Act
https://github.com/nektos/act
About
Act
allows us to test our Github Actions workflows locally. It's a great tool but it doesn't support all of the configuration options Github Actions offers quite yet (including actions/cache
, which is super annoying).
Configuration
In order to get act
working you'll need to create a .secrets
file at the root of the monorepo, formatted like a .env file, that contains a single key: STAGING_FIREBASE_CREDENTIALS
with the contents of ci-account@illust-marketplace-staging.iam.gserviceaccount.com
's service account key json file on a single line and contained in single quotes. There is a .secrets.example file at the root of the monorepo that you can use to create your own secrets file.
Running
To run a basic test workflow run: act <workflow event name> --secret-file .secrets
from the root of the monorepo. If your workflow runs on the "pull_request" event, you would run act pull_request --secret-file .secrets
. To reuse the same images you used in the previous run, you can pass the --reuse
option. This saves a lot of time if you're working on something that requires a lot of runs to test.
The most optimized way to run this script is:
ACTIONS_RUNTIME_TOKEN=foo act pull_request --secret-file .secrets --artifact-server-path=cache -P ubuntu-20.04=aas395/ubuntu:20.04-yarn-lerna
ACTIONS_RUNTIME_TOKEN
can be any value. --artifact-server-path=cache
can be passed exactly as written. These two options work together to allow you to use act's artifact server, which functions just like Github Actions' artifact server. -P ubuntu-20.04=aas395/ubuntu:20.04-yarn-lerna
tells act to use a custom image to run act that has yarn and lerna already installed (to mirror Github Actions as closely as possible and prevent some environment-specific configuration in workflow files).
Last updated