Merge pull request #16308 from barrettj12/k3s-operator-update #2694
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: | |
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@v3 | |
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 | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.0 | |
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 | |
sudo DEBIAN_FRONTEND=noninteractive apt install -y expect | |
- 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)" | |
STATIC_ANALYSIS_JOB=test_static_analysis_go make static-analysis | |
shell: bash | |
- 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@v3 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install Dependencies | |
if: steps.filter.outputs.schema == 'true' | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt install -y expect | |
- name: Schema Check | |
if: steps.filter.outputs.schema == 'true' | |
run: | | |
STATIC_ANALYSIS_JOB=test_schema make static-analysis | |
shell: bash |