Skip to content

Commit 14b3c44

Browse files
authored
Fix Python/JS/styles tests/linting on CI (#5586)
* fix: revert responses package to 0.22.0 * fix: run `test-python` job when requirements.txt changes * fix: run `lint-python` job when requirements.txt changes * fix: formatting * fix: run `test-js` and `lint-js` when package.json and yarn.lock change * fix: pass `lint-scss` check * fix: style lint * fix: better names for filters * fix: check filters properly this time * fix: move the path check at job level * fix: add vitest config to checked files * chore: format eslint config to trigger js checks * fix: yarn.lock * fix: add other pr dependencies
1 parent 9f0a790 commit 14b3c44

21 files changed

Lines changed: 54 additions & 88 deletions

File tree

.github/workflows/pr.yml

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -74,91 +74,100 @@ jobs:
7474
docker run --network="host" -v .:/app cypress/base:22.18.0 \
7575
bash "-c" "cd /app && npx cypress install && yarn run test-e2e"
7676
77+
changes:
78+
runs-on: ubuntu-latest
79+
permissions:
80+
pull-requests: read
81+
outputs:
82+
py: ${{ steps.filter.outputs.py }}
83+
js: ${{ steps.filter.outputs.js }}
84+
scss: ${{ steps.filter.outputs.scss }}
85+
steps:
86+
- uses: dorny/paths-filter@v3
87+
id: filter
88+
with:
89+
filters: |
90+
py:
91+
- '**/*.py'
92+
- 'requirements.txt'
93+
- 'templates/**/*'
94+
js:
95+
- '**/*.js'
96+
- '**/*.ts'
97+
- '**/*.jsx'
98+
- '**/*.tsx'
99+
- 'package.json'
100+
- 'yarn.lock'
101+
- 'eslint.config.mjs'
102+
- 'vitest.config.js'
103+
- 'vite.config.js'
104+
- 'tsconfig.json'
105+
- 'babel.config.json'
106+
scss:
107+
- '**/*.scss'
108+
- '.stylelintrc'
109+
- 'package.json'
110+
- 'yarn.lock'
111+
77112
lint-python:
113+
needs: changes
114+
if: ${{ needs.changes.outputs.py == 'true' }}
78115
runs-on: ubuntu-latest
79116
permissions:
80117
contents: read
81118
steps:
82119
- name: Checkout
83120
uses: actions/checkout@v6
84-
- uses: dorny/paths-filter@v3
85-
id: filter
86-
with:
87-
filters: |
88-
py:
89-
- '**/*.py'
90121

91122
- name: Install dotrun
92-
if: ${{ steps.filter.outputs.py == 'true' }}
93123
run: sudo pip3 install dotrun
94124

95125
- name: Install dependencies
96-
if: ${{ steps.filter.outputs.py == 'true' }}
97126
run: |
98127
sudo chmod -R 777 .
99128
dotrun install
100129
101130
- name: Build assets
102-
if: ${{ steps.filter.outputs.py == 'true' }}
103131
run: dotrun build
104132

105133
- name: Lint python
106-
if: ${{ steps.filter.outputs.py == 'true' }}
107134
run: dotrun lint-python
108135

109136
lint-scss:
137+
needs: changes
138+
if: ${{ needs.changes.outputs.scss == 'true' }}
110139
runs-on: ubuntu-latest
111140
permissions:
112141
contents: read
113142
steps:
114143
- name: Checkout
115144
uses: actions/checkout@v6
116145

117-
- uses: dorny/paths-filter@v3
118-
id: filter
119-
with:
120-
filters: |
121-
scss:
122-
- '**/*.scss'
123-
124146
- name: Install SCSS dependencies
125-
if: ${{ steps.filter.outputs.scss == 'true' }}
126147
run: yarn install --immutable
127148

128149
- name: Lint SCSS
129-
if: ${{ steps.filter.outputs.scss == 'true' }}
130150
run: yarn lint-scss
131151

132152
lint-js:
153+
needs: changes
154+
if: ${{ needs.changes.outputs.js == 'true' }}
133155
runs-on: ubuntu-latest
134156
permissions:
135157
contents: read
136158
steps:
137159
- name: Checkout
138160
uses: actions/checkout@v6
139161

140-
- uses: dorny/paths-filter@v3
141-
id: filter
142-
with:
143-
filters: |
144-
js:
145-
- '**/*.js'
146-
ts:
147-
- '**/*.ts'
148-
jsx:
149-
- '**/*.jsx'
150-
tsx:
151-
- '**/*.tsx'
152-
153162
- name: Install JS dependencies
154-
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
155163
run: yarn install --immutable
156164

157165
- name: Lint JS
158-
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
159166
run: yarn lint-js
160167

161168
test-python:
169+
needs: changes
170+
if: ${{ needs.changes.outputs.py == 'true' }}
162171
runs-on: ubuntu-latest
163172
permissions:
164173
pull-requests: write
@@ -167,76 +176,49 @@ jobs:
167176
steps:
168177
- uses: actions/checkout@v6
169178

170-
- uses: dorny/paths-filter@v3
171-
id: filter
172-
with:
173-
filters: |
174-
py:
175-
- '**/*.py'
176-
177179
- name: Install dotrun
178-
if: ${{ steps.filter.outputs.py == 'true' }}
179180
run: sudo pip3 install dotrun
180181

181182
- name: Install dependencies
182-
if: ${{ steps.filter.outputs.py == 'true' }}
183183
run: |
184184
sudo chmod -R 777 .
185185
dotrun install
186186
187187
- name: Install dependencies
188-
if: ${{ steps.filter.outputs.py == 'true' }}
189188
run: sudo pip3 install coverage
190189

191190
- name: Build resources
192-
if: ${{ steps.filter.outputs.py == 'true' }}
193191
run: dotrun build
194192

195193
- name: Run python tests with coverage
196-
if: ${{ steps.filter.outputs.py == 'true' }}
197194
run: dotrun test-python-job
198195

199196
- name: Upload coverage to Codecov
200-
if: ${{ steps.filter.outputs.py == 'true' }}
201197
uses: codecov/codecov-action@v5
202198
with:
203199
flags: python
204200

205201
test-js:
202+
needs: changes
203+
if: ${{ needs.changes.outputs.js == 'true' }}
206204
runs-on: ubuntu-latest
207205
permissions:
208206
contents: read
209207
steps:
210208
- uses: actions/checkout@v6
211209

212-
- uses: dorny/paths-filter@v3
213-
id: filter
214-
with:
215-
filters: |
216-
js:
217-
- '**/*.js'
218-
ts:
219-
- '**/*.ts'
220-
jsx:
221-
- '**/*.jsx'
222-
tsx:
223-
- '**/*.tsx'
224-
225210
- uses: actions/setup-node@v6
226211
with:
227212
node-version: 24
228213

229214
- name: Install dependencies
230-
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
231215
run: yarn install --immutable
232216

233217
- name: Run JS tests with coverage
234-
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
235218
run: |
236219
yarn test-js --coverage
237220
238221
- name: Upload coverage to Codecov
239-
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
240222
uses: codecov/codecov-action@v5
241223
with:
242224
flags: javascript

.stylelintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scss/no-global-function-names": null,
1717
"declaration-block-no-redundant-longhand-properties": null,
1818
"selector-not-notation": null,
19+
"color-function-alias-notation": null,
1920
"at-rule-no-unknown": [
2021
true,
2122
{

eslint.config.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import vitest from '@vitest/eslint-plugin'
1+
import vitest from "@vitest/eslint-plugin";
22
import react from "eslint-plugin-react";
33
import prettier from "eslint-plugin-prettier";
44
import jsxA11Y from "eslint-plugin-jsx-a11y";
@@ -48,7 +48,7 @@ export default [
4848
Object.entries({
4949
...globals.browser,
5050
...globals.node,
51-
...vitest.environments.env.globals
51+
...vitest.environments.env.globals,
5252
}).map(([key, value]) => [key.trim(), value]),
5353
),
5454
parser: babelParser,
@@ -103,4 +103,3 @@ export default [
103103
},
104104
},
105105
];
106-

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pycountry==24.6.1
2121
pymacaroons==0.13.0
2222
python-dateutil==2.9.0.post0
2323
requests==2.32.5
24-
responses==0.25.8
24+
responses==0.22.0
2525
ruamel.yaml==0.18.5
2626
vcrpy-unittest==0.1.7
2727
user-agents==2.2.0

static/sass/_snapcraft_p-release-details-row.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
}
99

1010
&__progress {
11+
column-gap: 0.5rem;
1112
display: grid;
1213
flex: 1;
1314
font-weight: 400;
14-
grid-column-gap: 0.5rem;
1515
grid-template-columns: auto 8rem;
1616
}
1717

tests/api/test_marketo_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# Local modules
99
import webapp.api.marketo as marketo_api
1010

11-
1211
responses.mock.assert_all_requests_are_fired = True
1312

1413

tests/endpoints/tests_models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from webapp.helpers import api_publisher_session
99
from tests.endpoints.endpoint_testing import TestModelServiceEndpoints
1010

11-
1211
candid = CandidClient(api_publisher_session)
1312

1413

webapp/admin/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from webapp.decorators import login_required, exchange_required
1111
from webapp.helpers import api_publisher_session, api_session
1212

13-
1413
dashboard = Dashboard(api_session)
1514
publisher_gateway = PublisherGW("snap", api_publisher_session)
1615
device_gateway = DeviceGW("snap", api_session)

webapp/endpoints/builds.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import flask
66
from canonicalwebteam.store_api.dashboard import Dashboard
77

8-
98
# Local
109
from webapp.helpers import api_publisher_session, launchpad
1110
from webapp.api.github import GitHub

webapp/endpoints/invites.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from webapp.decorators import login_required, exchange_required
1212
from webapp.helpers import api_session
1313

14-
1514
dashboard = Dashboard(api_session)
1615

1716
invites = flask.Blueprint(

0 commit comments

Comments
 (0)