[addon-operator] refactoring #1794
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run unit tests. | |
# Starts for new and updated pull requests. | |
name: Unit tests | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
run_unit_tests: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.22 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
id: go | |
- name: Check out addon-operator code | |
uses: actions/checkout@v4 | |
- name: Restore Go modules | |
id: go-modules-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-gomod-${{ hashFiles('go.mod', 'go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-gomod- | |
- name: Download Go modules | |
if: steps.go-modules-cache.outputs.cache-hit != 'true' | |
run: | | |
go mod download | |
echo -n "Go modules unpacked size is: " && du -sh $HOME/go/pkg/mod | |
- name: Download prebuilt libjq static libraries | |
run: | | |
curl -sSfL https://github.com/flant/libjq-go/releases/download/jq-b6be13d5-0/libjq-glibc-amd64.tgz | tar zxf - | |
- name: Run unit tests | |
run: | | |
export CGO_ENABLED=1 | |
export CGO_CFLAGS="-I$GITHUB_WORKSPACE/libjq/include" | |
export CGO_LDFLAGS="-L$GITHUB_WORKSPACE/libjq/lib" | |
export GOOS=linux | |
go test \ | |
-tags use_libjq \ | |
./cmd/... ./pkg/... |