Skip to content

Commit

Permalink
implement caching .build on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Dec 14, 2024
1 parent 1fd5aca commit d6abc25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ on:
required: false
default: false
description: "Set to 'true' to enable testing in release mode as well. Defaults to 'false'."
with_experimental_caching:
type: boolean
required: false
default: false
description: "Set to 'true' to enable caching ''.build' in tests. Defaults to 'false'."
with_coverage:
type: boolean
required: false
Expand Down Expand Up @@ -136,6 +141,14 @@ jobs:
uses: vapor/ci/.github/actions/check-compatible-swift@main
with:
package_root: ${{ inputs.package_root }}
- name: Restore .build
if: ${{ inputs.with_experimental_caching && (steps.swift-check.outputs.swift-compatible == 'true') && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
id: "restore-cache"
uses: actions/cache/restore@v4
with:
path: .build
key: "${{ github.event.repository.name }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
restore-keys: "${{ github.event.repository.name }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-"
- name: Run unit tests
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
run: |
Expand All @@ -149,6 +162,12 @@ jobs:
${WITH_COVERAGE} \
${TEST_FILTER} \
${EXTRA_FLAGS}
- name: Cache .build
if: ${{ inputs.with_experimental_caching && (steps.restore-cache.outputs.cache-hit != 'true') && (steps.swift-check.outputs.swift-compatible == 'true') && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
uses: actions/cache/save@v4
with:
path: .build
key: "${{ github.event.repository.name }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
- name: Upload coverage data
if: ${{ inputs.with_coverage && (steps.swift-check.outputs.swift-compatible == 'true') && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
uses: vapor/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
uses: ./.github/workflows/run-unit-tests.yml
with:
with_release_mode_testing: ${{ inputs.with_release_mode_testing || true }}
with_experimental_caching: true
with_coverage: ${{ inputs.with_coverage || false }}
with_tsan: ${{ inputs.with_tsan || false }}
with_api_check: ${{ inputs.with_api_check || true }}
Expand Down

0 comments on commit d6abc25

Please sign in to comment.