Skip to content

Commit 12b9b80

Browse files
committed
Go: revert changes to make and CI to postpone them in a separate PR
1 parent a8d3226 commit 12b9b80

File tree

3 files changed

+191
-14
lines changed

3 files changed

+191
-14
lines changed

.github/workflows/go-tests-other-os.yml

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- .github/workflows/go-tests-other-os.yml
88
- .github/actions/**
99
- codeql-workspace.yml
10+
env:
11+
GO_VERSION: '~1.22.0'
1012

1113
permissions:
1214
contents: read
@@ -16,17 +18,72 @@ jobs:
1618
name: Test MacOS
1719
runs-on: macos-latest
1820
steps:
21+
- name: Set up Go ${{ env.GO_VERSION }}
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
cache: false
26+
id: go
27+
1928
- name: Check out code
2029
uses: actions/checkout@v4
21-
- name: Run tests
22-
uses: ./go/actions/test
30+
31+
- name: Set up CodeQL CLI
32+
uses: ./.github/actions/fetch-codeql
33+
34+
- name: Enable problem matchers in repository
35+
shell: bash
36+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
37+
38+
- name: Build
39+
run: |
40+
cd go
41+
make
42+
43+
- name: Cache compilation cache
44+
id: query-cache
45+
uses: ./.github/actions/cache-query-compilation
46+
with:
47+
key: go-qltest
48+
- name: Test
49+
run: |
50+
cd go
51+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
2352
2453
test-win:
2554
if: github.repository_owner == 'github'
2655
name: Test Windows
2756
runs-on: windows-latest-xl
2857
steps:
58+
- name: Set up Go ${{ env.GO_VERSION }}
59+
uses: actions/setup-go@v5
60+
with:
61+
go-version: ${{ env.GO_VERSION }}
62+
cache: false
63+
id: go
64+
2965
- name: Check out code
3066
uses: actions/checkout@v4
31-
- name: Run tests
32-
uses: ./go/actions/test
67+
68+
- name: Set up CodeQL CLI
69+
uses: ./.github/actions/fetch-codeql
70+
71+
- name: Enable problem matchers in repository
72+
shell: bash
73+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
74+
75+
- name: Build
76+
run: |
77+
cd go
78+
make
79+
80+
- name: Cache compilation cache
81+
id: query-cache
82+
uses: ./.github/actions/cache-query-compilation
83+
with:
84+
key: go-qltest
85+
86+
- name: Test
87+
run: |
88+
cd go
89+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

.github/workflows/go-tests.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
- .github/actions/**
1717
- codeql-workspace.yml
1818

19+
env:
20+
GO_VERSION: '~1.22.0'
21+
1922
permissions:
2023
contents: read
2124

@@ -25,9 +28,51 @@ jobs:
2528
name: Test Linux (Ubuntu)
2629
runs-on: ubuntu-latest-xl
2730
steps:
31+
- name: Set up Go ${{ env.GO_VERSION }}
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ env.GO_VERSION }}
35+
cache: false
36+
id: go
37+
2838
- name: Check out code
2939
uses: actions/checkout@v4
30-
- name: Run tests
31-
uses: ./go/actions/test
40+
41+
- name: Set up CodeQL CLI
42+
uses: ./.github/actions/fetch-codeql
43+
44+
- name: Enable problem matchers in repository
45+
shell: bash
46+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
47+
48+
- name: Build
49+
run: |
50+
cd go
51+
make
52+
53+
- name: Check that all Go code is autoformatted
54+
run: |
55+
cd go
56+
make check-formatting
57+
58+
- name: Compile qhelp files to markdown
59+
run: |
60+
cd go
61+
env QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown
62+
63+
- name: Upload qhelp markdown
64+
uses: actions/upload-artifact@v3
3265
with:
33-
run-code-checks: true
66+
name: qhelp-markdown
67+
path: go/qhelp-out/**/*.md
68+
69+
- name: Cache compilation cache
70+
id: query-cache
71+
uses: ./.github/actions/cache-query-compilation
72+
with:
73+
key: go-qltest
74+
75+
- name: Test
76+
run: |
77+
cd go
78+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

go/Makefile

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
all: gen extractor
1+
all: extractor ql/lib/go.dbscheme
2+
3+
ifeq ($(OS),Windows_NT)
4+
EXE = .exe
5+
CODEQL_PLATFORM = win64
6+
else
7+
EXE =
8+
UNAME_S := $(shell uname -s)
9+
ifeq ($(UNAME_S),Linux)
10+
CODEQL_PLATFORM = linux64
11+
endif
12+
ifeq ($(UNAME_S),Darwin)
13+
CODEQL_PLATFORM = osx64
14+
endif
15+
endif
16+
17+
CODEQL_TOOLS = $(addprefix codeql-tools/,autobuild.cmd autobuild.sh baseline-config-empty.json baseline-config-vendor.json configure-baseline.cmd configure-baseline.sh identify-environment.cmd identify-environment.sh index.cmd index.sh pre-finalize.cmd pre-finalize.sh tracing-config.lua)
218

319
EXTRACTOR_PACK_OUT = build/codeql-extractor-go
420

5-
.PHONY: extractor gen clean autoformat check-formatting
21+
BINARIES = go-extractor go-tokenizer go-autobuilder go-build-runner go-bootstrap go-gen-dbscheme
22+
23+
.PHONY: tools tools-codeql tools-codeql-full clean autoformat \
24+
tools-linux64 tools-osx64 tools-win64 check-formatting
625

726
clean:
27+
rm -rf tools/bin tools/linux64 tools/osx64 tools/win64 tools/net tools/opencsv
828
rm -rf $(EXTRACTOR_PACK_OUT) build/stats build/testdb
929

1030
autoformat:
@@ -27,11 +47,66 @@ endif
2747
qhelp-to-markdown:
2848
scripts/qhelp-to-markdown.sh ql/src "$(QHELP_OUT_DIR)"
2949

30-
extractor:
31-
bazel run :create-extractor-pack
50+
tools: tools-codeql tools/tokenizer.jar
51+
52+
.PHONY: $(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES)))
53+
$(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES))):
54+
go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F))
55+
56+
tools-codeql: tools-$(CODEQL_PLATFORM)
57+
58+
tools-codeql-full: tools-linux64 tools-osx64 tools-win64
59+
60+
tools-linux64: $(addprefix tools/linux64/,$(BINARIES))
61+
62+
.PHONY: $(addprefix tools/linux64/,$(BINARIES))
63+
$(addprefix tools/linux64/,$(BINARIES)):
64+
GOOS=linux GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(@F)
65+
66+
tools-osx64: $(addprefix tools/osx64/,$(BINARIES))
67+
68+
.PHONY: $(addprefix tools/osx64/,$(BINARIES))
69+
$(addprefix tools/osx64/,$(BINARIES)):
70+
GOOS=darwin GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@.amd64 ./cli/$(@F)
71+
GOOS=darwin GOARCH=arm64 go build -C extractor -mod=vendor -o ../$@.arm64 ./cli/$(@F)
72+
lipo -create $@.amd64 $@.arm64 -output $@
73+
rm $@.amd64 $@.arm64
74+
75+
tools-win64: $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES)))
76+
77+
.PHONY: $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES)))
78+
$(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES))):
79+
env GOOS=windows GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F))
80+
81+
.PHONY: extractor-common extractor extractor-full
82+
extractor-common: codeql-extractor.yml LICENSE ql/lib/go.dbscheme \
83+
tools/tokenizer.jar $(CODEQL_TOOLS)
84+
rm -rf $(EXTRACTOR_PACK_OUT)
85+
mkdir -p $(EXTRACTOR_PACK_OUT)
86+
cp codeql-extractor.yml LICENSE ql/lib/go.dbscheme ql/lib/go.dbscheme.stats $(EXTRACTOR_PACK_OUT)
87+
mkdir $(EXTRACTOR_PACK_OUT)/tools
88+
cp -r tools/tokenizer.jar $(CODEQL_TOOLS) $(EXTRACTOR_PACK_OUT)/tools
89+
cp -r downgrades $(EXTRACTOR_PACK_OUT)
90+
91+
extractor: extractor-common tools-codeql
92+
cp -r tools/$(CODEQL_PLATFORM) $(EXTRACTOR_PACK_OUT)/tools
93+
94+
extractor-full: extractor-common tools-codeql-full
95+
cp -r $(addprefix tools/,linux64 osx64 win64) $(EXTRACTOR_PACK_OUT)/tools
96+
97+
tools/tokenizer.jar: tools/net/sourceforge/pmd/cpd/GoLanguage.class
98+
jar cf $@ -C tools net
99+
jar uf $@ -C tools opencsv
100+
101+
tools/net/sourceforge/pmd/cpd/GoLanguage.class: extractor/net/sourceforge/pmd/cpd/GoLanguage.java
102+
javac -cp extractor -d tools $<
103+
rm tools/net/sourceforge/pmd/cpd/AbstractLanguage.class
104+
rm tools/net/sourceforge/pmd/cpd/SourceCode.class
105+
rm tools/net/sourceforge/pmd/cpd/TokenEntry.class
106+
rm tools/net/sourceforge/pmd/cpd/Tokenizer.class
32107

33-
gen:
34-
bazel run :gen
108+
ql/lib/go.dbscheme: tools/$(CODEQL_PLATFORM)/go-gen-dbscheme$(EXE)
109+
$< $@
35110

36111
build/stats/src.stamp:
37112
mkdir -p $(@D)/src
@@ -48,7 +123,7 @@ test: all build/testdb/check-upgrade-path
48123
codeql test run -j0 ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
49124
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
50125
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)
51-
cd extractor; bazel test ...
126+
cd extractor; go test -mod=vendor ./...
52127
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
53128

54129
.PHONY: build/testdb/check-upgrade-path

0 commit comments

Comments
 (0)