From fc0889288023ceccf903b1984ad75fb82f2b9368 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 07:51:13 -0500 Subject: [PATCH 1/7] Add caching to the api-breakage check --- .github/workflows/run-unit-tests.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 20f107c..e17e5fc 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -105,6 +105,7 @@ permissions: env: WITH_TESTING: ${{ inputs.with_testing && '-Xswiftc -enable-testing' || '' }} PACKAGE_ROOT: ${{ inputs.package_root != '' && format('--package-path={0}', inputs.package_root) || '' }} + BASELINES: ${{ inputs.package_root || '.' }}/.api-breakage EXTRA_FLAGS: ${{ inputs.extra_flags || '--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable' }} EXTRA_MUSL_FLAGS: ${{ inputs.extra_musl_flags }} WITH_TSAN: ${{ inputs.with_tsan && '--sanitize=thread' || '' }} @@ -120,15 +121,20 @@ jobs: if: ${{ inputs.with_api_check && github.event_name == 'pull_request' && !github.event.pull_request.draft }} runs-on: ubuntu-latest container: swift:noble - timeout-minutes: 30 steps: - - name: Check out code - uses: actions/checkout@v6 - with: { 'fetch-depth': 0 } + - { name: Check out code, uses: actions/checkout@v6, with: { 'fetch-depth': 0 } } + - { name: Restore API baseline, uses: actions/cache/restore@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } - name: Run API breakage check - run: | - git config --global --add safe.directory "${GITHUB_WORKSPACE}" - swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes origin/main + run: swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main + api-breakage-baseline: + if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} + runs-on: ubuntu-latest + container: swift:noble + steps: + - { name: Check out code, uses: actions/checkout@v6, with: { 'fetch-depth': 0 } } + - name: Regenerate API breakage baseline + run: swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} --regenerate-baseline origin/main + - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } linux-unit: if: ${{ !(github.event.pull_request.draft || false) }} From 9fa14b1cb659788bb9e332d9099892303181a6cf Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 07:56:48 -0500 Subject: [PATCH 2/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index e17e5fc..4cf4eca 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -125,7 +125,9 @@ jobs: - { name: Check out code, uses: actions/checkout@v6, with: { 'fetch-depth': 0 } } - { name: Restore API baseline, uses: actions/cache/restore@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } - name: Run API breakage check - run: swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main + run: | + git config --global --add safe.directory "${GITHUB_WORKSPACE}" + swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main api-breakage-baseline: if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} runs-on: ubuntu-latest @@ -133,7 +135,9 @@ jobs: steps: - { name: Check out code, uses: actions/checkout@v6, with: { 'fetch-depth': 0 } } - name: Regenerate API breakage baseline - run: swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} --regenerate-baseline origin/main + run: | + git config --global --add safe.directory "${GITHUB_WORKSPACE}" + swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} --regenerate-baseline origin/main - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } linux-unit: From 00f118cba9febaa2c46c628ff9501628dabdc39f Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 08:40:50 -0500 Subject: [PATCH 3/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 4cf4eca..9318d32 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -128,8 +128,11 @@ jobs: run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main + ###REMOVE THIS BEFORE MERGING### + - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } + ###REMOVE THIS BEFORE MERGING### api-breakage-baseline: - if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} + #if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} runs-on: ubuntu-latest container: swift:noble steps: From d0c59585f099b5c1118f1543df3994625a469546 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 08:42:26 -0500 Subject: [PATCH 4/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 9318d32..98edd94 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -132,7 +132,7 @@ jobs: - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } ###REMOVE THIS BEFORE MERGING### api-breakage-baseline: - #if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} + if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} runs-on: ubuntu-latest container: swift:noble steps: From f5df6f19e5cb96a2948295d115a6b27514d326d0 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 08:49:02 -0500 Subject: [PATCH 5/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 98edd94..d7c4feb 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -128,11 +128,8 @@ jobs: run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main - ###REMOVE THIS BEFORE MERGING### - - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } - ###REMOVE THIS BEFORE MERGING### api-breakage-baseline: - if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} + #if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} runs-on: ubuntu-latest container: swift:noble steps: From 861ea32681cbdeecf5bbe10ddc22d888cc8c8c65 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 08:57:09 -0500 Subject: [PATCH 6/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index d7c4feb..c289038 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -138,6 +138,9 @@ jobs: run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} --regenerate-baseline origin/main + ##TESTING## + echo $RANDOM > ${BASELINES}/random.txt + ##TESTING## - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } linux-unit: From 0943fac2ccc404256a5f2da1d96577aac896e9d8 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 10 Mar 2026 09:05:23 -0500 Subject: [PATCH 7/7] Update run-unit-tests.yml --- .github/workflows/run-unit-tests.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index c289038..b5f0069 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -123,13 +123,19 @@ jobs: container: swift:noble steps: - { name: Check out code, uses: actions/checkout@v6, with: { 'fetch-depth': 0 } } - - { name: Restore API baseline, uses: actions/cache/restore@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } + - name: Restore API baseline + uses: actions/cache/restore@v5 + with: + path: ${{ env.BASELINES }} + # N.B.: Do not use restore-keys to restore a different api-breakage cache; the result will be a comparison against + # an outdated baseline, which invalidates the check. + key: api-breakage-${{ github.event.pull_request.base.sha }} - name: Run API breakage check run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} origin/main api-breakage-baseline: - #if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} + if: ${{ inputs.with_api_check && github.event_name == 'push' && github.ref == 'main' }} runs-on: ubuntu-latest container: swift:noble steps: @@ -138,10 +144,11 @@ jobs: run: | git config --global --add safe.directory "${GITHUB_WORKSPACE}" swift package ${PACKAGE_ROOT} diagnose-api-breaking-changes --baseline-dir=${BASELINES} --regenerate-baseline origin/main - ##TESTING## - echo $RANDOM > ${BASELINES}/random.txt - ##TESTING## - - { name: Cache API baseline, uses: actions/cache/save@v5, with: { path: "${{ env.BASELINES }}", key: api-breakage } } + - name: Cache API baseline + uses: actions/cache/save@v5 + with: + path: ${{ env.BASELINES }} + key: api-breakage-${{ github.sha }} linux-unit: if: ${{ !(github.event.pull_request.draft || false) }}