Skip to content

Commit

Permalink
fix(ci): Bring back job skipping for PRs without code changes (#13340)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Aug 13, 2024
1 parent 334f869 commit 6c0f01a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
profiling_node:
- 'packages/profiling-node/**'
- 'dev-packages/e2e-tests/test-applications/node-profiling/**'
any_code:
- '!**/*.md'
- name: Get PR labels
Expand All @@ -109,6 +111,8 @@ jobs:
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
changed_profiling_node: ${{ steps.changed.outputs.profiling_node == 'true' }}
changed_ci: ${{ steps.changed.outputs.workflow == 'true' }}
changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }}

# When merging into master, or from master
is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }}
has_gitflow_label:
Expand All @@ -123,6 +127,7 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 15
if: |
(needs.job_get_metadata.outputs.changed_any_code) &&
(needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false')
steps:
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
Expand Down Expand Up @@ -274,24 +279,37 @@ jobs:

job_check_format:
name: Check file formatting
needs: [job_get_metadata, job_build]
needs: [job_get_metadata]
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT"

- name: Check dependency cache
uses: actions/cache/restore@v4
uses: actions/cache@v4
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
fail-on-cache-miss: true
key: ${{ steps.compute_lockfile_hash.outputs.hash }}

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-engines --frozen-lockfile

- name: Check file formatting
run: yarn lint:prettier && yarn lint:biome

Expand Down

0 comments on commit 6c0f01a

Please sign in to comment.