-
Notifications
You must be signed in to change notification settings - Fork 1.3k
115 lines (102 loc) · 3.53 KB
/
quality.yml
File metadata and controls
115 lines (102 loc) · 3.53 KB
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
name: Code Quality
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request_target'
permissions:
contents: read
pull-requests: read
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.10.9
toxenv: py310,style,coverage-ci
- python-version: 3.11
toxenv: py311,style,coverage-ci
- python-version: 3.12
toxenv: py312,style,coverage-ci
- python-version: 3.13
toxenv: py313,style,coverage-ci
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c
with:
python-version: ${{ matrix.python-version }}
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: '20'
- name: Install dependencies
run: |
pip install --upgrade virtualenv
pip install tox
npm --prefix plugins/magma install
npm --prefix plugins/magma run build
- name: Run tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: SonarQube Scan
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) }}
uses: SonarSource/sonarqube-scan-action@v6.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonar_fork_pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork }}
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout base repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 0
- name: Checkout PR HEAD (fork)
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
submodules: recursive
- name: Detect Sonar base dir
id: detect
run: |
set -euo pipefail
if [ -f pr/caldera/sonar-project.properties ]; then
echo "base=pr/caldera" >> "$GITHUB_OUTPUT"
elif [ -f pr/sonar-project.properties ]; then
echo "base=pr" >> "$GITHUB_OUTPUT"
else
echo "base=pr" >> "$GITHUB_OUTPUT"
fi
- name: SonarQube Scan (fork PR)
uses: SonarSource/sonarqube-scan-action@v6.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectBaseDir: ${{ steps.detect.outputs.base }}
args: |
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}