Skip to content

Commit 5a0cce2

Browse files
authored
Merge pull request #11430 from erik-krogh/go-go
GO: get the Go CI to go fast!
2 parents fb1f221 + 2b0ecec commit 5a0cce2

File tree

3 files changed

+102
-65
lines changed

3 files changed

+102
-65
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "Go: Run Tests - Other OS"
2+
on:
3+
pull_request:
4+
paths:
5+
- "go/**"
6+
- "!go/ql/**" # don't run other-os if only ql/ files changed
7+
- .github/workflows/go-tests-other-os.yml
8+
- .github/actions/fetch-codeql/action.yml
9+
- .github/actions/cache-query-compilation/action.yml
10+
- codeql-workspace.yml
11+
jobs:
12+
test-mac:
13+
name: Test MacOS
14+
runs-on: macos-latest
15+
steps:
16+
- name: Set up Go 1.19
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.19
20+
id: go
21+
22+
- name: Check out code
23+
uses: actions/checkout@v2
24+
25+
- name: Set up CodeQL CLI
26+
uses: ./.github/actions/fetch-codeql
27+
28+
- name: Enable problem matchers in repository
29+
shell: bash
30+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
31+
32+
- name: Build
33+
run: |
34+
cd go
35+
make
36+
37+
- name: Cache compilation cache
38+
id: query-cache
39+
uses: ./.github/actions/cache-query-compilation
40+
with:
41+
key: go-qltest
42+
- name: Test
43+
run: |
44+
cd go
45+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
46+
47+
test-win:
48+
name: Test Windows
49+
runs-on: windows-latest-xl
50+
steps:
51+
- name: Set up Go 1.19
52+
uses: actions/setup-go@v3
53+
with:
54+
go-version: 1.19
55+
id: go
56+
57+
- name: Check out code
58+
uses: actions/checkout@v2
59+
60+
- name: Set up CodeQL CLI
61+
uses: ./.github/actions/fetch-codeql
62+
63+
- name: Enable problem matchers in repository
64+
shell: bash
65+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
66+
67+
- name: Build
68+
run: |
69+
cd go
70+
make
71+
72+
- name: Cache compilation cache
73+
id: query-cache
74+
uses: ./.github/actions/cache-query-compilation
75+
with:
76+
key: go-qltest
77+
78+
- name: Test
79+
run: |
80+
cd go
81+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

.github/workflows/go-tests.yml

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
name: "Go: Run Tests"
22
on:
3+
push:
4+
paths:
5+
- "go/**"
6+
- .github/workflows/go-tests.yml
7+
- .github/actions/fetch-codeql/action.yml
8+
- .github/actions/cache-query-compilation/action.yml
9+
- codeql-workspace.yml
10+
branches:
11+
- main
12+
- "rc/*"
313
pull_request:
414
paths:
515
- "go/**"
616
- .github/workflows/go-tests.yml
717
- .github/actions/fetch-codeql/action.yml
18+
- .github/actions/cache-query-compilation/action.yml
819
- codeql-workspace.yml
920
jobs:
1021
test-linux:
1122
name: Test Linux (Ubuntu)
12-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-latest-xl
1324
steps:
1425
- name: Set up Go 1.19
1526
uses: actions/setup-go@v3
@@ -32,7 +43,7 @@ jobs:
3243
cd go
3344
make
3445
35-
- name: Check that all QL and Go code is autoformatted
46+
- name: Check that all Go code is autoformatted
3647
run: |
3748
cd go
3849
make check-formatting
@@ -48,67 +59,13 @@ jobs:
4859
name: qhelp-markdown
4960
path: go/qhelp-out/**/*.md
5061

51-
- name: Test
52-
run: |
53-
cd go
54-
make test
55-
56-
test-mac:
57-
name: Test MacOS
58-
runs-on: macos-latest
59-
steps:
60-
- name: Set up Go 1.19
61-
uses: actions/setup-go@v3
62-
with:
63-
go-version: 1.19
64-
id: go
65-
66-
- name: Check out code
67-
uses: actions/checkout@v2
68-
69-
- name: Set up CodeQL CLI
70-
uses: ./.github/actions/fetch-codeql
71-
72-
- name: Enable problem matchers in repository
73-
shell: bash
74-
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
75-
76-
- name: Build
77-
run: |
78-
cd go
79-
make
80-
81-
- name: Test
82-
run: |
83-
cd go
84-
make test
85-
86-
test-win:
87-
name: Test Windows
88-
runs-on: windows-2019
89-
steps:
90-
- name: Set up Go 1.19
91-
uses: actions/setup-go@v3
62+
- name: Cache compilation cache
63+
id: query-cache
64+
uses: ./.github/actions/cache-query-compilation
9265
with:
93-
go-version: 1.19
94-
id: go
95-
96-
- name: Check out code
97-
uses: actions/checkout@v2
98-
99-
- name: Set up CodeQL CLI
100-
uses: ./.github/actions/fetch-codeql
101-
102-
- name: Enable problem matchers in repository
103-
shell: bash
104-
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
105-
106-
- name: Build
107-
run: |
108-
cd go
109-
make
110-
66+
key: go-qltest
67+
11168
- name: Test
11269
run: |
11370
cd go
114-
make test
71+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

go/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ autoformat:
3434
find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -w
3535

3636
check-formatting:
37-
find ql -iregex '.*\.qll?' -print0 | xargs -0 codeql query format --check-only
3837
test -z "$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l)"
3938

4039
install-deps:
@@ -117,9 +116,9 @@ ql/lib/go.dbscheme.stats: ql/lib/go.dbscheme build/stats/src.stamp extractor
117116
codeql dataset measure -o $@ build/stats/database/db-go
118117

119118
test: all build/testdb/check-upgrade-path
120-
codeql test run ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency
119+
codeql test run -j0 ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
121120
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
122-
env GOOS=linux GOARCH=386 codeql$(EXE) test run ql/test/query-tests/Security/CWE-681 --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency
121+
env GOOS=linux GOARCH=386 codeql$(EXE) test run -j0 ql/test/query-tests/Security/CWE-681 --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
123122
cd extractor; go test -mod=vendor ./... | grep -vF "[no test files]"
124123
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
125124

0 commit comments

Comments
 (0)