-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (96 loc) · 2.68 KB
/
quality.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
name: Quality
on:
push:
branches:
- main
workflow_dispatch:
inputs:
push:
description: Save the lock file?
default: false
type: boolean
tag:
description: Tag to push
required: false
type: string
codescan:
description: Perform code scan?
default: true
type: boolean
workflow_call:
inputs:
push:
description: Save the lock file?
default: true
type: boolean
tag:
description: Tag to push
required: false
type: string
codescan:
description: Perform code scan?
default: true
type: boolean
secrets:
PYPI_API_TOKEN:
description: PyPi token
required: true
GH_APP_KEY:
description: GitHub App private key
required: true
jobs:
quality:
name: Quality
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Setup
id: setup
uses: duplocloud/duploctl/.github/actions/setup@main
with:
ref: ${{ inputs.tag }}
install: "--editable ."
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_KEY }}
- name: Freeze Requirements
run: pip freeze --exclude-editable > requirements.txt
- name: Install Test Dependencies
run: pip install .[test]
- name: Pip Audit
uses: pypa/[email protected]
with:
inputs: requirements.txt
# do linting
# stop the build if there are Python syntax errors or undefined names
# ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
- name: Lint with ruff
run: ruff check ./src
# Now do codequality checks with CodeQL
- name: Initialize CodeQL
# if codescan is true or it is the default branch
if: inputs.codescan || github.ref == 'refs/heads/main'
uses: github/codeql-action/init@v3
with:
languages: python
build-mode: none
# token: ${{ steps.setup.outputs.token }}
- name: Perform CodeQL Analysis
id: analysis
if: inputs.codescan || github.ref == 'refs/heads/main'
uses: github/codeql-action/analyze@v3
with:
category: "/language:python"
# token: ${{ steps.setup.outputs.token }}
- name: Save Lock File
uses: actions/upload-artifact@v4
if: inputs.push
with:
name: requirements.lock
path: requirements.txt
- name: Save Sarif File
if: inputs.push && (inputs.codescan || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v4
with:
name: sarif
path: ${{ steps.analysis.outputs.sarif-output }}