Improvements v2 #391
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR | |
# Run on all pull requests | |
on: [ pull_request ] | |
env: | |
NX_BRANCH: ${{ github.event.number }} | |
NX_RUN_GROUP: ${{ github.run_id }} | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.plan.outputs.matrix }} | |
hasPlan: ${{ steps.plan.outputs.hasPlan }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache node modules | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
key: cache-node-modules-${{ hashFiles('yarn.lock') }} | |
- name: yarn install | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: yarn install | |
- name: Derive appropriate SHAs for base and head for `nx affected` commands | |
uses: ./actions/set-shas | |
with: | |
main-branch-name: master | |
- name: Plan | |
id: plan | |
uses: ./actions/plan | |
with: | |
targets: | | |
test | |
build | |
e2e | |
testMaxJobs: 1 | |
buildMaxJobs: 2 | |
e2eMaxJobs: 2 | |
distributed-task: | |
name: Distributed ${{ matrix.target }} ${{ matrix.index }}/${{ matrix.count }} | |
needs: | |
- setup | |
runs-on: ubuntu-latest | |
if: needs.setup.outputs.hasPlan == 'true' | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} | |
steps: | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.10 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache node modules | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
key: cache-node-modules-${{ hashFiles('yarn.lock') }} | |
- name: Derive appropriate SHAs for base and head for `nx affected` commands | |
uses: ./actions/set-shas | |
with: | |
main-branch-name: master | |
- name: GIT config | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: nx affected:version | |
if: matrix.target == 'build' | |
uses: ./actions/run-many | |
with: | |
target: version | |
- name: nx affected:${{ matrix.target }} | |
uses: ./actions/run-many | |
with: | |
target: ${{ matrix.target }} | |
index: ${{ matrix.index }} | |
count: ${{ matrix.count }} | |
tag: ${{ matrix.tag }} | |
parallel: ${{ matrix.parallel }} | |
# So we can add branch protection that this one is required | |
distributed-check: | |
name: Distributed check | |
runs-on: ubuntu-latest | |
needs: | |
- distributed-task | |
if: | | |
!cancelled() | |
steps: | |
- name: Check | |
if: | | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
run: echo "Ok" | |
- name: Fail | |
if: | | |
contains(needs.*.result, 'failure') || | |
contains(needs.*.result, 'cancelled') | |
run: exit 1 |