Merge pull request #16647 from SimonRichardson/bootstrap-worker #2738
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
name: "Static Analysis" | |
on: | |
push: | |
branches: [2.9, 3.1, 3.2, 3.3, main] | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
# paths: | |
# DON'T SET - these are "required" so they need to run on every PR | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
name: Lint | |
runs-on: [self-hosted, linux, arm64, aws, xxlarge] | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Determine which tests to run | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
go: | |
- '**.go' | |
- 'go.mod' | |
sh: | |
- '**.sh' | |
python: | |
- '**.py' | |
static-analysis: | |
- '.github/workflows/static-analysis.yml' | |
- 'Makefile' | |
- 'tests/main.sh' | |
- 'tests/includes/**' | |
- 'tests/suites/static_analysis/**' | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install Dependencies | |
run: | | |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV | |
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | |
sudo add-apt-repository ppa:dqlite/dev -y --no-update | |
sudo apt-get update | |
sudo apt-get install -y \ | |
expect \ | |
libdqlite-dev \ | |
libsqlite3-dev \ | |
sqlite3 | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 | |
sudo curl -sSfL https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_$(go env GOARCH) -o /usr/bin/shfmt | |
sudo chmod +x /usr/bin/shfmt | |
- name: Download Dependencies | |
run: go mod download | |
- name: "Static Analysis: Copyright" | |
if: steps.filter.outputs.static-analysis == 'true' || steps.filter.outputs.go == 'true' | |
run: | | |
STATIC_ANALYSIS_JOB=test_copyright make static-analysis | |
shell: bash | |
- name: "Static Analysis: Shell Check" | |
if: steps.filter.outputs.static-analysis == 'true' || steps.filter.outputs.sh == 'true' | |
run: | | |
STATIC_ANALYSIS_JOB=test_static_analysis_shell make static-analysis | |
shell: bash | |
- name: "Static Analysis: Go Check" | |
if: steps.filter.outputs.static-analysis == 'true' || steps.filter.outputs.go == 'true' | |
run: | | |
# Explicitly set GOROOT to avoid golangci-lint/issues/3107 | |
export "GOROOT=$(go env GOROOT)" | |
export "CGO_LDFLAGS=-L$(pwd)/_deps/juju-dqlite-static-lib-deps -luv -lraft -ldqlite -llz4 -lsqlite3" | |
STATIC_ANALYSIS_JOB=test_static_analysis_go make static-analysis | |
shell: bash | |
env: | |
CGO_ENABLED: 1 | |
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" | |
- name: "Static Analysis: Python Check" | |
if: steps.filter.outputs.static-analysis == 'true' || steps.filter.outputs.python == 'true' | |
run: | | |
STATIC_ANALYSIS_JOB=test_static_analysis_python make static-analysis | |
shell: bash | |
schema: | |
name: Schema | |
runs-on: [self-hosted, linux, arm64, aws, large] | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check if there is anything to test | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
schema: | |
- 'apiserver/facades/schema.json' | |
- 'generate/schemagen/**' | |
- '**.go' | |
- 'go.mod' | |
- '.github/workflows/static-analysis.yml' | |
- 'Makefile' | |
- 'tests/main.sh' | |
- 'tests/includes/**' | |
- 'tests/suites/static_analysis/schema.sh' | |
- name: Set up Go | |
if: steps.filter.outputs.schema == 'true' | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install Dependencies | |
if: steps.filter.outputs.schema == 'true' | |
run: | | |
sudo add-apt-repository ppa:dqlite/dev -y --no-update | |
sudo apt-get update | |
sudo apt-get install -y \ | |
expect \ | |
libdqlite-dev \ | |
libsqlite3-dev \ | |
sqlite3 | |
- name: Schema Check | |
if: steps.filter.outputs.schema == 'true' | |
run: | | |
STATIC_ANALYSIS_JOB=test_schema make static-analysis | |
shell: bash |