Skip to content

Commit bd3308e

Browse files
GODRIVER-3493 Test why codeql is breaking
1 parent 4df2f6d commit bd3308e

File tree

4 files changed

+83
-31
lines changed

4 files changed

+83
-31
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ jobs:
3333
languages: go
3434
build-mode: manual
3535

36-
#- name: Install Taskfile support
37-
# uses: arduino/setup-task@v2
36+
- name: Install Taskfile support
37+
uses: arduino/setup-task@v2
3838

39-
#- name: Task build
40-
# shell: bash
41-
# run: task build
39+
- shell: bash
40+
run: task build
4241

4342
- name: Perform CodeQL Analysis
4443
uses: github/codeql-action/analyze@v3

Taskfile.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ tasks:
2323
- go build ./...
2424
- go build ${BUILD_TAGS} ./...
2525
- task: build-tests
26-
- task: build-compile-check-msv
26+
- task: build-compile-check
2727
- task: cross-compile
2828

2929
build-tests: go test -short ${BUILD_TAGS} -run ^$$ ./...
3030

31-
# Compile check for all versions >= the minimum supported version.
32-
build-compile-check: bash etc/run-compile-check-test.sh
33-
34-
# Compile check for the minimum supported version (msv).
35-
build-compile-check-msv: bash etc/run-compile-check-test.sh TestCompileCheck/golang:1.18
31+
build-compile-check: bash etc/compile_check.sh
3632

3733
build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go
3834

etc/compile_check.sh

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,98 @@
22
set -e # exit when any command fails
33
set -x # show all commands being run
44

5-
GC=go
5+
# Default to Go 1.18 if GO_VERSION is not set.
6+
#
7+
# Use the "=" operator (instead of the more common ":-" operator) so that it
8+
# allows setting GO_VERSION="" to use the Go installation in the PATH, and it
9+
# sets the GO_VERSION variable if the default is used.
10+
GC=go${GO_VERSION="1.18"}
611
COMPILE_CHECK_DIR="internal/cmd/compilecheck"
7-
ARCHITECTURES=("386" "arm" "arm64" "ppc64le" "s390x")
8-
BUILD_CMD="${GC} build -buildvcs=false"
9-
10-
# Compilation modules are not part of the workspace as testcontainers requires
11-
# a version of klauspost/compress not supported by the Go Driver / other modules
12-
# in the workspace.
13-
export GOWORK=off
1412

1513
# compile_check will attempt to build the internal/test/compilecheck project
1614
# using the provided Go version. This is to simulate an end-to-end use case.
1715
function compile_check {
1816
# Change the directory to the compilecheck test directory.
19-
pushd "${COMPILE_CHECK_DIR}" >/dev/null
17+
pushd ${COMPILE_CHECK_DIR}
18+
19+
# If a custom Go version is set using the GO_VERSION env var (e.g. "1.18"),
20+
# add the GOPATH bin directory to PATH and then install that Go version.
21+
if [ ! -z "$GO_VERSION" ]; then
22+
PATH=$(go env GOPATH)/bin:$PATH
23+
export PATH
24+
25+
go install golang.org/dl/go$GO_VERSION@latest
26+
${GC} download
27+
fi
2028

2129
${GC} version
2230
${GC} mod tidy
2331

24-
# Standard build
25-
$BUILD_CMD ./...
32+
# Check simple build.
33+
${GC} build ./...
2634

27-
# Dynamic linking
28-
$BUILD_CMD -buildmode=plugin
35+
# Check build with dynamic linking.
36+
${GC} build -buildmode=plugin
2937

3038
# Check build with tags.
31-
[[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
39+
${GC} build $BUILD_TAGS ./...
3240

3341
# Check build with various architectures.
34-
for ARCH in "${ARCHITECTURES[@]}"; do
35-
GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
36-
done
42+
GOOS=linux GOARCH=386 ${GC} build ./...
43+
GOOS=linux GOARCH=arm ${GC} build ./...
44+
GOOS=linux GOARCH=arm64 ${GC} build ./...
45+
GOOS=linux GOARCH=amd64 ${GC} build ./...
46+
GOOS=linux GOARCH=ppc64le ${GC} build ./...
47+
GOOS=linux GOARCH=s390x ${GC} build ./...
48+
49+
# Remove the binaries.
50+
rm compilecheck
51+
rm compilecheck.so
3752

3853
# Change the directory back to the working directory.
39-
popd >/dev/null
54+
popd
4055
}
4156

4257
compile_check
58+
##!/usr/bin/env bash
59+
#set -e # exit when any command fails
60+
#set -x # show all commands being run
61+
#
62+
#GC=go
63+
#COMPILE_CHECK_DIR="internal/cmd/compilecheck"
64+
#ARCHITECTURES=("386" "arm" "arm64" "ppc64le" "s390x")
65+
#BUILD_CMD="${GC} build -buildvcs=false"
66+
#
67+
## Compilation modules are not part of the workspace as testcontainers requires
68+
## a version of klauspost/compress not supported by the Go Driver / other modules
69+
## in the workspace.
70+
#export GOWORK=off
71+
#
72+
## compile_check will attempt to build the internal/test/compilecheck project
73+
## using the provided Go version. This is to simulate an end-to-end use case.
74+
#function compile_check {
75+
# # Change the directory to the compilecheck test directory.
76+
# pushd "${COMPILE_CHECK_DIR}" >/dev/null
77+
#
78+
# ${GC} version
79+
# ${GC} mod tidy
80+
#
81+
# # Standard build
82+
# $BUILD_CMD ./...
83+
#
84+
# # Dynamic linking
85+
# $BUILD_CMD -buildmode=plugin
86+
#
87+
# # Check build with tags.
88+
# [[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
89+
#
90+
# # Check build with various architectures.
91+
# for ARCH in "${ARCHITECTURES[@]}"; do
92+
# GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
93+
# done
94+
#
95+
# # Change the directory back to the working directory.
96+
# popd >/dev/null
97+
#}
98+
#
99+
#compile_check

go.work

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go 1.23.1
1+
go 1.22
22

33
use (
44
.
@@ -8,6 +8,6 @@ use (
88
./internal/cmd/benchmark
99
./internal/cmd/faas/awslambda/mongodb
1010
./internal/test/goleak
11-
./internal/test/compilecheck
11+
//./internal/test/compilecheck
1212
./internal/cmd/compilecheck
1313
)

0 commit comments

Comments
 (0)