Skip to content

Commit

Permalink
chore: update GitHub actions workflow with examples test information (#…
Browse files Browse the repository at this point in the history
…256)

- Refactor example test info into `example_infos`.
- Add `example_infos.write_json` rule to serialize information about the
example tests.
- Add `//tools/generate_ci_workflow` to read a GitHub workflow file and
update specific matrix strategy sections.
- Add `//:ci_workflow` to generate the correct GH workflow file.
- Add `//:update` to ensure that the most up-to-date GH workflow file
has been copied to `.github/workflows/ci.yml`.

Related to #206.
  • Loading branch information
cgrindel authored Mar 3, 2023
1 parent ef0946e commit 53cc37f
Show file tree
Hide file tree
Showing 12 changed files with 755 additions and 220 deletions.
199 changes: 102 additions & 97 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,119 +1,124 @@
# This file is processed by //tools/generate_ci_workflow. Specifically, the
# matrix strategy sections for the integration test matrix jobs are updated with
# the values from //examples:json.
#
# Note:
# - Modification to values outside of the matrix strategy sections should
# persist.
# - Comments and custom formatting will be lost.
name: Continuous Integration

on:
"on":
pull_request:
branches: [ main ]
branches:
- main
schedule:
# Every day at 11:14 UTC.
- cron: '14 11 * * *'

- cron: 14 11 * * *
jobs:

macos_tidy_and_test:
runs-on: macos-12
all_ci_tests:
runs-on: ubuntu-20.04
needs:
- macos_tidy_and_test
- macos_int_test_matrix
- ubuntu_tidy_and_test
- ubuntu_int_test_matrix
if: ${{ always() }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_macos
with:
xcode_version: '14.0.1'
repo_name: swift_bazel
- name: Ensure everything is tidy
shell: bash
run: |
bazelisk run //:tidy_check
- name: Execute Tests
shell: bash
run: |
bazelisk test //...
- uses: cgrindel/gha_join_jobs@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
macos_int_test_matrix:
strategy:
matrix:
example:
- "http_archive_ext_deps"
- "pkg_manifest_minimal"
bazel_version:
- ".bazelversion"
- "5_4_0"
include:
- example: "firebase_example"
bazel_version: ".bazelversion"
- example: "interesting_deps"
bazel_version: ".bazelversion"
- example: "ios_sim"
bazel_version: ".bazelversion"
- example: "objc_code"
bazel_version: ".bazelversion"
- example: "phone_number_kit"
bazel_version: ".bazelversion"
- example: "xcmetrics_example"
bazel_version: ".bazelversion"
- example: http_archive_ext_deps
bazel_version: .bazelversion
- example: http_archive_ext_deps
bazel_version: "5_4_0"
- example: pkg_manifest_minimal
bazel_version: .bazelversion
- example: pkg_manifest_minimal
bazel_version: "5_4_0"
- example: vapor_example
bazel_version: .bazelversion
- example: firebase_example
bazel_version: .bazelversion
- example: interesting_deps
bazel_version: .bazelversion
- example: ios_sim
bazel_version: .bazelversion
- example: objc_code
bazel_version: .bazelversion
- example: phone_number_kit
bazel_version: .bazelversion
- example: xcmetrics_example
bazel_version: .bazelversion
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_macos
with:
xcode_version: '14.0.1'
repo_name: swift_bazel
- uses: ./.github/actions/test_example
with:
example_name: ${{ matrix.example }}
bazel_version: ${{ matrix.bazel_version }}

ubuntu_tidy_and_test:
runs-on: ubuntu-22.04
env:
CC: clang
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_macos
with:
repo_name: swift_bazel
xcode_version: 14.0.1
- uses: ./.github/actions/test_example
with:
bazel_version: ${{ matrix.bazel_version }}
example_name: ${{ matrix.example }}
macos_tidy_and_test:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_ubuntu
with:
repo_name: swift_bazel
ubuntu_version: "22.04"
- name: Ensure everything is tidy
shell: bash
run: |
bazelisk run //:tidy_check
- name: Execute Tests
shell: bash
run: |
bazelisk test //...
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_macos
with:
repo_name: swift_bazel
xcode_version: 14.0.1
- name: Ensure everything is tidy
shell: bash
run: |
bazelisk run //:tidy_check
- name: Execute Tests
shell: bash
run: "bazelisk test //... \n"
ubuntu_int_test_matrix:
strategy:
matrix:
example:
- "http_archive_ext_deps"
- "pkg_manifest_minimal"
bazel_version:
- ".bazelversion"
- "5_4_0"
include:
- example: vapor_example
bazel_version: ".bazelversion"
- example: http_archive_ext_deps
bazel_version: .bazelversion
- example: http_archive_ext_deps
bazel_version: "5_4_0"
- example: pkg_manifest_minimal
bazel_version: .bazelversion
- example: pkg_manifest_minimal
bazel_version: "5_4_0"
- example: vapor_example
bazel_version: .bazelversion
runs-on: ubuntu-22.04
env:
CC: clang
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_ubuntu
with:
repo_name: swift_bazel
ubuntu_version: "22.04"
- uses: ./.github/actions/test_example
with:
example_name: ${{ matrix.example }}
bazel_version: ${{ matrix.bazel_version }}

all_ci_tests:
runs-on: ubuntu-20.04
needs:
- macos_tidy_and_test
- macos_int_test_matrix
- ubuntu_tidy_and_test
- ubuntu_int_test_matrix
if: ${{ always() }}
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_ubuntu
with:
repo_name: swift_bazel
ubuntu_version: "22.04"
- uses: ./.github/actions/test_example
with:
bazel_version: ${{ matrix.bazel_version }}
example_name: ${{ matrix.example }}
ubuntu_tidy_and_test:
runs-on: ubuntu-22.04
env:
CC: clang
steps:
- uses: cgrindel/gha_join_jobs@v1
- uses: actions/checkout@v3
- uses: ./.github/actions/set_up_ubuntu
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repo_name: swift_bazel
ubuntu_version: "22.04"
- name: Ensure everything is tidy
shell: bash
run: |
bazelisk run //:tidy_check
- name: Execute Tests
shell: bash
run: "bazelisk test //... \n"
33 changes: 32 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_missing_pkgs", "bzlformat_pkg")
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
load("@cgrindel_bazel_starlib//markdown:defs.bzl", "markdown_pkg")
load("@cgrindel_bazel_starlib//shlib/rules:execute_binary.bzl", "execute_binary")
load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_update_all")
load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_diff_and_update", "updatesrc_update_all")
load(
"@contrib_rules_bazel_integration_test//bazel_integration_test:defs.bzl",
"integration_test_utils",
Expand Down Expand Up @@ -190,6 +191,36 @@ test_suite(
visibility = ["//:__subpackages__"],
)

# MARK: - CI Workflow

run_binary(
name = "ci_workflow",
srcs = [
".github/workflows/ci.yml",
"//examples:json",
],
outs = ["ci.yml"],
args = [
"-template",
"$(location .github/workflows/ci.yml)",
"-example_json",
"$(location //examples:json)",
"-output",
"$(location ci.yml)",
],
tool = "//tools/generate_ci_workflow",
)

updatesrc_diff_and_update(
name = "update",
srcs = [
".github/workflows/ci.yml",
],
outs = [
":ci_workflow",
],
)

bzl_library(
name = "bazel_versions",
srcs = ["bazel_versions.bzl"],
Expand Down
Loading

0 comments on commit 53cc37f

Please sign in to comment.