-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I have a project that uses the nrwl/ci/.github/workflows/nx-cloud-main.yml@refs/tags/v0.14 action and some agents to run my Playwright tests for my project.
In my previous setup, I used playwright's sharding feature, where you gather the blob reports from each shard job as artifacts and then consolidate then in a subsequent job.
With using the nx-cloud-main workflow mentioned above, I set the input values for collecting some artifacts. But unfortunately the Upload Artifacts step only runs if the main job was successful. See
ci/.github/workflows/nx-cloud-main.yml
Lines 368 to 374 in 81f1194
| - name: Uploading artifacts | |
| uses: actions/upload-artifact@v3 | |
| if: ${{ inputs.artifacts-path != '' }} | |
| with: | |
| name: ${{ inputs.artifacts-name }} | |
| path: ${{ inputs.artifacts-path }} | |
| retention-days: ${{ inputs.artifacts-retention-days }} |
The Playwright sharding docs recommend to use if: always() in the "Upload Artifact" step:
- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1This will allow for artifacts for failed tests to be uploaded too, which is pretty essential.
Is there a recommended approach here, or is this a change that needs to be made to the nx-cloud-main workflow?
Potential solutions:
- Provide some guidance to your users that they should include
|| trueto the end of the command where failures are acceptable
- This will unfortunately give a false signal of success for the main job
- Add the
always()expression to the condition in the "Upload Artifacts" step
- This may be an unexpected behaviour for some users
- Add an input
artifacts-always-uploadto the workflow that allows a user to conditionally turn this behaviour on.
- The condition in the step would become:
if: ${{ inputs.artifacts-path != '' && (success() || (failure() && inputs.artifacts-always-upload)) }}
- Extract the steps of this workflow as a github action (which would exclude the artifact bit) so that users can leverage this code within their own job and handle artifacts how they wish. The
nx-could-mainworkflow in your repository would then also use this extracted action.
What do you think?