-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (110 loc) · 3.78 KB
/
static-analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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