forked from elves/elvish
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (193 loc) · 5.69 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: CI
on:
push:
pull_request:
defaults:
run:
# PowerShell's behavior for -flag=value is undesirable, so run all commands with bash.
shell: bash
jobs:
test:
name: Run tests
strategy:
matrix:
os: [ubuntu, macos, windows]
go-version: [1.18.x]
# We usually support building Elvish with Go 1.N-1 too, but since Go
# 1.18 brought a lot of improvements, we dropped support for Go 1.17
# when Go 1.18 is released. When Go 1.19 is released, uncomment the
# stanza below to test on Go 1.18 too.
#include:
# # Test old supported Go version
# - os: ubuntu
# go-version: 1.18.x
env:
ELVISH_TEST_TIME_SCALE: 20
runs-on: ${{ matrix.os }}-latest
steps:
# autocrlf is problematic for fuzz testdata.
- name: Turn off autocrlf
if: matrix.os == 'windows'
run: git config --global core.autocrlf false
- name: Checkout code
uses: actions/checkout@v2
- name: Set up cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~/AppData/Local/go-build
key: test/${{ matrix.os }}/${{ matrix.go-version }}/${{ hashFiles('go.sum') }}/${{ github.sha }}
restore-keys: test/${{ matrix.os }}/${{ matrix.go-version }}/${{ hashFiles('go.sum') }}/
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Test with race detection
run: |
go test -race ./...
cd website; go test -race ./...
- name: Set ostype to ${{ matrix.os }}
run: echo ostype=${{ matrix.os }} >> $GITHUB_ENV
- name: Set ostype to linux
if: matrix.os == 'ubuntu'
run: echo ostype=linux >> $GITHUB_ENV
- name: Generate test coverage
if: matrix.go-version == '1.18.x'
run: go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
- name: Save test coverage
if: matrix.go-version == '1.18.x'
uses: actions/upload-artifact@v2
with:
name: cover-${{ env.ostype }}
path: cover
# The purpose of running benchmarks in GitHub Actions is primarily to ensure
# that the benchmark code runs and doesn't crash. GitHub Action runners don't
# have a stable enough environment to produce reliable benchmark numbers.
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Run benchmarks
run: go test -bench=. -run='^$' ./...
upload-coverage:
name: Upload test coverage
strategy:
matrix:
ostype: [linux, macos, windows]
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download test coverage
uses: actions/download-artifact@v2
with:
name: cover-${{ matrix.ostype }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
files: ./cover
flags: ${{ matrix.ostype }}
checkstyle-go:
name: Check style of **.go
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Set up goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Check style
run: ./tools/checkstyle-go.sh
checkstyle-md:
name: Check style of **.md
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up environment
run: |
echo "NPM_PREFIX=$HOME/npm" >> $GITHUB_ENV
echo "PATH=$HOME/npm/bin:$PATH" >> $GITHUB_ENV
- name: Set up Node
uses: actions/setup-node@v2
- name: Set up Node prefix
run: npm config set prefix $NPM_PREFIX
- name: Set up prettier
run: npm install --global [email protected]
- name: Check style
run: ./tools/checkstyle-md.sh
codespell:
name: Check spelling
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Install codespell
run: pip install codespell==2.1.0
- name: Run codespell
run: codespell
check-content:
name: Check content
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run check-content.sh
run: ./tools/check-content.sh
check-rellinks:
name: Check relative links
runs-on: ubuntu-latest
container:
image: theelves/up
options: --user 0
defaults:
run:
shell: sh
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check relative links
run: make -C website check-rellinks
lint:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Set up staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@master
- name: Run linters
run: ./tools/lint.sh
lsif:
name: Upload SourceGraph LSIF
if: github.repository == 'elves/elvish' && github.event_name == 'push'
runs-on: ubuntu-latest
container: sourcegraph/lsif-go:latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Generate LSIF data
run: lsif-go
- name: Upload LSIF data
run: src lsif upload -github-token=${{ secrets.GITHUB_TOKEN }} -ignore-upload-failure