Closed steakscience closed 3 years ago
Hey @steakscience!
Getting parallel builds to work within GitHub Actions can actually be more difficult than it seems. For example, the parallel nonce must be unique for that specific set of parallel builds. The GITHUB_ACTION
environment variable is actually set to be the Action's scoped name or context name, which would be the same every time that step in the action runs even for different commits.
A more accurate nonce, would be to create a unique string at the beginning of the entire workflow and persist that string until the end of the workflow. For example, {branch}-{sha}-{timestamp}
would be pretty unique to create once at the beginning and use in subsequent steps for builds that need to be grouped together. In the future, we'd like to automatically create a unique nonce within the action, but for now you'll have to do it manually and ensure it is unique for each group of parallel builds.
As for the error, it would help to know what error actually says, and how you are running your parallel jobs. 🙂
Also, I just noticed that you're using the with.command
option, when you probably want with.custom-command
. The command
option gets wrapped as percy exec -- <command>
, while custom-command
will replace the exec command entirely.
@wwilsman Using custom-command
makes perfect sense. Thank you.
Do I need to use @percy/agent
at all or would /exec
work for finalize? https://github.com/percy/percy-agent#percy-finalize
@percy/agent
comes with both the exec
and finalize
commands. Since custom-command
gets executed directly rather than wrapped in percy exec --
, you'll probably want something like:
custom-command: "npx percy finalize --all"
If you're referring to needing @percy/agent
as a direct dependency, it should be included as a JS dependency of your SDK or installed directly if you're using another language besides JS. In either case, npx
will first check your local dependencies for the percy
command, and failing to find it should automatically download @percy/agent
before executing the command.
Does any of that answer your question? 😄
@wwilsman
Ok that answers my question
One last thing is: when using custom-command
, do the env variables still get passed in? Such as PERCY_PARALLEL_NONCE
- name: Visual Tests
uses: percy/agent@master
with:
custom-command: "npx percy finalize --all"
working-directory: "./e2e"
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_PARALLEL_NONCE: ${UNIQUE_ID}
Sorry for the delay, yes it should pass through all environment variables to the command.
Here is the entire action's code: https://github.com/percy/exec-action/blob/master/src/index.js
We don't specifically set the exec
option, env
, which means it should be inherited from the current environment.
@wwilsman Thank you!
Hi, I'm currently trying to run
percy finalize --all
to complete my parallel tests:Relevant section:
Currently, the command will result in an error so there must be a syntax issue with it. I tag all the parallel tests with the nonce
${GITHUB_ACTION}
which is a unique ID for each GitHub Action.What is the right way to do this?