Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/actions/cache-swiftpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Cache SwiftPM
description: Cache exact build inputs and reusable dependency downloads separately.

inputs:
build-variant:
description: Build configuration and target architecture or Swift SDK
required: true
cache-build:
description: Cache compiled output for builds without per-run generated inputs
default: "true"

runs:
using: composite
steps:
- name: Fingerprint build environment
if: inputs.cache-build == 'true'
id: environment
shell: bash
run: |
FINGERPRINT="$RUNNER_TEMP/swiftpm-environment.txt"
swift --version > "$FINGERPRINT"
swift sdk list >> "$FINGERPRINT"
printf '%s\n' "$GITHUB_WORKSPACE" "$RUNNER_OS" "$RUNNER_ARCH" \
"${ImageOS:-}" "${ImageVersion:-}" >> "$FINGERPRINT"
if [[ "$RUNNER_OS" == macOS ]]; then
sw_vers >> "$FINGERPRINT"
xcrun clang --version >> "$FINGERPRINT"
xcrun --sdk macosx --show-sdk-path >> "$FINGERPRINT"
xcrun --sdk macosx --show-sdk-build-version >> "$FINGERPRINT"
else
cat /etc/os-release >> "$FINGERPRINT"
clang --version >> "$FINGERPRINT"
ldd --version >> "$FINGERPRINT"
fi
HASH=$(shasum -a 256 "$FINGERPRINT" | cut -d ' ' -f 1)
echo "hash=$HASH" >> "$GITHUB_OUTPUT"

# Build databases and compiled modules are reused only for identical inputs.
# In particular, generated release metadata must be written before this action.
- name: Cache exact SwiftPM build
if: inputs.cache-build == 'true'
id: build
uses: actions/cache@v6
with:
path: .build
key: swiftpm-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.environment.outputs.hash }}-${{ inputs.build-variant }}-${{ hashFiles('Package.swift', 'Package.resolved', 'Sources/**', 'Tests/**', 'Makefile', '.github/actions/**', '.github/workflows/**') }}

# SwiftPM still resolves and validates the locked dependency graph on a miss.
# Do not restore build databases or compiled modules from a partial match.
- name: Cache SwiftPM dependencies
if: steps.build.outputs.cache-hit != 'true'
uses: actions/cache@v6
with:
path: |
.build/repositories
.build/checkouts
.build/artifacts
key: swiftpm-dependencies-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Package.swift', 'Package.resolved') }}
21 changes: 21 additions & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ jobs:
commit-sha: ${{ inputs.commit_sha }}
build-date: ${{ inputs.build_date }}

- name: Cache SwiftPM
uses: ./.github/actions/cache-swiftpm
with:
build-variant: darwin-${{ matrix.architecture }}-release
# Release metadata changes every run, so exact build caches cannot be reused.
cache-build: "false"

- name: Build CLI
id: build
run: |
Expand Down Expand Up @@ -127,7 +134,15 @@ jobs:
with:
swift-version: "6.4.0"

- name: Cache Static Linux SDK
id: linux-sdk
uses: actions/cache@v6
with:
path: ~/.swiftpm/swift-sdks
key: swift-static-sdk-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile', '.github/actions/setup-swift/**') }}

- name: Install Static Linux SDK
if: steps.linux-sdk.outputs.cache-hit != 'true'
run: make install-linux-sdk

- name: Generate build metadata
Expand All @@ -137,6 +152,12 @@ jobs:
commit-sha: ${{ inputs.commit_sha }}
build-date: ${{ inputs.build_date }}

- name: Cache SwiftPM
uses: ./.github/actions/cache-swiftpm
with:
build-variant: ${{ matrix.swift_sdk }}-release
cache-build: "false"

- name: Build CLI with debug information
id: build-linux
run: |
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/build.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
prepare:
name: Prepare Release
Expand Down Expand Up @@ -88,6 +92,17 @@ jobs:
build_date: ${{ needs.prepare.outputs.build_date }}
secrets: inherit

build-required-check:
name: Build
needs: build-cli-binaries
if: always()
runs-on: ubuntu-latest
steps:
- name: Check build result
env:
BUILD_RESULT: ${{ needs.build-cli-binaries.result }}
run: test "$BUILD_RESULT" = success

release:
name: Create Release
needs: [prepare, build-cli-binaries]
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
with:
swift-version: "6.4.0"

- name: Cache SwiftPM
uses: ./.github/actions/cache-swiftpm
with:
build-variant: macos-native-debug

- name: Make Test
run: make test

Expand All @@ -43,5 +48,10 @@ jobs:
with:
swift-version: "6.4.0"

- name: Cache SwiftPM
uses: ./.github/actions/cache-swiftpm
with:
build-variant: linux-native-debug

- name: Make Test
run: make test
Loading