-
Notifications
You must be signed in to change notification settings - Fork 40
173 lines (139 loc) · 4.39 KB
/
ci.yml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
needs: [lint, test]
strategy:
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.environment }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Speed up Go (Windows)
if: runner.os == 'Windows'
run: |
DIR='D:\a\local'
mkdir -p "$DIR" && cd "$DIR"
mkdir go go-cache go-tmp tmpdir
go env -w GOPATH="$DIR\\go"
go env -w GOCACHE="$DIR\\go-cache"
go env -w GOTMPDIR="$DIR\\go-tmp"
printf '%s\\go\\bin\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'TMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
go env
- uses: actions/setup-go@v4
with:
go-version: "^1.18.1"
- name: Build (Linux and macOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: go build -o medusa -v .
- name: Compress (Linux and macOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: tar -czvf medusa.tar.gz medusa
- name: Build (Windows)
if: runner.os == 'Windows'
run: go build -o medusa.exe -v .
- name: Compress (Windows)
if: runner.os == 'Windows'
run: tar -czvf medusa.tar.gz medusa.exe
- name: Upload artifact on merge to master
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: medusa-${{ runner.os }}
path: medusa.tar.gz
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "^1.18.1"
- name: Actionlint
run: |
go install github.com/rhysd/actionlint/cmd/actionlint@latest
actionlint
- name: Prettier
run: |
npm install -g prettier
prettier --check '**.json' '**/*.md' '**/*.yml' '!(pkg)'
- name: Markdown link check
run: |
npm install -g markdown-link-check@3.10.3
markdown-link-check --config .github/workflows/resources/markdown_link_check.json ./*.md
- name: Format
run: |
go fmt ./...
git diff --exit-code
- name: Lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout 5m0s
test:
strategy:
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.environment }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Speed up Go, Python, Node (Windows)
if: runner.os == 'Windows'
run: |
DIR='D:\a\local'
mkdir -p "$DIR" && cd "$DIR"
echo "::group::Go"
mkdir -p go go-cache go-tmp tmpdir
go env -w GOPATH="$DIR\\go"
go env -w GOCACHE="$DIR\\go-cache"
go env -w GOTMPDIR="$DIR\\go-tmp"
printf '%s\\go\\bin\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'TMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
go env
echo "::endgroup::"
echo "::group::Python"
python3 -m venv venv
printf '%s\\venv\\Scripts\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'VIRTUAL_ENV=%s\\venv\n' "$DIR" | tee -a "$GITHUB_ENV"
echo "::endgroup::"
echo "::group::Node"
npm config set cache "$DIR\\npm-cache" --global
echo "::endgroup::"
- uses: actions/setup-go@v4
with:
go-version: "^1.18.1"
- uses: actions/setup-node@v3
with:
node-version: 18.15
- name: Install Node dependencies
run: npm install hardhat
- name: Install Python dependencies
run: |
pip3 install --no-cache-dir solc-select crytic-compile
- name: Install solc
run: |
solc-select use 0.8.17 --always-install
- name: Test
run: go test ./...
all-checks:
needs: [lint, test, build]
runs-on: ubuntu-latest
steps:
- run: true