[FOLIO-3433] provide Dockerfile-ish access to GitHub Actions CI images Created: 28/Feb/22  Updated: 30/Nov/23

Status: Open
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: New Feature Priority: P3
Reporter: Zak Burke Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Attachments: File test-local.yml    
Issue links:
Relates
relates to FOLIO-3432 Update NodeJS to Active LTS (v16) in ... Closed
relates to FOLIO-3434 Update NodeJS to Active LTS (v16) in ... Closed
Sprint: DevOps Sprint 135, DevOps Sprint 136, DevOps Sprint 137, Kitfox: sprint 165
Development Team: FOLIO DevOps

 Description   

Summary: Provide a mechanism by which developers can download the GitHub actions image so devs can exactly match the GA env when running tests locally.

Details: It would be awesome if we had a way to replicate the CI environment locally, as we did with Docker when we built on Jenkins. I believe the virtual-environments repo contains all this info, and I’m hopeful somebody with more knowhow than I will look at that and say, β€œOh sure, it’s easy if you know how.”



 Comments   
Comment by Zak Burke [ 24/May/22 ]

Michal Kuklis pointed me to nektos/act, "Run your GitHub Actions locally πŸš€", which may be something of a magic bullet here. From the README:

When you run act it reads in your GitHub Actions from .github/workflows/ and determines the set of actions that need to be run. It uses the Docker API to either pull or build the necessary images, as defined in your workflow files and finally determines the execution path based on the dependencies that were defined. Once it has the execution path, it then uses the Docker API to run containers for each action based on the images prepared earlier. The environment variables and filesystem are all configured to match what GitHub provides.

The attached test-local.yml job (omits all the "Publish..." steps, installs yarn) was ultimately unsuccessful due to some missing/unconfigured tools, but it's most of the way there and maybe can be fixed by running against a larger or different Docker image as suggested by others who found yarn absent.

$ act -j test-local -s GITHUB_TOKEN
Provide value for 'GITHUB_TOKEN': 
...
[buildNPM Snapshot/test-local] ⭐  Run Run yarn lint
[buildNPM Snapshot/test-local]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/8] user= workdir=
yarn run v1.22.18
$ eslint . && stylelint "src/**/*.css"
| 
| Oops! Something went wrong! :(
| 
| ESLint: 7.32.0
| 
| Error: .eslintrc:
| 	Environment key "jest/globals" is unknown
| 
|     at /Users/zburke/projects/folio-org/stripes-core/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:175:23
|     at Array.forEach (<anonymous>)
|     at ConfigValidator.validateEnvironment (/Users/zburke/projects/folio-org/stripes-core/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:169:34)
|     at ConfigValidator.validateConfigArray (/Users/zburke/projects/folio-org/stripes-core/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:319:18)
|     at CascadingConfigArrayFactory._finalizeConfigArray (/Users/zburke/projects/folio-org/stripes-core/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:493:23)
|     at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/zburke/projects/folio-org/stripes-core/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:299:21)
|     at FileEnumerator._iterateFilesRecursive (/Users/zburke/projects/folio-org/stripes-core/node_modules/eslint/lib/cli-engine/file-enumerator.js:445:49)
|     at _iterateFilesRecursive.next (<anonymous>)
|     at FileEnumerator.iterateFiles (/Users/zburke/projects/folio-org/stripes-core/node_modules/eslint/lib/cli-engine/file-enumerator.js:296:49)
|     at iterateFiles.next (<anonymous>)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[buildNPM Snapshot/test-local]   ❌  Failure - Run yarn lint
[buildNPM Snapshot/test-local] Failed but continue next step
[buildNPM Snapshot/test-local] ⭐  Run Run yarn formatjs-compile
[buildNPM Snapshot/test-local]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/9] user= workdir=
yarn run v1.22.18
$ formatjs compile-folder --ast --format simple ./translations/stripes-core ./translations/stripes-core/compiled
Done in 1.24s.
[buildNPM Snapshot/test-local]   βœ…  Success - Run yarn formatjs-compile
[buildNPM Snapshot/test-local] ⭐  Run Run yarn test
[buildNPM Snapshot/test-local]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/10] user= workdir=
| /var/run/act/workflow/10: line 2: xvfb-run: command not found
[buildNPM Snapshot/test-local]   ❌  Failure - Run yarn test
[buildNPM Snapshot/test-local] exit with `FAILURE`: 127
Error: Job 'test-local' failed
Generated at Thu Feb 08 23:28:05 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.