-
Notifications
You must be signed in to change notification settings - Fork 159
132 lines (131 loc) · 4.13 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
on: [push, pull_request]
jobs:
unit-tests:
name: Unit tests
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-13]
go: ['1.22', '1.23']
runs-on: ${{ matrix.os }}
steps:
- name: Install dependencies on macOS
run: |
set -x
brew install --quiet shellcheck python3 pipx
# https://pipx.pypa.io/stable/installation/
pipx ensurepath
pipx install pyflakes
shellcheck --version
pyflakes --version
if: ${{ matrix.os == 'macos-latest' }}
- name: Install dependencies on Linux
run: |
set -x
sudo apt-get install -y shellcheck
pip install pyflakes
shellcheck --version
pyflakes --version
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Install dependencies on Windows
run: |
# `choco install shellcheck` is too slow on GitHub Actions. It takes more than 3 minutes to install one package
# choco install shellcheck
pip install pyflakes
pyflakes --version
if: ${{ matrix.os == 'windows-latest' }}
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- run: go test -v -race -coverprofile coverage.txt -covermode=atomic ./...
- run: go tool cover -func ./coverage.txt
# Check build without CGO
- run: go build ./cmd/actionlint
env:
# Note: -race requires cgo
CGO_ENABLED: 0
# Set -race for catching data races on dog fooding (#333)
- run: go build -race ./cmd/actionlint
- name: Dog fooding 🐶
run: |
echo "::add-matcher::.github/actionlint-matcher.json"
./actionlint -color
- uses: codecov/codecov-action@v4
with:
env_vars: OS
token: ${{ secrets.CODECOV_TOKEN }}
env:
OS: ${{ matrix.os }}
wasm:
name: Wasm
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./playground
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Cache node_modules
uses: actions/cache@v4
with:
path: ./playground/node_modules
key: ${{ hashFiles('./playground/package.json') }}
- name: Build playground
run: make build
- name: Lint playground
run: npm run lint
- name: Run tests for wasm
run: npm test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install dependencies
run: |
sudo apt-get install -y shellcheck
pip install pyflakes
shellcheck --version
pyflakes --version
- name: Check Go sources are formatted
run: |
diffs="$(gofmt -d ./*.go ./cmd/actionlint/*.go ./scripts/*/*.go ./playground/*.go)"
if [[ "$diffs" != "" ]]; then
echo "$diffs" >&2
exit 1
fi
- name: Install staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- run: make lint SKIP_GO_GENERATE=true
- name: Lint bash scripts
run: shellcheck ./scripts/*.bash ./playground/*.bash
docker:
name: Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
id: image
uses: docker/build-push-action@v5
with:
build-args: |
GOLANG_VER=1.23
push: false
- name: Test Docker image
run: docker container run
--mount type=bind,source="$(pwd)",target=/mnt/app
--workdir /mnt/app
-- ${{ steps.image.outputs.digest }} -color -verbose
- name: Lint Dockerfile with hadolint
run: docker run --rm -i hadolint/hadolint hadolint --ignore DL3018 --strict-labels - < Dockerfile