Skip to content

Commit

Permalink
Merge branch 'master' into cat/fix/mount-act-path
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 24, 2021
2 parents fcc8a03 + e82f17e commit c5eb35d
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 71 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
76 changes: 69 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: checks
on: [pull_request, workflow_dispatch]

env:
ACT_OWNER: ${{ github.repository_owner }}
ACT_REPOSITORY: ${{ github.repository }}
CACHED_DOCKER_IMAGES: '"node:12-buster" "node:12-buster-slim" "ubuntu:18.04" "ubuntu:latest" "alpine:3.10" "tonistiigi/binfmt:latest"'
CACHED_DOCKER_IMAGES_KEY: docker-images-0
GO_VERSION: 1.17

jobs:
lint:
name: lint
Expand All @@ -11,7 +18,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- uses: golangci/golangci-lint-action@v2
env:
CGO_ENABLED: 0
Expand Down Expand Up @@ -41,7 +48,7 @@ jobs:
uses: docker/setup-qemu-action@v1
- uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
Expand All @@ -53,22 +60,57 @@ jobs:
env:
CGO_ENABLED: 0
- name: Upload Codecov report
uses: codecov/codecov-action@v1.5.2
uses: codecov/codecov-action@v2.1.0
with:
files: coverage.txt
fail_ci_if_error: true # optional (default = false)

dump_images:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/cache@v2
id: image_cache
with:
key: ${{ env.CACHED_DOCKER_IMAGES_KEY }}
path: |
registry
docker-registry
- name: Pull and export images
if: steps.image_cache.outputs.cache-hit != 'true'
run: |
docker pull registry:2
docker image save -o registry registry:2
mkdir -p docker-registry
docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2
npx wait-on tcp:5000
for image in ${{ env.CACHED_DOCKER_IMAGES }}
do
bash -c 'docker pull "'"$image"'" && docker tag "'"$image"'" "localhost:5000/'"$image"'" && docker push "localhost:5000/'"$image"'"'&
done
wait
test-macos:
needs: dump_images
name: test-macos
runs-on: macos-latest
continue-on-error: true # Don't let macos test fail whole workflow
env:
ISO_PATH: ~/.docker/machine/cache/boot2docker.iso
steps:
- uses: actions/checkout@v2
- name: Restore Docker Image Cache
uses: actions/cache@v2
id: image_cache
continue-on-error: true
with:
key: ${{ env.CACHED_DOCKER_IMAGES_KEY }}
path: |
registry
docker-registry
- uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
Expand Down Expand Up @@ -97,9 +139,23 @@ jobs:
echo "DOCKER_HOST=$DOCKER_HOST" | tee -a $GITHUB_ENV
echo "DOCKER_CERT_PATH=$DOCKER_CERT_PATH" | tee -a $GITHUB_ENV
echo "DOCKER_MACHINE_NAME=$DOCKER_MACHINE_NAME" | tee -a $GITHUB_ENV
printf " 🛠️ Install Qemu for running containers with different architecture 🛠️ \n\n"
docker run --rm --privileged tonistiigi/binfmt --install all
printf " 🛠️ Finished installing Docker 🛠️ \n\n"
- name: Import images
if: steps.image_cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
echo load registry
docker image load -i registry
echo Setup local registry
docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2
echo pulling images from cache
for image in ${{ env.CACHED_DOCKER_IMAGES }}
do
bash -c '(sleep 1 && docker pull "localhost:5000/'"$image"'" || sleep 2 && docker pull "localhost:5000/'"$image"'" || sleep 10 && docker pull "localhost:5000/'"$image"'") && docker tag "localhost:5000/'"$image"'" "'"$image"'"'&
done
wait
- name: 🛠️ Install Qemu for running containers with different architecture 🛠️
run: docker run --rm --privileged tonistiigi/binfmt:latest --install all
- run: go test -v -timeout 30m -cover ./...
env:
CGO_ENABLED: 0
Expand All @@ -111,7 +167,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
Expand Down Expand Up @@ -166,6 +222,12 @@ jobs:
with:
name: act-windows-i386
path: dist/act_windows_386/act.exe
- name: Capture arm64 (64-bit) Windows binary
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v2
with:
name: act-windows-arm64
path: dist/act_windows_arm64/act.exe
- name: Capture armv7 (32-bit) Windows binary
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v2
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
tags:
- v*

env:
GO_VERSION: 1.17

jobs:
release:
name: release
Expand All @@ -14,7 +17,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
Expand Down
12 changes: 4 additions & 8 deletions IMAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

**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**

| Image | Size |
| ------------------------------------ | -------------------------------------------------------- |
| [`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:12-stretch`][hub/_/node] | ![`stretch-size`][hub/_/node/12-stretch/size] |
| [`node:12-stretch-slim`][hub/_/node] | ![`micro-stretch-size`][hub/_/node/12-stretch-slim/size] |
| Image | Size |
| ----------------------------------- | ------------------------------------------------------ |
| [`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] |

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

Expand Down Expand Up @@ -46,8 +44,6 @@ 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/12-stretch/size]: https://img.shields.io/docker/image-size/_/node/12-stretch
[hub/_/node/12-stretch-slim/size]: https://img.shields.io/docker/image-size/_/node/12-stretch-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
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ scoop install act
yay -S act
```

### Nix (Linux/macOS)
### [Nix](https://nixos.org) (Linux/macOS)

[Nix recipe](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/misc/act/default.nix)

Global install:

Expand All @@ -85,7 +87,7 @@ or through `nix-shell`:
nix-shell -p act
```

### Go (Linux/Windows/macOS/any other platform supported by Go)
### [Go](https://golang.org) (Linux/Windows/macOS/any other platform supported by Go)

If you have Go 1.16+, you can install latest released version of `act` directly from source by running:

Expand Down Expand Up @@ -227,22 +229,16 @@ export DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}

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:

| 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-16.04` | [`node:12-stretch-slim`][micro] | [`ghcr.io/catthehacker/ubuntu:act-16.04`][docker_images] | `unavailable` |
| 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] |

[micro]: https://hub.docker.com/_/buildpack-deps
[docker_images]: https://github.com/catthehacker/docker_images

Below platforms are currently **unsupported and won't work** (see issue [#97](https://github.com/nektos/act/issues/97))

- `windows-latest`
- `windows-2019`
- `macos-latest`
- `macos-10.15`
Windows and macOS based platforms are currently **unsupported and won't work** (see issue [#97](https://github.com/nektos/act/issues/97))

## Please see [IMAGES.md](./IMAGES.md) for more information about the Docker images that can be used with `act`

Expand Down
76 changes: 57 additions & 19 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,102 @@ package cmd
import (
"fmt"
"strconv"
"strings"

"github.com/nektos/act/pkg/model"
)

func printList(plan *model.Plan) error {
type lineInfoDef struct {
id string
stage string
name string
jobID string
jobName string
stage string
wfName string
wfFile string
events string
}
lineInfos := []lineInfoDef{}

header := lineInfoDef{
id: "ID",
stage: "Stage",
name: "Name",
jobID: "Job ID",
jobName: "Job name",
stage: "Stage",
wfName: "Workflow name",
wfFile: "Workflow file",
events: "Events",
}

jobs := map[string]bool{}
duplicateJobIDs := false

idMaxWidth := len(header.id)
jobIDMaxWidth := len(header.jobID)
jobNameMaxWidth := len(header.jobName)
stageMaxWidth := len(header.stage)
nameMaxWidth := len(header.name)
wfNameMaxWidth := len(header.wfName)
wfFileMaxWidth := len(header.wfFile)
eventsMaxWidth := len(header.events)

for i, stage := range plan.Stages {
for _, r := range stage.Runs {
jobID := r.JobID
line := lineInfoDef{
id: jobID,
stage: strconv.Itoa(i),
name: r.String(),
jobID: jobID,
jobName: r.String(),
stage: strconv.Itoa(i),
wfName: r.Workflow.Name,
wfFile: r.Workflow.File,
events: strings.Join(r.Workflow.On(), `,`),
}
if _, ok := jobs[jobID]; ok {
duplicateJobIDs = true
} else {
jobs[jobID] = true
}
lineInfos = append(lineInfos, line)
if idMaxWidth < len(line.id) {
idMaxWidth = len(line.id)
if jobIDMaxWidth < len(line.jobID) {
jobIDMaxWidth = len(line.jobID)
}
if jobNameMaxWidth < len(line.jobName) {
jobNameMaxWidth = len(line.jobName)
}
if stageMaxWidth < len(line.stage) {
stageMaxWidth = len(line.stage)
}
if nameMaxWidth < len(line.name) {
nameMaxWidth = len(line.name)
if wfNameMaxWidth < len(line.wfName) {
wfNameMaxWidth = len(line.wfName)
}
if wfFileMaxWidth < len(line.wfFile) {
wfFileMaxWidth = len(line.wfFile)
}
if eventsMaxWidth < len(line.events) {
eventsMaxWidth = len(line.events)
}
}
}

idMaxWidth += 2
jobIDMaxWidth += 2
jobNameMaxWidth += 2
stageMaxWidth += 2
nameMaxWidth += 2
wfNameMaxWidth += 2
wfFileMaxWidth += 2

fmt.Printf("%*s%*s%*s\n", -idMaxWidth, header.id, -stageMaxWidth, header.stage, -nameMaxWidth, header.name)
fmt.Printf("%*s%*s%*s%*s%*s%*s\n",
-stageMaxWidth, header.stage,
-jobIDMaxWidth, header.jobID,
-jobNameMaxWidth, header.jobName,
-wfNameMaxWidth, header.wfName,
-wfFileMaxWidth, header.wfFile,
-eventsMaxWidth, header.events,
)
for _, line := range lineInfos {
fmt.Printf("%*s%*s%*s\n", -idMaxWidth, line.id, -stageMaxWidth, line.stage, -nameMaxWidth, line.name)
fmt.Printf("%*s%*s%*s%*s%*s%*s\n",
-stageMaxWidth, line.stage,
-jobIDMaxWidth, line.jobID,
-jobNameMaxWidth, line.jobName,
-wfNameMaxWidth, line.wfName,
-wfFileMaxWidth, line.wfFile,
-eventsMaxWidth, line.events,
)
}
if duplicateJobIDs {
fmt.Print("\nDetected multiple jobs with the same job name, use `-W` to specify the path to the specific workflow.\n")
Expand Down
11 changes: 3 additions & 8 deletions cmd/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +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-16.04": "node:12-stretch-slim",
"windows-latest": "",
"windows-2019": "",
"macos-latest": "",
"macos-10.15": "",
"ubuntu-latest": "node:12-buster-slim",
"ubuntu-20.04": "node:12-buster-slim",
"ubuntu-18.04": "node:12-buster-slim",
}

for _, p := range i.platforms {
Expand Down
Loading

0 comments on commit c5eb35d

Please sign in to comment.