-
Notifications
You must be signed in to change notification settings - Fork 23
136 lines (114 loc) · 3.32 KB
/
qa.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
name: QA
on:
- push
- pull_request
jobs:
generate:
name: "${{ github.event_name }} / generate"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: go generate
shell: nix develop -c bash -e {0}
- name: Git dirty check
run: |
git add .
if [[ -n "$(git status --porcelain)" ]]; then
PAGER= git diff --cached
exit 1
fi
lint:
name: "${{ github.event_name }} / lint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run goimports
run: goimports -w .
shell: nix develop -c bash -e {0}
- name: Git dirty check
run: |
git add .
if [[ -n "$(git status --porcelain)" ]]; then
PAGER= git diff --cached
exit 1
fi
test:
name: "${{ github.event_name }} / test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Setup Go build cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-build-nix-${{ github.run_id }}
restore-keys: |
go-build-nix-
go-build-
- run: go test ./...
shell: nix develop -c bash -e {0}
- run: cd pkg && go test ./...
shell: nix develop -c bash -e {0}
docker:
name: "${{ github.event_name }} / docker"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v2
- name: Setup Go build cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-build-docker-${{ github.run_id }}
restore-keys: |
go-build-docker-
go-build-
- run: mkdir -p ~/.cache/go-build
# Check that the instructions for using Docker in CONTRIBUTING.md work.
# Use docker/build-push-action@v4 instead of plain `docker build` to get caching.
- name: docker build -t gotk4 .
uses: docker/build-push-action@v4
with:
# Build but don't push
load: true
push: false
# Caching
cache-from: type=gha
cache-to: type=gha,mode=max
# Normal `docker build` arguments
tags: gotk4
#context: . # commented out to use Git directly instead of the filesystem
- run: |
docker run \
--rm \
--volume "$PWD:/gotk4/" \
-u "$(id -u):$(id -g)" \
gotk4 \
go generate
- name: Git dirty check
run: |
git add .
if [[ -n "$(git status --porcelain)" ]]; then
PAGER= git diff --cached
exit 1
fi
# Also add extra `--volume "$HOME/.cache/go-build:/user/.cache/go-build"`
# arguments to do caching.
- run: |
docker run \
--rm \
--volume "$PWD:/gotk4/" \
--volume "$HOME/.cache/go-build:/user/.cache/go-build" \
-u "$(id -u):$(id -g)" \
gotk4 \
bash -c "cd pkg && go test ./..."