Skip to content

Commit

Permalink
CI: Only run jobs when files changed (#490)
Browse files Browse the repository at this point in the history
* CI: Only run jobs when files changed

* CI: Comments about why we run tests on main
  • Loading branch information
aakoshh authored Dec 20, 2023
1 parent 6284eba commit cc07711
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
67 changes: 62 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,48 @@ on:


jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
contracts: ${{ steps.filter.outputs.contracts }}
fvm-utils: ${{ steps.filter.outputs.fvm-utils }}
ipc: ${{ steps.filter.outputs.ipc }}
ipld-resolver: ${{ steps.filter.outputs.ipld-resolver }}
fendermint: ${{ steps.filter.outputs.fendermint }}
steps:
# For pull requests it's not necessary to checkout the code,
# but the workflow is also triggered on pushes to `main`.
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
contracts:
- 'contracts/**'
fvm-utils:
- 'fvm-utils/**'
ipc:
- 'ipc/**'
ipld-resolver:
- 'ipld-resolver/**'
fendermint:
- 'fendermint/**'
license:
uses: ./.github/workflows/license.yaml

contracts-prettier:
uses: ./.github/workflows/contracts-prettier.yaml
needs: [changes]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
github.ref == 'refs/heads/main'
contracts-test:
uses: ./.github/workflows/contracts-test.yaml
Expand All @@ -40,24 +77,44 @@ jobs:

fvm-utils:
uses: ./.github/workflows/fvm-utils.yaml
needs: [license]
needs: [changes, license]
if: >-
needs.changes.filter.outputs.fvm-utils == 'true' ||
github.ref == 'refs/heads/main'
ipc:
uses: ./.github/workflows/ipc.yaml
needs: [license]
needs: [changes, license]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
needs.changes.filter.outputs.ipc == 'true' ||
github.ref == 'refs/heads/main'
ipld-resolver:
uses: ./.github/workflows/ipld-resolver.yaml
needs: [license]
needs: [changes, license]
if: >-
needs.changes.filter.outputs.ipld-resolver == 'true' ||
github.ref == 'refs/heads/main'
fendermint-test:
uses: ./.github/workflows/fendermint-test.yaml
needs: [license]
needs: [changes, license]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
needs.changes.filter.outputs.ipc == 'true' ||
needs.changes.filter.outputs.ipld-resolver == 'true' ||
needs.changes.filter.outputs.fendermint == 'true' ||
github.ref == 'refs/heads/main'
fendermint-publish:
uses: ./.github/workflows/fendermint-publish.yaml
secrets: inherit
# Dependencies are not strictly necessary, but if fendermint tests pass they publish docker too, so they better work
# Dependencies are not strictly necessary, but if fendermint tests pass they publish docker too, so they better work.
# It is because of these needs that all the filters are allowed to run on `main` too, otherwise this would be disabled.
# It could be done in a more granular approach inside the workflows to allow the job to pass but opt-out of testing,
# but I guess it doesn't hurt to run a final round of unconditional tests, even though it takes longer to publish.
if: github.ref == 'refs/heads/main'
needs:
- contracts-test # generates the ABI artifacts (although fendermint can do on its own too)
- fvm-utils
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/fendermint-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
cache-prefix: publish-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') }}
cache-suffix: ${{ hashFiles('**/Cargo.lock') }}

- name: Cache Solidity ABI arfiacts
uses: actions/cache@v2
with:
path: ./contracts/out
key: contracts-abi-${{ hashFiles('./contracts/src/**/*.sol') }}

# - name: Docker Build
# run: make docker-build

Expand Down

0 comments on commit cc07711

Please sign in to comment.