<!-- .slide: data-background="https://dm0qx8t0i9gc9.cloudfront.net/previews/image/rDtN98Qoishumwih/graphicstock-man-touching-workflow-illustrating-management-approval-flowchart-with-his-finger-on-dark-background_r_qeeUhvloe_PMNW.jpg?" --> # `nektos/act` --- ![demo](https://github.com/noirbizarre/slides/raw/master/act/demo.gif) --- ## Use cases --- ### Cost management ---- #### Time cost Reduce your feedback loop ---- #### Money cost Reduce the GHA bill --- ### Craft workflows from scratch ---- ```bash # Run the default (`push`) event: act # Run a specific event act pull_request # Run a specific job act -j test # Run a job in a specific workflow (for duplicate job names) act -j lint -W .github/workflows/checks.yml ``` --- ### Easily runs edge-cases ---- Craft a tailored JSON event payload for your case ```json { "pull_request": { "head": { "ref": "sample-head-ref" }, "base": { "ref": "sample-base-ref" } } } ``` ---- Then run it ```shell act pull_request -e payload.json ``` ---- Works with inputs ```json { "inputs": { "NAME": "Manual Workflow", "SOME_VALUE": "ABC" } } ``` --- ### Introspection ```shell $ act -l Stage Job ID Job name Workflow name Workflow file Events 0 test-older-versions test-older-versions CI publish.yml push,pull_request 1 test-check-and-publish test-check-and-publish CI publish.yml push,pull_request ``` --- ### Easily test your custom actions --- ### Build tailored GHA docker envs --- ## Limitations ---- No Windows and MacOS runner support ---- Not safe (Don't expect to build your own GHA with it) ---- Some services not supported [#173](https://github.com/nektos/act/issues/173) --- ## Tips ---- Skip steps only in `act` ```yaml - name: Some step if: ${{ !env.ACT }} run: | ... ``` ---- Env & secrets ```bash act -e ENV=value -e ANOTHER_ONE -s SECRET=secret -s SKEY ``` ---- Custom docker image ```Dockerfile FROM ghcr.io/catthehacker/ubuntu:act-latest RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ && unzip awscliv2.zip \ && sudo ./aws/install \ && rm -fr aws awscliv2.zip ``` ```bash # act -P <platform>=<docker-image> act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 ``` See [the dedicated page](https://github.com/nektos/act/blob/master/IMAGES.md) ---- Package test data in `.github/workflows` ---- JSON payloads custom Dockerfile sample `act` commands as comments --- <!-- .slide: data-background="https://www.trustradius.com//wp-content/uploads/istock-1205896326-scaled-1536x1024.jpg" --> # Questions ?
{"metaMigratedAt":"2023-06-17T15:45:19.571Z","metaMigratedFrom":"YAML","title":"Testing GHA workflows with `act`","breaks":true,"image":"https://www.python.org/static/community_logos/python-logo-master-v3-TM.png","slideOptions":"{\"theme\":\"moon\"}","contributors":"[{\"id\":\"ccb66f62-527e-4f67-aebf-99b8ba78ddd3\",\"add\":3605,\"del\":630}]"}
    213 views