Skip to content

Commit a9fe038

Browse files
Ryan (hackercat)cplee
andauthored
Update images, fix extrapath (nektos#723)
* fix: typo * fix: remove debug for git references it generates a massive amount of logs * feat: read values from env allows to test act on GHA when it's not a main repo * fix: merge extrapath with PATH * fix(tests): add additional shells for testing * fix(image): update images pin node to major version only, current node version: 12.22.1 replace most images with `node:12-buster-slim` to prevent errors on macOS runner due to DockerHub pull limit replace ocaml image Co-authored-by: Casey Lee <cplee@nektos.com>
1 parent a9295c9 commit a9fe038

File tree

23 files changed

+121
-68
lines changed

23 files changed

+121
-68
lines changed

IMAGES.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
**Note 2: `node` `-slim` images don't have `python` installed, if you want to use actions or software that is depending on `python`, you need to specify image manually**
1010

11-
| Image | Size |
12-
| ----------------------------------------- | ------------------------------------------------------------- |
13-
| [`node:12.20.1-buster`][hub/_/node] | ![`buster-size`][hub/_/node/12.20.1-buster/size] |
14-
| [`node:12.20.1-buster-slim`][hub/_/node] | ![`micro-buster-size`][hub/_/node/12.20.1-buster-slim/size] |
15-
| [`node:12.20.1-stretch`][hub/_/node] | ![`stretch-size`][hub/_/node/12.20.1-stretch/size] |
16-
| [`node:12.20.1-stretch-slim`][hub/_/node] | ![`micro-stretch-size`][hub/_/node/12.20.1-stretch-slim/size] |
11+
| Image | Size |
12+
| ------------------------------------ | -------------------------------------------------------- |
13+
| [`node:12-buster`][hub/_/node] | ![`buster-size`][hub/_/node/12-buster/size] |
14+
| [`node:12-buster-slim`][hub/_/node] | ![`micro-buster-size`][hub/_/node/12-buster-slim/size] |
15+
| [`node:12-stretch`][hub/_/node] | ![`stretch-size`][hub/_/node/12-stretch/size] |
16+
| [`node:12-stretch-slim`][hub/_/node] | ![`micro-stretch-size`][hub/_/node/12-stretch-slim/size] |
1717

1818
**Note: `catthehacker/ubuntu` images are based on Ubuntu root filesystem**
1919

@@ -48,10 +48,10 @@ Feel free to make a pull request with your image added here
4848

4949
[hub/_/buildpack-deps]: https://hub.docker.com/_/buildpack-deps
5050
[hub/_/node]: https://hub.docker.com/r/_/node
51-
[hub/_/node/12.20.1-buster/size]: https://img.shields.io/docker/image-size/_/node/12.20.1-buster
52-
[hub/_/node/12.20.1-buster-slim/size]: https://img.shields.io/docker/image-size/_/node/12.20.1-buster-slim
53-
[hub/_/node/12.20.1-stretch/size]: https://img.shields.io/docker/image-size/_/node/12.20.1-stretch
54-
[hub/_/node/12.20.1-stretch-slim/size]: https://img.shields.io/docker/image-size/_/node/12.20.1-stretch-slim
51+
[hub/_/node/12-buster/size]: https://img.shields.io/docker/image-size/_/node/12-buster
52+
[hub/_/node/12-buster-slim/size]: https://img.shields.io/docker/image-size/_/node/12-buster-slim
53+
[hub/_/node/12-stretch/size]: https://img.shields.io/docker/image-size/_/node/12-stretch
54+
[hub/_/node/12-stretch-slim/size]: https://img.shields.io/docker/image-size/_/node/12-stretch-slim
5555
[hub/catthehacker/ubuntu]: https://hub.docker.com/r/catthehacker/ubuntu
5656
[hub/catthehacker/ubuntu/act-latest/size]: https://img.shields.io/docker/image-size/catthehacker/ubuntu/act-latest
5757
[hub/catthehacker/ubuntu/act-20.04/size]: https://img.shields.io/docker/image-size/catthehacker/ubuntu/act-20.04

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ It will save that information to `~/.actrc`, please refer to [Configuration](#co
139139
--detect-event Use first event type from workflow as event that triggered the workflow
140140
-C, --directory string working directory (default ".")
141141
-n, --dryrun dryrun mode
142-
--env stringArray env to make available to actions with optional value (e.g. --e myenv=foo or -s myenv)
142+
--env stringArray env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)
143143
--env-file string environment file to read and use as env in the containers (default ".env")
144144
-e, --eventpath string path to event JSON file
145145
--github-instance string GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server. (default "github.com")
@@ -192,12 +192,12 @@ If the `path:` value doesn't match the name of the repository, a `MODULE_NOT_FOU
192192

193193
GitHub Actions offers managed [virtual environments](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners) for running workflows. In order for `act` to run your workflows locally, it must run a container for the runner defined in your workflow file. Here are the images that `act` uses for each runner type and size:
194194

195-
| GitHub Runner | Micro Docker Image | Medium Docker Image | Large Docker Image |
196-
| --------------- | ------------------------------------ | ------------------------------------------ | --------------------------------------------------- |
197-
| `ubuntu-latest` | [`node:12.20.1-buster-slim`][micro] | [`catthehacker/ubuntu:act-latest`][medium] | [`catthehacker/ubuntu:full-20.04`][large-cat] |
198-
| `ubuntu-20.04` | [`node:12.20.1-buster-slim`][micro] | [`catthehacker/ubuntu:act-20.04`][medium] | [`catthehacker/ubuntu:full-20.04`][large-cat] |
199-
| `ubuntu-18.04` | [`node:12.20.1-buster-slim`][micro] | [`catthehacker/ubuntu:act-18.04`][medium] | [`nektos/act-environments-ubuntu:18.04`][large-act] |
200-
| `ubuntu-16.04` | [`node:12.20.1-stretch-slim`][micro] | [`catthehacker/ubuntu:act-16.04`][medium] | `unavailable` |
195+
| GitHub Runner | Micro Docker Image | Medium Docker Image | Large Docker Image |
196+
| --------------- | ------------------------------- | ------------------------------------------ | --------------------------------------------------- |
197+
| `ubuntu-latest` | [`node:12-buster-slim`][micro] | [`catthehacker/ubuntu:act-latest`][medium] | [`catthehacker/ubuntu:full-20.04`][large-cat] |
198+
| `ubuntu-20.04` | [`node:12-buster-slim`][micro] | [`catthehacker/ubuntu:act-20.04`][medium] | [`catthehacker/ubuntu:full-20.04`][large-cat] |
199+
| `ubuntu-18.04` | [`node:12-buster-slim`][micro] | [`catthehacker/ubuntu:act-18.04`][medium] | [`nektos/act-environments-ubuntu:18.04`][large-act] |
200+
| `ubuntu-16.04` | [`node:12-stretch-slim`][micro] | [`catthehacker/ubuntu:act-16.04`][medium] | `unavailable` |
201201

202202
[micro]: https://hub.docker.com/_/buildpack-deps
203203
[medium]: https://github.com/catthehacker/docker_images
@@ -249,7 +249,7 @@ If you use multiple platforms in your workflow, you have to specify them to chan
249249
For example, if your workflow uses `ubuntu-18.04`, `ubuntu-16.04` and `ubuntu-latest`, specify all platforms like below
250250

251251
```sh
252-
act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:12.20.1-buster-slim
252+
act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:12-buster-slim
253253
```
254254

255255
# Secrets

cmd/platforms.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66

77
func (i *Input) newPlatforms() map[string]string {
88
platforms := map[string]string{
9-
"ubuntu-latest": "node:12.20.1-buster-slim",
10-
"ubuntu-20.04": "node:12.20.1-buster-slim",
11-
"ubuntu-18.04": "node:12.20.1-buster-slim",
12-
"ubuntu-16.04": "node:12.20.1-stretch-slim",
9+
"ubuntu-latest": "node:12-buster-slim",
10+
"ubuntu-20.04": "node:12-buster-slim",
11+
"ubuntu-18.04": "node:12-buster-slim",
12+
"ubuntu-16.04": "node:12-stretch-slim",
1313
"windows-latest": "",
1414
"windows-2019": "",
1515
"macos-latest": "",

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Execute(ctx context.Context, version string) {
3939
rootCmd.Flags().BoolP("graph", "g", false, "draw workflows")
4040
rootCmd.Flags().StringP("job", "j", "", "run job")
4141
rootCmd.Flags().StringArrayVarP(&input.secrets, "secret", "s", []string{}, "secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)")
42-
rootCmd.Flags().StringArrayVarP(&input.envs, "env", "", []string{}, "env to make available to actions with optional value (e.g. --e myenv=foo or -s myenv)")
42+
rootCmd.Flags().StringArrayVarP(&input.envs, "env", "", []string{}, "env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)")
4343
rootCmd.Flags().StringArrayVarP(&input.platforms, "platform", "P", []string{}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)")
4444
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "reuse action containers to maintain state")
4545
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
@@ -303,7 +303,7 @@ func defaultImageSurvey(actrc string) error {
303303
case "Medium":
304304
option = "-P ubuntu-latest=catthehacker/ubuntu:act-latest\n-P ubuntu-20.04=catthehacker/ubuntu:act-20.04\n-P ubuntu-18.04=catthehacker/ubuntu:act-18.04\nubuntu-16.04=catthehacker/ubuntu:act-16.04"
305305
case "Micro":
306-
option = "-P ubuntu-latest=node:12.20.1-buster-slim\n-P ubuntu-20.04=node:12.20.1-buster-slim\n-P ubuntu-18.04=node:12.20.1-buster-slim\n-P ubuntu-16.04=node:12.20.1-stretch-slim"
306+
option = "-P ubuntu-latest=node:12-buster-slim\n-P ubuntu-20.04=node:12-buster-slim\n-P ubuntu-18.04=node:12-buster-slim\n-P ubuntu-16.04=node:12-stretch-slim"
307307
}
308308

309309
f, err := os.Create(actrc)

pkg/common/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func FindGitRef(file string) (string, error) {
8686
if r == nil || err != nil {
8787
break
8888
}
89-
log.Debugf("Reference: name=%s sha=%s", r.Name().String(), r.Hash().String())
89+
// log.Debugf("Reference: name=%s sha=%s", r.Name().String(), r.Hash().String())
9090
if r.Hash().String() == ref {
9191
if r.Name().IsTag() {
9292
refTag = r.Name().String()

pkg/container/docker_images_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ func TestImageExistsLocally(t *testing.T) {
4040

4141
// Chose alpine latest because it's so small
4242
// maybe we should build an image instead so that tests aren't reliable on dockerhub
43-
readerDefault, err := cli.ImagePull(ctx, "alpine:latest", types.ImagePullOptions{
43+
readerDefault, err := cli.ImagePull(ctx, "node:12-buster-slim", types.ImagePullOptions{
4444
Platform: "linux/amd64",
4545
})
4646
assert.Nil(t, err)
4747
defer readerDefault.Close()
4848
_, err = ioutil.ReadAll(readerDefault)
4949
assert.Nil(t, err)
5050

51-
imageDefaultArchExists, err := ImageExistsLocally(ctx, "alpine:latest", "linux/amd64")
51+
imageDefaultArchExists, err := ImageExistsLocally(ctx, "node:12-buster-slim", "linux/amd64")
5252
assert.Nil(t, err)
5353
assert.Equal(t, true, imageDefaultArchExists)
5454

5555
// Validate if another architecture platform can be pulled
56-
readerArm64, err := cli.ImagePull(ctx, "alpine:latest", types.ImagePullOptions{
56+
readerArm64, err := cli.ImagePull(ctx, "node:12-buster-slim", types.ImagePullOptions{
5757
Platform: "linux/arm64",
5858
})
5959
assert.Nil(t, err)
6060
defer readerArm64.Close()
6161
_, err = ioutil.ReadAll(readerArm64)
6262
assert.Nil(t, err)
6363

64-
imageArm64Exists, err := ImageExistsLocally(ctx, "alpine:latest", "linux/arm64")
64+
imageArm64Exists, err := ImageExistsLocally(ctx, "node:12-buster-slim", "linux/arm64")
6565
assert.Nil(t, err)
6666
assert.Equal(t, true, imageArm64Exists)
6767
}

pkg/runner/run_context_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,28 @@ func TestGetGitHubContext(t *testing.T) {
308308

309309
log.Debugf("%v", ghc)
310310

311+
actor := "nektos/act"
312+
if a := os.Getenv("ACT_ACTOR"); a != "" {
313+
actor = a
314+
}
315+
316+
repo := "nektos/act"
317+
if r := os.Getenv("ACT_REPOSITORY"); r != "" {
318+
repo = r
319+
}
320+
321+
owner := "nektos"
322+
if o := os.Getenv("ACT_OWNER"); o != "" {
323+
owner = o
324+
}
325+
311326
assert.Equal(t, ghc.RunID, "1")
312327
assert.Equal(t, ghc.Workspace, rc.Config.containerPath(cwd))
313328
assert.Equal(t, ghc.RunNumber, "1")
314329
assert.Equal(t, ghc.RetentionDays, "0")
315-
assert.Equal(t, ghc.Actor, "nektos/act")
316-
assert.Equal(t, ghc.Repository, "nektos/act")
317-
assert.Equal(t, ghc.RepositoryOwner, "nektos")
330+
assert.Equal(t, ghc.Actor, actor)
331+
assert.Equal(t, ghc.Repository, repo)
332+
assert.Equal(t, ghc.RepositoryOwner, owner)
318333
assert.Equal(t, ghc.RunnerPerflog, "/dev/null")
319334
assert.Equal(t, ghc.EventPath, ActPath+"/workflow/event.json")
320335
assert.Equal(t, ghc.Token, rc.Config.Secrets["GITHUB_TOKEN"])

pkg/runner/runner_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ import (
1616
"github.com/nektos/act/pkg/model"
1717
)
1818

19+
var baseImage string = "node:12-buster-slim"
20+
21+
func init() {
22+
if p := os.Getenv("ACT_TEST_IMAGE"); p != "" {
23+
baseImage = p
24+
}
25+
}
26+
1927
func TestGraphEvent(t *testing.T) {
2028
planner, err := model.NewWorkflowPlanner("testdata/basic", true)
2129
assert.Nil(t, err)
@@ -81,16 +89,18 @@ func TestRunEvent(t *testing.T) {
8189
}
8290

8391
platforms := map[string]string{
84-
"ubuntu-latest": "node:12.20.1-buster-slim",
92+
"ubuntu-latest": baseImage,
8593
}
8694

8795
tables := []TestJobFileInfo{
8896
{"testdata", "basic", "push", "", platforms, ""},
8997
{"testdata", "fail", "push", "exit with `FAILURE`: 1", platforms, ""},
9098
{"testdata", "runs-on", "push", "", platforms, ""},
9199
{"testdata", "checkout", "push", "", platforms, ""},
92-
// Pwsh is not available in default worker (yet) so we use a separate image for testing
93-
{"testdata", "powershell", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""},
100+
{"testdata", "shells/pwsh", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""}, // custom image with pwsh
101+
{"testdata", "shells/bash", "push", "", platforms, ""},
102+
{"testdata", "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:12-buster"}, ""}, // slim doesn't have python
103+
{"testdata", "shells/sh", "push", "", platforms, ""},
94104
{"testdata", "job-container", "push", "", platforms, ""},
95105
{"testdata", "job-container-non-root", "push", "", platforms, ""},
96106
{"testdata", "uses-docker-url", "push", "", platforms, ""},
@@ -131,7 +141,7 @@ func TestRunEventSecrets(t *testing.T) {
131141
ctx := context.Background()
132142

133143
platforms := map[string]string{
134-
"ubuntu-latest": "node:12.20.1-buster-slim",
144+
"ubuntu-latest": baseImage,
135145
}
136146

137147
workflowPath := "secrets"
@@ -172,7 +182,7 @@ func TestRunEventPullRequest(t *testing.T) {
172182
ctx := context.Background()
173183

174184
platforms := map[string]string{
175-
"ubuntu-latest": "node:12.20.1-buster-slim",
185+
"ubuntu-latest": baseImage,
176186
}
177187

178188
workflowPath := "pull-request"

pkg/runner/step_context.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ func (sc *StepContext) mergeEnv() map[string]string {
125125
env = mergeMaps(rc.GetEnv(), step.GetEnv())
126126
}
127127

128-
env["PATH"] = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`
129-
if (rc.ExtraPath != nil) && (len(rc.ExtraPath) > 0) {
128+
if env["PATH"] == "" {
129+
env["PATH"] = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`
130+
}
131+
if rc.ExtraPath != nil && len(rc.ExtraPath) > 0 {
132+
p := env["PATH"]
130133
env["PATH"] = strings.Join(rc.ExtraPath, `:`)
134+
env["PATH"] += `:` + p
131135
}
132136

133137
sc.Env = rc.withGithubEnv(env)

pkg/runner/step_context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestStepContextExecutor(t *testing.T) {
1111
platforms := map[string]string{
12-
"ubuntu-latest": "node:12.20.1-buster-slim",
12+
"ubuntu-latest": baseImage,
1313
}
1414
tables := []TestJobFileInfo{
1515
{"testdata", "uses-and-run-in-one-step", "push", "Invalid run/uses syntax for job:test step:Test", platforms, ""},

0 commit comments

Comments
 (0)