-
Notifications
You must be signed in to change notification settings - Fork 12
75 lines (62 loc) · 2.08 KB
/
test.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
name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
GO111MODULE: on
BUILDKIT_HOST: docker-container://buildkitd
jobs:
build:
name: Build
# expression language does not support ternary, so hack it via indexing boolean keys of an json object
runs-on: ${{ fromJSON('{true:"buildkitd",false:"ubuntu-latest"}')[github.repository == 'openllb/hlb'] }}
steps:
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: ^1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Restore Cache
uses: actions/cache@v1
if: github.repository != 'openllb/hlb'
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Get dependencies
run: go get
- name: Compile
run: |
go build -o build/hlb ./cmd/hlb
go build -o build/docgen ./cmd/docgen
go build -o build/builtingen ./cmd/builtingen
- name: Go Tests
run: go test -v ./...
- name: Start BuildkitD
if: github.repository != 'openllb/hlb'
run: docker run --name buildkitd --rm -d --privileged openllb/buildkit:experimental
- name: BuildkitD Wait
if: github.repository != 'openllb/hlb'
# waiting for buildkitd to report 1 worker (2 lines, 1 for column titles, one for the worker details)
run: while true; do lineCount=$(docker exec buildkitd buildctl debug workers | wc -l); if [ $lineCount -gt 1 ]; then break; fi; sleep 1; done
- name: GoLint
run: ./build/hlb run -t lint
- name: Ensure generated files
run: |
./build/hlb run -t gen
if ! git diff --quiet; then
echo "ERROR: Generated files need updating:" >&2
echo "" >&2
git ls-files -m | sed 's/^/ /g' >&2
echo "" >&2
echo "To resolve run:" >&2
echo " ./hlb run -t gen" >&2
echo "and add changes to the git branch" >&2
exit 1
fi
- name: Crosscompile
run: ./build/hlb run