Exporting iOS results artifacts after Fastlane tests fail in GitHub Actions

I have an iOS repo with Fastlane running unit and UI tests via GitHub Actions on my pull requests. I would like to preserve the artifacts generated, specifically the xcresults logs, and upload it to GitHub. I’ve added this to my GHA .yml file:

    - name: Archive test artifacts
      uses: actions/upload-artifact@v2
        name: test-artifacts
        path: |

When tests fail, Error: Process completed with exit code 1 is returned and the above step is never done. I’d like the logs to always be uploaded regardless of tests passing or not- especially if they don’t. How can I force GHA to continue running if the previous test step failed?

For reference, that preceding GHA step is simply:

- name: Run Tests
      run: |
        bundle exec fastlane test

I understand it’s possible to add the fail_ci_if_error flag set to true on GitHub Actions (edit: it doesn’t seem to be possible to pair it with a run command), or to set fail_build in Fastlane’s scan to false, but while I would like the tests to continue to the next step and archive artifacts, I also want to the test to fail shortly after uploading the artifacts, instead of creating a false success.

Hi, could you try adding a if: failure() like this example?

You might need to add two steps – one that has the failure() so it uploads artifacts on failed steps, and one without so it uploads on success.

If you have any configuration questions you’re also welcome to open an issue here: Issues · actions/upload-artifact · GitHub

1 Like