Derive catalog cache keys from the filter (#207) #275
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| classify: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| code_changed: ${{ steps.changes.outputs.code_changed }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Classify changes | |
| id: changes | |
| shell: bash | |
| env: | |
| BEFORE_SHA: ${{ github.event.before }} | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| git diff --name-only "origin/${GITHUB_BASE_REF}...HEAD" > "$RUNNER_TEMP/changed-files" | |
| elif [[ -n "${BEFORE_SHA:-}" && ! "$BEFORE_SHA" =~ ^0+$ ]] && git cat-file -e "$BEFORE_SHA^{commit}"; then | |
| git diff --name-only "$BEFORE_SHA...HEAD" > "$RUNNER_TEMP/changed-files" | |
| elif git rev-parse HEAD^ >/dev/null 2>&1; then | |
| git diff --name-only HEAD^ HEAD > "$RUNNER_TEMP/changed-files" | |
| else | |
| git ls-files > "$RUNNER_TEMP/changed-files" | |
| fi | |
| if grep -Ev '(^|/)([^/]+\.md)$' "$RUNNER_TEMP/changed-files" | grep -q .; then | |
| echo "code_changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "code_changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| sed 's/^/- /' "$RUNNER_TEMP/changed-files" >> "$GITHUB_STEP_SUMMARY" | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check whitespace | |
| shell: bash | |
| env: | |
| BEFORE_SHA: ${{ github.event.before }} | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| git diff --check "origin/${GITHUB_BASE_REF}...HEAD" | |
| elif [[ -n "${BEFORE_SHA:-}" && ! "$BEFORE_SHA" =~ ^0+$ ]] && git cat-file -e "$BEFORE_SHA^{commit}"; then | |
| git diff --check "$BEFORE_SHA...HEAD" | |
| elif git rev-parse HEAD^ >/dev/null 2>&1; then | |
| git diff --check HEAD^ HEAD | |
| else | |
| git diff --check | |
| fi | |
| - name: Check relative Markdown links | |
| uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0 | |
| with: | |
| args: --offline --root-dir "${{ github.workspace }}" --no-progress './**/*.md' | |
| fail: true | |
| build-and-test: | |
| needs: classify | |
| if: needs.classify.outputs.code_changed == 'true' | |
| runs-on: macos-26 | |
| env: | |
| SWIFTLY_VERSION: "1.1.3" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Swift with Swiftly | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| curl --fail --location --retry 3 \ | |
| "https://download.swift.org/swiftly/darwin/swiftly-${SWIFTLY_VERSION}.pkg" \ | |
| --output "$RUNNER_TEMP/swiftly.pkg" | |
| installer -pkg "$RUNNER_TEMP/swiftly.pkg" -target CurrentUserHomeDirectory | |
| "$HOME/.swiftly/bin/swiftly" init --assume-yes --skip-install --no-modify-profile | |
| source "$HOME/.swiftly/env.sh" | |
| swiftly install --assume-yes | |
| echo "$HOME/.swiftly/bin" >> "$GITHUB_PATH" | |
| swift --version | grep -F "Swift version $(tr -d '[:space:]' < .swift-version)" | |
| - name: Cache Swift packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: .build | |
| key: ${{ runner.os }}-swift-${{ hashFiles('.swift-version') }}-spm-${{ hashFiles('Package.resolved') }} | |
| restore-keys: | | |
| ${{ runner.os }}-swift-${{ hashFiles('.swift-version') }}-spm- | |
| - name: Test | |
| run: swift test | |
| - name: Build release product | |
| run: swift build -c release --product focusrelay | |
| - name: Check minimum macOS | |
| run: ./scripts/check-minimum-macos.sh .build/release/focusrelay | |
| - name: Check release surface | |
| run: ./scripts/check-bridge-only-architecture.sh .build/debug/focusrelay .build/release/focusrelay | |
| ci: | |
| if: always() | |
| needs: [classify, docs, build-and-test] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Require selected checks | |
| env: | |
| CLASSIFY_RESULT: ${{ needs.classify.result }} | |
| DOCS_RESULT: ${{ needs.docs.result }} | |
| CODE_CHANGED: ${{ needs.classify.outputs.code_changed }} | |
| BUILD_RESULT: ${{ needs.build-and-test.result }} | |
| run: | | |
| set -euo pipefail | |
| test "$CLASSIFY_RESULT" = success | |
| test "$DOCS_RESULT" = success | |
| if test "$CODE_CHANGED" = true; then | |
| test "$BUILD_RESULT" = success | |
| fi |