-
Notifications
You must be signed in to change notification settings - Fork 2
262 lines (225 loc) · 8.41 KB
/
workflow.ci.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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
---
name: CI
on:
push:
branches:
- main
pull_request:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main
paths:
- "**.py"
- ".pre-commit-config.yaml"
- ".pre-commit-hooks.yaml"
- "pyproject.toml"
- ".github/workflows/workflow.ci.yml"
- "!docs/**"
# Allow one concurrent
concurrency:
group: ${{ format('{0}-{1}', github.event_name, github.ref) }}
cancel-in-progress: true
permissions:
contents: read
jobs:
gh-diag:
name: Run GitHub diagnostic
uses: ./.github/workflows/reuse.ghdiag.yml
dependency-review:
if: ${{ github.repository_visibility == 'public' && (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
name: Dependency Review
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Run Dependency Review
uses: actions/dependency-review-action@v3
with:
comment-summary-in-pr: true
codeql-analyze:
if: ${{ github.repository_visibility == 'public' && (github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft && !contains(github.event.head_commit.message, 'skip-codeql'))) }}
name: CodeQL Analyze
runs-on: ubuntu-latest
permissions:
actions: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout Repo
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
upload: false
output: codeql-results
- name: Upload Sarif Artifact
uses: actions/upload-artifact@v3
with:
name: Analyses Results (SARIF)
path: codeql-results
if-no-files-found: warn
codeql-results:
if: ${{ github.repository_visibility == 'public' && (github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft && !contains(github.event.head_commit.message, 'skip-codeql'))) }}
name: CodeQL Results
needs:
- codeql-analyze
runs-on: ubuntu-latest
permissions:
actions: read
security-events: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Download Sarifs
uses: actions/download-artifact@v3
with:
path: codeql-results
- name: Upload Results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: codeql-results
wait-for-processing: true
lint:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version-file: .python-version
- name: Install dependencies
run: pip install .[dev]
- name: Run Ruff
run: ruff check --config pyproject.toml --no-fix .
test-build:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
name: Test (build)
runs-on: ubuntu-latest
needs:
- lint
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install . .[build]
- name: Build wheel
run: python -m pip wheel --no-deps -w dist .
- name: Install test build
# using a wildcard as filename on Windows requires a bash shell
shell: bash
run: python -m pip install dist/*.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@v3
with:
name: test-build
path: dist/*.whl
# vhs-demo:
# if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
# name: VHS demo
# # needs:
# # - test-build
# runs-on: ubuntu-latest
# permissions:
# contents: write
# env:
# OPENAI_API_KEY: ${{ secrets.TEST__OPENAI_API_KEY }}
# OPENAI_API_BASE: ${{ secrets.TEST__OPENAI_API_BASE }}
# OPENAI_API_TYPE: ${{ vars.TEST__OPENAI_API_TYPE }}
# OPENAI_MODEL: ${{ vars.TEST__OPENAI_MODEL }}
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v3
# - name: Init VHS
# uses: charmbracelet/vhs-action@v1
# with:
# path: demo/init.tape
# - name: Prepare VHS demo repo
# run: |
# rm -f init.gif
# demo/vhs_demo_repo.sh ci
# - name: Commit VHS demo
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
# commit_message: Update VHS demo
# file_pattern: "*.gif *.ascii"
test-install:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
name: Test (build)
needs:
- test-build
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel artifact
uses: actions/download-artifact@v3
with:
name: test-build
path: dist
- name: Install test
# using a wildcard as filename on Windows requires a bash shell
shell: bash
run: python -m pip install dist/*.whl
- name: Install dependencies
run: pip install .[dev]
- name: Run test repo
run: python .github/scripts/test_repo.py
env:
TEST__OPENAI_API_KEY: ${{ secrets.TEST__OPENAI_API_KEY }}
TEST__OPENAI_API_BASE: ${{ secrets.TEST__OPENAI_API_BASE }}
TEST__OPENAI_API_TYPE: ${{ vars.TEST__OPENAI_API_TYPE }}
TEST__OPENAI_MODEL: ${{ vars.TEST__OPENAI_MODEL }}