-
Notifications
You must be signed in to change notification settings - Fork 23
212 lines (183 loc) · 6.03 KB
/
pr-github-actions.yaml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Check github workflow
on:
push:
paths:
- ".github/**"
branches:
- main
pull_request:
branches:
- main
paths:
- ".github/**"
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'labeled'
workflow_dispatch:
inputs:
nebius:
required: false
type: choice
default: "no"
description: "Run on nebius runners"
options:
- "yes"
- "no"
allow_downgrade:
description: 'Allow downgrade'
required: false
type: choice
default: "no"
options:
- "yes"
- "no"
large_tests:
description: 'Launch large tests'
required: false
type: choice
default: "no"
options:
- "yes"
- "no"
defaults:
run:
shell: bash
env:
nebius: ${{ vars.GLOBAL_RUN_ON_NEBIUS == 'yes' || ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'nebius')) || inputs.nebius == 'yes') }}
allow_downgrade: ${{ vars.GLOBAL_ALLOW_DOWNGRADE == 'yes' || ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'allow-downgrade')) || inputs.allow_downgrade == 'yes') }}
large_tests: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'large-tests')) && 'true' || inputs.large_tests == 'yes' }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
set-env:
runs-on: ubuntu-latest
outputs:
nebius: ${{ env.nebius == 'false' && 'no' || 'yes' }}
allow_downgrade: ${{ env.allow_downgrade == 'false' && 'no' || 'yes' }}
large_tests: ${{ env.large_tests == 'false' && 'no' || 'yes' }}
# we don't need anything, but otherwise github will complain
steps:
- name: set env
id: set-env
run: echo
shell:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: true
- name: get reporter name
uses: haya14busa/action-cond@v1
id: reporter
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "github-pr-review"
if_false: "github-check"
- name: set up dependencies
run: pip install pyyaml
- name: generate shellscripts from github actions
run: |
python .github/scripts/shell-extractor.py
find .temporary/ -type f -name "*.sh";
- name: shellcheck for .github dir
uses: ludeeus/action-shellcheck@master
with:
scandir: .github
env:
SHELLCHECK_OPTS: "-e SC2155,SC2086,SC2154,SC2164,SC2009,SC2015"
- name: shellcheck for github actions shell scripts in .temporary dir
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: "-e SC2155,SC2086,SC2154,SC2164,SC2009,SC2015"
with:
scandir: .temporary
- name: shfmt
uses: librarian/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workdir: .github/
shfmt_flags: "-i 4 -ci -kp -bn -sr"
python:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: true
- name: get reporter name
uses: haya14busa/action-cond@v1
id: reporter
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "github-pr-review"
if_false: "github-check"
- name: set up python environment
uses: actions/[email protected]
with:
python-version: "3.10"
- name: set up dependencies
run: pip install flake8 black[jupyter] flake8-docstrings flake8-simplify flake8-unused-arguments flake8-quotes
- name: flake8
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workdir: .github/
reporter: ${{ steps.reporter.outputs.value }}
flake8_args: "--max-line-length 128 --ignore Q000,D100,D101,D102,D103,D104,D105,D106,D107"
- name: black
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workdir: .github/
reporter: ${{ steps.reporter.outputs.value }}
workflows:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: true
- name: install action-validator with asdf
uses: asdf-vm/actions/install@v3
with:
tool_versions: |
action-validator 0.5.4
- name: check workflows syntax
id: lint
run: |
set -x
export TMP_OUT=$(mktemp)
find .github/workflows -type f \( -iname \*.yaml -o -iname \*.yml \) -print0 \
| xargs -0 -I {} action-validator --verbose {} > $TMP_OUT
echo "WORKFLOW_LINT=$(cat $TMP_OUT | awk -v ORS='\\n' 1)"
cat $TMP_OUT >> "$GITHUB_STEP_SUMMARY"
echo "WORKFLOW_LINT=$(cat $TMP_OUT | awk -v ORS='\\n' 1)" >> "$GITHUB_OUTPUT"
- name: comment on issue
uses: actions/[email protected]
if: ${{ github.event_name == 'pull_request' }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '${{ steps.lint.outputs.WORKFLOW_LINT }}'
})
nbs-github-actions:
name: Launch scripts on test-data
uses: ./.github/workflows/github_actions_scripts.yaml
secrets: inherit
create-and-delete-vm:
name: Create and delete VM
uses: ./.github/workflows/create_and_delete_vm.yaml
needs:
- set-env
with:
nebius: ${{ needs.set-env.outputs.nebius }}
allow_downgrade: ${{ needs.set-env.outputs.allow_downgrade }}
large_tests: ${{ needs.set-env.outputs.large_tests }}
secrets: inherit