-
-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an option to fail the action itself #265
Comments
That is an interesting an particular finding. Let's summarize the situation: The action creates a check run on that commit on master, which has failure state: This is associated with the commit: So everything looks good for GitHub to consider master branch not passing. However, those badges are per workflow, and the workflow did pass: The check run is not part of the workflow, though it is in some views shown there. This is related to #12. Given the publish action runs in a separate workflow on a |
I would expect the This would achieve a job and workflow failure, turning the batch to failure state. |
Correct, for sure it would be better if everything always passes but we have cases where we need to accept failing tests for a while (e.g. there are os changes we need to adapt) so a red (or yellow) badge would be good.
We disabled that maven fails but instead just runs all the tests and later on the verify check post the result of the unit test results, that way one could see for example if a test only fails on a certain platform configuration or java even thozgh the compile itself succeeds.
The split is manly done due to https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches as we use forks for all code changes. |
I don't get it. You could achieve all this by:
eclipse-platform/eclipse.platform.swt@d470bcf...EnricoMi:416507e528484d35df3ab1354d870f11fc6ac7b8
-DforkCount=1
-Dcompare-version-with-baselines.skip=false
-Dmaven.compiler.failOnWarning=true
- -Dmaven.test.failure.ignore=true
+ --fail-at-end
clean verify
working-directory: eclipse.platform.swt
- name: Upload Test Results for ${{ matrix.config.name }} / Java-${{ matrix.java }}
uses: actions/upload-artifact@v3
+ if: always()
with:
name: test-results-${{ matrix.config.native }}-java${{ matrix.java }}
if-no-files-found: error
unit-test-results:
name: Unit Test Results
runs-on: ubuntu-latest
- if: github.event.workflow_run.conclusion == 'success'
+ if: github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Download and Extract Artifacts |
I want a green badge if compiling succeeds on all platforms and a another if all test passed (or a red/yellow/... if any tests currently fail of course) otherwise one could still get a false impression (without looking at the build output) that there are only test failures even if some modules fail with compile error (as -fae do not work for only tests). |
Right, then I would suggest two workflows, one building without bothering to run tests for your green build badge, and one thoroughly testing for your test-failure badge. You could have the former workflow only run on master. |
But I already have two workflows right now ... ;-) And if I want to support PRs I then need three of them... that's why I thought it might be good to have an option that the publish can mark the current workflow as a failure! e.g. if I follow the "show this check" e.g. https://github.com/eclipse-platform/eclipse.platform.swt/runs/6372153691 then the workflow is marked with a red-x so I assume it already tells github that are something wrong, but it is not bubbled up to the workflow run... so it works already for PRs as expected but just seem to be marked as "good" when there is no PR... |
Even if the publish job would fail, this would not make the master badge fail as it runs as |
But why do I see then runs of the workflow with master branch? That was just the 'trigger' for me to ask for that feature: also these runs seem to do something or do I get the log output wrong here?:
|
The That log tells you that the results were published as check run https://github.com/eclipse-platform/eclipse.platform.swt/runs/6373026177 associated with commit d470bcf8 on master. |
I just found that there already is a way to can make the publish job fail. Simply evaluate the JSON output like this: - name: Publish Unit Test Results
+ id: test-results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
commit: ${{ github.event.workflow_run.head_sha }}
files: "artifacts/**/*.xml"
+ - name: Fail on test failure
+ if: fromJSON( steps.test-results.outputs.json ).conclusion != 'success'
+ run: |
+ echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"
+ false Curious if this works with |
With two build workflows this definitively works fine: eclipse-platform/eclipse.platform.swt@master...EnricoMi:master As I said, the problem with the publish workflow badge is that it cannot distinguish between the branch that triggered it. Results from PRs will be accounted for |
Okay I was not aware of that, than probably this request do not make much sense and could be closed, thanks for the detailed insights! |
Alternatively, you could create a badge from the test results, upload to gist and use that to flag your master tests read when they fail: https://github.com/EnricoMi/publish-unit-test-result-action/tree/v1.36#create-a-badge-from-test-results |
That looks really cool! |
@EnricoMi I have tried your suggestion but can't get it to work, it always complains about non existing file: https://github.com/laeubi/eclipse.platform.swt/runs/6790512790 I have tried to create the file with some dummy content: so it seems I'm missing something here... Edit: Everything works, I just messed up gist ids and filenames... |
We have an action that publish the junit tests in a separate step:
https://github.com/eclipse-platform/eclipse.platform.swt/actions/workflows/junit.yml
but for the master build there are obviously nothing to publish as there is no PR so currently one gets the following output:
Example: https://github.com/eclipse-platform/eclipse.platform.swt/runs/6360504104
To create a status badge that shows if tests on the master branch are all successful it would be useful to have an option that the action itself should fail if
The text was updated successfully, but these errors were encountered: