Skip to content

Commit

Permalink
ci: use shared action for detecting changes
Browse files Browse the repository at this point in the history
* also updated actions/checkout to v3
  • Loading branch information
pchrysochoidis committed Apr 21, 2022
1 parent 0dae398 commit 22246cc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 40 deletions.
26 changes: 26 additions & 0 deletions .github/actions/diffs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Detect Changes
description: Defines variables indicating the parts of the code that changed
outputs:
isRust:
description: True when changes happened to the rust code
value: "${{ steps.diff.outputs.isRust }}"
isExplorerClient:
description: True when there are changes to files related to explorer client
value: "${{ steps.diff.outputs.isExplorerClient }}"
runs:
using: composite
steps:
- uses: actions/checkout@v3
- name: Detect Changes
uses: dorny/[email protected]
id: diff
with:
filters: |
isRust:
- '!(explorer|doc|.github)/**'
- '.github/workflows/bench.yml'
- '.github/workflows/codecov.yml'
- '.github/workflows/rust.yml'
isExplorerClient:
- 'explorer/client/**'
- '.github/workflows/explorer-client-prs.yml'
12 changes: 4 additions & 8 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ jobs:
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Detect Changes
uses: dorny/[email protected]
uses: './.github/actions/diffs'
id: diff
with:
filters: |
isRust:
- '!(explorer|doc|.github)/**'
- '.github/workflows/bench.yml'

bench:
needs: diff
if: github.event.pull_request.draft == false && needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ jobs:
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Detect Changes
uses: dorny/[email protected]
uses: './.github/actions/diffs'
id: diff
with:
filters: |
isRust:
- '!(explorer|doc|.github)/**'
- '.github/workflows/bench.yml'

codecov-grcov:
name: Generate code coverage
Expand All @@ -32,7 +27,7 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: llvm-tools-preview
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/explorer-client-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ jobs:
diff:
runs-on: ubuntu-latest
outputs:
isClient: ${{ steps.diff.outputs.isClient }}
isClient: ${{ steps.diff.outputs.isExplorerClient }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Detect Changes
uses: dorny/[email protected]
uses: './.github/actions/diffs'
id: diff
with:
filters: |
isClient:
- 'explorer/client/**'
- '.github/workflows/explorer-client-prs.yml'
client_checks:
name: Lint, Test & Build
needs: diff
if: needs.diff.outputs.isClient == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Nodejs
uses: actions/setup-node@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
name: Run test on the beta channel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install beta toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -51,7 +51,7 @@ jobs:
name: build release binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- name: cargo build
uses: actions-rs/cargo@v1
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,16 @@ jobs:
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Detect Changes
uses: dorny/[email protected]
uses: './.github/actions/diffs'
id: diff
with:
filters: |
isRust:
- '!(explorer|doc|.github)/**'
- '.github/workflows/rust.yml'

license-check:
name: license-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: scripts/license_check.sh

test:
Expand All @@ -58,7 +53,7 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
Expand All @@ -76,7 +71,7 @@ jobs:
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: clippy
Expand All @@ -94,7 +89,7 @@ jobs:
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
components: rustfmt
Expand All @@ -110,15 +105,15 @@ jobs:
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1

cargo-udeps:
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
Expand Down

0 comments on commit 22246cc

Please sign in to comment.