-
Notifications
You must be signed in to change notification settings - Fork 17
47 lines (45 loc) · 1.79 KB
/
tests.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
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
stable: "false"
go-version: "1.18"
- name: Run Linters
run: ./run_lint.sh
- name: Run Tests
run: CI=true ./run_tests.sh
contest-generator:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
# clone in the gopath
path: src/github.com/${{ github.repository }}
- uses: actions/setup-go@v2
with:
stable: "false"
go-version: "1.18"
- name: set up environment variables
run: |
# must do this here because `env` doesn't allow variable expansion
echo "GOPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "GOBIN=$GITHUB_WORKSPACE/bin" >> $GITHUB_ENV
- name: Validate contest-generator
run: |
set -exu
cd "${GITHUB_WORKSPACE}"/src/github.com/${{ github.repository }}/cmds/contest-generator
go build
builddir=$(./contest-generator --from core-plugins.yml) # generate the code and get the output directory
cd "${builddir}"
ls -l
go mod init contest
go mod edit -replace "github.com/${{ github.repository}}=${GITHUB_WORKSPACE}/src/github.com/${{ github.repository}}" # ensure we are building against the code from this commit
go mod tidy
go build # build the generated main.go
gofmt -w "${builddir}/contest.go" # ensure that the code respects Go's format guidelines
diff -Naur "${builddir}/contest.go" "${GITHUB_WORKSPACE}"/src/github.com/${{ github.repository }}/cmds/contest/main.go # show the differences between the newly generated code and the existing one