Skip to content

Commit

Permalink
feat: add node16 support (#922)
Browse files Browse the repository at this point in the history
* feat: add node16 support

Signed-off-by: hackercat <[email protected]>

* feat: bump images to node16

Signed-off-by: hackercat <[email protected]>

* lint(editorconfig): ignore *.md due to mixed style

Signed-off-by: hackercat <[email protected]>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Ryan and mergify[bot] authored Dec 22, 2021
1 parent 9868e13 commit 5580812
Show file tree
Hide file tree
Showing 27 changed files with 9,200 additions and 32 deletions.
4 changes: 4 additions & 0 deletions IMAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
| ----------------------------------- | ------------------------------------------------------ |
| [`node:12-buster`][hub/_/node] | ![`buster-size`][hub/_/node/12-buster/size] |
| [`node:12-buster-slim`][hub/_/node] | ![`micro-buster-size`][hub/_/node/12-buster-slim/size] |
| [`node:16-buster`][hub/_/node] | ![`buster-size`][hub/_/node/16-buster/size] |
| [`node:16-buster-slim`][hub/_/node] | ![`micro-buster-size`][hub/_/node/16-buster-slim/size] |

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

Expand Down Expand Up @@ -44,6 +46,8 @@ Feel free to make a pull request with your image added here
[hub/_/node]: https://hub.docker.com/r/_/node
[hub/_/node/12-buster/size]: https://img.shields.io/docker/image-size/_/node/12-buster
[hub/_/node/12-buster-slim/size]: https://img.shields.io/docker/image-size/_/node/12-buster-slim
[hub/_/node/16-buster/size]: https://img.shields.io/docker/image-size/_/node/16-buster
[hub/_/node/16-buster-slim/size]: https://img.shields.io/docker/image-size/_/node/16-buster-slim
[ghcr/catthehacker/ubuntu]: https://github.com/catthehacker/docker_images/pkgs/container/ubuntu
[hub/nektos/act-environments-ubuntu]: https://hub.docker.com/r/nektos/act-environments-ubuntu
[hub/nektos/act-environments-ubuntu/18.04/size]: https://img.shields.io/docker/image-size/nektos/act-environments-ubuntu/18.04
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ GitHub Actions offers managed [virtual environments](https://help.github.com/en/

| GitHub Runner | Micro Docker Image | Medium Docker Image | Large Docker Image |
| --------------- | ------------------------------ | --------------------------------------------------------- | ---------------------------------------------------------- |
| `ubuntu-latest` | [`node:12-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-latest`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-latest`][docker_images] |
| `ubuntu-20.04` | [`node:12-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-20.04`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-20.04`][docker_images] |
| `ubuntu-18.04` | [`node:12-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-18.04`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-18.04`][docker_images] |
| `ubuntu-latest` | [`node:16-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-latest`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-latest`][docker_images] |
| `ubuntu-20.04` | [`node:16-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-20.04`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-20.04`][docker_images] |
| `ubuntu-18.04` | [`node:16-buster-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-18.04`][docker_images] | [`ghcr.io/catthehacker/ubuntu:full-18.04`][docker_images] |

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

```sh
act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:12-buster-slim
act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:16-buster-slim
```

# Secrets
Expand Down
6 changes: 3 additions & 3 deletions cmd/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

func (i *Input) newPlatforms() map[string]string {
platforms := map[string]string{
"ubuntu-latest": "node:12-buster-slim",
"ubuntu-20.04": "node:12-buster-slim",
"ubuntu-18.04": "node:12-buster-slim",
"ubuntu-latest": "node:16-buster-slim",
"ubuntu-20.04": "node:16-buster-slim",
"ubuntu-18.04": "node:16-buster-slim",
}

for _, p := range i.platforms {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func defaultImageSurvey(actrc string) error {
case "Medium":
option = "-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest\n-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04\n-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04\n"
case "Micro":
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"
option = "-P ubuntu-latest=node:16-buster-slim\n-P ubuntu-20.04=node:16-buster-slim\n-P ubuntu-18.04=node:16-buster-slim\n"
}

f, err := os.Create(actrc)
Expand Down
2 changes: 1 addition & 1 deletion pkg/artifacts/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestArtifactFlow(t *testing.T) {
defer cancel()

platforms := map[string]string{
"ubuntu-latest": "node:12.20.1-buster-slim",
"ubuntu-latest": "node:16-buster-slim",
}

tables := []TestJobFileInfo{
Expand Down
8 changes: 4 additions & 4 deletions pkg/container/docker_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ func TestImageExistsLocally(t *testing.T) {

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

imageDefaultArchExists, err := ImageExistsLocally(ctx, "node:12-buster-slim", "linux/amd64")
imageDefaultArchExists, err := ImageExistsLocally(ctx, "node:16-buster-slim", "linux/amd64")
assert.Nil(t, err)
assert.Equal(t, true, imageDefaultArchExists)

// Validate if another architecture platform can be pulled
readerArm64, err := cli.ImagePull(ctx, "node:12-buster-slim", types.ImagePullOptions{
readerArm64, err := cli.ImagePull(ctx, "node:16-buster-slim", types.ImagePullOptions{
Platform: "linux/arm64",
})
assert.Nil(t, err)
defer readerArm64.Close()
_, err = ioutil.ReadAll(readerArm64)
assert.Nil(t, err)

imageArm64Exists, err := ImageExistsLocally(ctx, "node:12-buster-slim", "linux/arm64")
imageArm64Exists, err := ImageExistsLocally(ctx, "node:16-buster-slim", "linux/arm64")
assert.Nil(t, err)
assert.Equal(t, true, imageArm64Exists)
}
5 changes: 4 additions & 1 deletion pkg/model/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ func (a *ActionRunsUsing) UnmarshalYAML(unmarshal func(interface{}) error) error
// Force input to lowercase for case insensitive comparison
format := ActionRunsUsing(strings.ToLower(using))
switch format {
case ActionRunsUsingNode12, ActionRunsUsingDocker, ActionRunsUsingComposite:
case ActionRunsUsingNode16, ActionRunsUsingNode12, ActionRunsUsingDocker, ActionRunsUsingComposite:
*a = format
default:
return fmt.Errorf(fmt.Sprintf("The runs.using key in action.yml must be one of: %v, got %s", []string{
ActionRunsUsingComposite,
ActionRunsUsingDocker,
ActionRunsUsingNode12,
ActionRunsUsingNode16,
}, format))
}
return nil
Expand All @@ -35,6 +36,8 @@ func (a *ActionRunsUsing) UnmarshalYAML(unmarshal func(interface{}) error) error
const (
// ActionRunsUsingNode12 for running with node12
ActionRunsUsingNode12 = "node12"
// ActionRunsUsingNode12 for running with node16
ActionRunsUsingNode16 = "node16"
// ActionRunsUsingDocker for running with docker
ActionRunsUsingDocker = "docker"
// ActionRunsUsingComposite for running composite
Expand Down
4 changes: 2 additions & 2 deletions pkg/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/nektos/act/pkg/model"
)

var baseImage = "node:12-buster-slim"
var baseImage = "node:16-buster-slim"

func init() {
if p := os.Getenv("ACT_TEST_IMAGE"); p != "" {
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestRunEvent(t *testing.T) {
// {"testdata", "shells/custom", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""}, // custom image with pwsh
{"testdata", "shells/pwsh", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""}, // custom image with pwsh
{"testdata", "shells/bash", "push", "", platforms, ""},
{"testdata", "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:12-buster"}, ""}, // slim doesn't have python
{"testdata", "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:16-buster"}, ""}, // slim doesn't have python
{"testdata", "shells/sh", "push", "", platforms, ""},
{"testdata", "job-container", "push", "", platforms, ""},
{"testdata", "job-container-non-root", "push", "", platforms, ""},
Expand Down
3 changes: 2 additions & 1 deletion pkg/runner/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (sc *StepContext) runAction(actionDir string, actionPath string, actionRepo
}

switch action.Runs.Using {
case model.ActionRunsUsingNode12:
case model.ActionRunsUsingNode12, model.ActionRunsUsingNode16:
if err := maybeCopyToActionDir(); err != nil {
return err
}
Expand All @@ -547,6 +547,7 @@ func (sc *StepContext) runAction(actionDir string, actionPath string, actionRepo
return fmt.Errorf(fmt.Sprintf("The runs.using key must be one of: %v, got %s", []string{
model.ActionRunsUsingDocker,
model.ActionRunsUsingNode12,
model.ActionRunsUsingNode16,
model.ActionRunsUsingComposite,
}, action.Runs.Using))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/testdata/actions/docker-local/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Container image that runs your code
FROM node:12-buster-slim
FROM node:16-buster-slim

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/testdata/actions/docker-url/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
default: World
runs:
using: docker
image: docker://node:12-buster-slim
image: docker://node:16-buster-slim
entrypoint: /bin/sh -c
env:
TEST: enabled
Expand Down
3 changes: 3 additions & 0 deletions pkg/runner/testdata/actions/node12/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
},
"devDependencies": {
"@vercel/ncc": "^0.24.1"
},
"engines": {
"node": ">=12"
}
}
3 changes: 3 additions & 0 deletions pkg/runner/testdata/actions/node16/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Updating

If an update to this app is required, it must be done manually via `npm run-script build` since the `node_modules` are not shared.
13 changes: 13 additions & 0 deletions pkg/runner/testdata/actions/node16/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node16'
main: 'dist/index.js'
Loading

0 comments on commit 5580812

Please sign in to comment.