Open benjamincharity opened 4 years ago
Currently it is not possible to not fail the workflow if no artifact is found
Some customization is on the way for upload-artifact
: https://github.com/actions/upload-artifact/pull/104
Perhaps a similar option could prove useful for download-artifact
. Something like if-no-artifact:
with options error
, warn
or ignore
? 🤔
Any updates on this issue?
Currently it is not possible to not fail the workflow if no artifact is found
Some customization is on the way for
upload-artifact
: actions/upload-artifact#104Perhaps a similar option could prove useful for
download-artifact
. Something likeif-no-artifact:
with optionserror
,warn
orignore
? 🤔
I was having the same issue. After reviewing the method used, I can see that if you don't specific a name on the download, it will attempt to create the directories regardless.
const artifactClient = artifact.create() if (!name) { // download all artifacts core.info('No artifact name specified, downloading all artifacts') core.info( 'Creating an extra directory for each artifact that is being downloaded' )
This worked for me as a work around.
@benjamincharity maybe use
continue-on-error: true
-- see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
@benjamincharity maybe use
continue-on-error: true
-- see docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
I called this out in the original edit. There are multiple ways to functionally unblock ourselves to get around this, but from what I've seen each method will still mark our workflow as failed in the PR and primary repo badge. So any contributor or consumer needs to actually go see if our build is really failing or if it is just one optional step that is failing.
@benjamincharity you should check on this again.
i dd a quick playground to replicate the behavior you described.
i used continue-on-error: true
it marks the workflow as passed, badges are passed.
even the step is marked as passed. see https://github.com/jkowalleck/playground_download-artifact_issue-42/runs/1022858445?check_suite_focus=true
PS: nevertheless i like idea of @konradpabjan as of https://github.com/actions/download-artifact/issues/42#issuecomment-665569569
@jkowalleck thanks for calling this out. From your test it sure does looks like you are correct. I'll be happy to be wrong on this 😄 I will give it a test as soon as I can. Thanks!
Hi, we fixed it in if statement. We check for existence of coverage file:
- name: Check file existence for sonar integration
id: sonar
uses: andstor/file-existence-action@v1
with:
files: "sonar-project.properties, coverage/lcov.info"
- name: Upload coverage file
if: steps.sonar.outputs.files_exists == 'true'
uses: actions/upload-artifact@v2
with:
name: coverage-file
path: coverage/lcov.info
hope it helps someone, we made it defensive since its a pipeline for multiple apps. Some are mature and some not :)
@konradpabjan would you accept a PR that adds the if-no-artifact
input as you suggested?
Hi, we fixed it in if statement. We check for existence of coverage file:
- name: Check file existence for sonar integration id: sonar uses: andstor/file-existence-action@v1 with: files: "sonar-project.properties, coverage/lcov.info" - name: Upload coverage file if: steps.sonar.outputs.files_exists == 'true' uses: actions/upload-artifact@v2 with: name: coverage-file path: coverage/lcov.info
hope it helps someone, we made it defensive since its a pipeline for multiple apps. Some are mature and some not :)
Actually not sure it solves anything because we're talking about download here. How would you check that the file in the artifact exists if it isn't downloaded yet ?
Did someone find a workaround ?
@benjamincharity maybe use
continue-on-error: true
-- see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
This would be the best solution imho.
I'll probably make an action myself returning true or false as an output if there are artifacts. I can't think of another way to do it for now
Stumbled across this need and found no way of checking if some artifact exists. So created a new action: https://github.com/marketplace/actions/check-artifact-existence
You can add a new step that is going to expose and output denoting if an artifact exists or not by the given artifact name:
uses: actions/xSAVIKx/artifact-exists-action@v0
id: check_coverage_artifact
with:
name: 'coverage-artifact'
Then you can use steps.check_coverage_artifact.outputs.exists
(true/false) in the conditions.
Just don't use this action and call gh
directly:
- name: Download artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo $(gh run download -n my-artifact-name)
In my case, I was able to do the following.
- id: check-artifact-exist
run: |
url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${run-id}/artifacts"
echo "artifact-name=$(curl -fsSL "$url" | jq -r '.artifacts[0].name')" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
if:
${{ steps.check-artifact-exist.outputs.artifact-name ==
'xxx' }}
We've been having intermittent issues uploading our coverage reports from our GitHub action. These issues are displayed as 403s which cause really, really long jobs. In order for this to not block steps that come after test coverage, we are moving the coverage upload to a final step after all other.
The issue we have is that coverage is not always generated. In those cases, download artifact fails that final step and the entire workflow is marked as failed.
Our flow:
a) check if any packages have changes since last run b) if changed, run tests c) upload coverage (if no test are run, no coverage exists but the uploader does gracefully exit) d) all other steps e) attempt to upload coverage (FAIL if no coverage is found)
Is there a way to gracefully fail if the artifact hasn't been uploaded since in some cases this is not a failure from our standpoint?
Ninja edit: I did see the option
continue-on-error
, but the overall workflow is still shown with the red 'x' so at a glance it appears our entire release is failing to consumers.