You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used to use CircleCI and have recently started trialing GitHub Actions. My project uses pnpm and nx. There is one scenario that I am finding difficult to implement as illustrated in this action:
name: CI/CDon:
push:
branches: ['main']jobs:
lint_and_unit_tests:
runs-on: ubuntu-latestpermissions:
contents: readactions: readsteps:
- uses: actions/checkout@v3with:
# Required by nx-set-shasfetch-depth: 0
- uses: pnpm/action-setup@v2with:
version: 8
- uses: actions/setup-node@v3with:
node-version: 18.xcache: pnpm
- name: Install dependenciesrun: pnpm i
- name: Derive appropriate SHAs for base and head for nx affected commandsuses: nrwl/nx-set-shas@v3with:
error-on-no-successful-workflow: true
- name: List affected projectsrun: pnpm list-affacted-projects
- name: Run lint & unit tests on affected projects onlyrun: | pnpm lint:affected pnpm test:affected
- name: Run lint & unit tests on ALL projectsif: ${{ failure() }}run: | pnpm lint:all pnpm test:all
The step Derive appropriate SHAs for base and head for nx affected commands makes use of nx to detect the last successful workflow. If it finds one, then it will only build the projects in my monorepo that were affected by the changes since the last successful workflow.
Now, I have made several checkins which all failed due to various reasons. Once I fixed those, then I hit the issue I am describing here. Since there is no "last successful" workflow, the step Derive appropriate SHAs for base and head for nx affected commands fails because I have set its error-on-no-successful-workflow to true. If I remove tis setting then it defaults to comparing what changed since HEAD~1. In my scenario that would yield the wrong set of files which is why I have set this parameter to true.
What I was expecting to happen, and what actually happens, is that the steps List affected projects and Run lint & unit tests on affected projects only get skipped due to the failure and instead the step Run lint & unit tests on ALL projects is run.
However, after a successful run of the step Run lint & unit tests on ALL projects, the job itself fails when in fact I wanted it to succeed unless of course the step Run lint & unit tests on ALL projects itself fails.
I was hoping that I could somehow reset the jobs failure marker in the step Run lint & unit tests on ALL projects - something along the lines of:
...
- name: Run lint & unit tests on ALL projectsif: ${{ failure() }}uses: actions/reset-job-failurerun: | pnpm lint:all pnpm test:all
where I have made up a GitHub action named uses: actions/reset-job-failure.
Is this possible to do and, if not, would it be possible to add this enhancement? Alternatively, is there another way to achieve my requirements?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I used to use CircleCI and have recently started trialing GitHub Actions. My project uses pnpm and nx. There is one scenario that I am finding difficult to implement as illustrated in this action:
The step
Derive appropriate SHAs for base and head for nx affected commands
makes use of nx to detect the last successful workflow. If it finds one, then it will only build the projects in my monorepo that were affected by the changes since the last successful workflow.Now, I have made several checkins which all failed due to various reasons. Once I fixed those, then I hit the issue I am describing here. Since there is no "last successful" workflow, the step
Derive appropriate SHAs for base and head for nx affected commands
fails because I have set itserror-on-no-successful-workflow
totrue
. If I remove tis setting then it defaults to comparing what changed sinceHEAD~1
. In my scenario that would yield the wrong set of files which is why I have set this parameter totrue
.What I was expecting to happen, and what actually happens, is that the steps
List affected projects
andRun lint & unit tests on affected projects only
get skipped due to the failure and instead the stepRun lint & unit tests on ALL projects
is run.However, after a successful run of the step
Run lint & unit tests on ALL projects
, the job itself fails when in fact I wanted it to succeed unless of course the stepRun lint & unit tests on ALL projects
itself fails.I was hoping that I could somehow reset the jobs failure marker in the step
Run lint & unit tests on ALL projects
- something along the lines of:where I have made up a GitHub action named
uses: actions/reset-job-failure
.Is this possible to do and, if not, would it be possible to add this enhancement? Alternatively, is there another way to achieve my requirements?
Beta Was this translation helpful? Give feedback.
All reactions