-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (127 loc) · 4.32 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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