Skip to content

Commit 24bb21d

Browse files
ci(backend): run biome for static files too DEV-862 (#6084)
### 💭 Notes So far biome was run only on frontend file changes although it checked also backend javascript static files. That led to situations where a green PR can be merged but it would fail `main` where all workflows are run. No more :) ### 👀 Preview steps 1. add a change to a `.js` file outside `jsapp/` folder 4. 🔴 [on main] notice that biome isn't run on CI 5. 🟢 [on PR] notice that biome is run on CI Co-authored-by: Leszek Pietrzak <[email protected]>
1 parent 7d2dd72 commit 24bb21d

File tree

8 files changed

+77
-5
lines changed

8 files changed

+77
-5
lines changed

.github/filters.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ darker:
1212
- 'pyproject.toml' # rules
1313
- '.github/workflows/darker.yml' # ci
1414

15+
biome:
16+
- '*.(js|jsx|ts|tsx)' # js or ts files.
17+
- 'biome.jsonc' # configuration.
18+
- '{package*.json,patches/*.patch}' # npm + postinstall
19+
- '.github/workflows/biome.yml' # ci
20+
1521
pytest:
1622
- '{kpi,kobo,hub}/**/*.!(md)' # backend
1723
- 'dependencies/**/*.!(md)' # pip
@@ -22,7 +28,7 @@ npm-test:
2228
- '{jsapp,test,webpack,static,scripts}/**/*.!(md|py|sh|bash)' # frontend
2329
- '{package*.json,patches/*.patch,scripts/copy_fonts.py}' # npm + postinstall
2430
- '{tsconfig.json,.swcrc,.babelrc*,.browserslistrc}' # compilers
25-
- '{.editorconfig,.stylelint*,.eslint*,coffeelint*,biome.jsonc}' # linters
31+
- '{.editorconfig,.stylelint*,.eslint*,coffeelint*}' # linters
2632
- '.gitignore' # (can affect tools)
2733
- '.github/workflows/{npm-test,chromatic}.yml' # ci
2834

.github/workflows/biome.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Biome is a seperate workflow because it should be run both on frontend source files and backend static files.
2+
3+
name: biome
4+
5+
on: workflow_call
6+
jobs:
7+
build:
8+
runs-on: ubuntu-24.04
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: '20.18.1' # version that's pinned in Dockerfile for kpi release
15+
check-latest: true # download newer semver match if available
16+
cache: 'npm'
17+
18+
- name: Identify resolved node version
19+
id: resolved-node-version
20+
run: echo "NODE_VERSION=$(node --version)" >> "$GITHUB_OUTPUT"
21+
22+
# Cache: Use cache for node_modules
23+
# Keyed on os, node version, package-lock, and patches
24+
- uses: actions/cache@v4
25+
name: Check for cached node_modules
26+
id: cache-nodemodules
27+
env:
28+
cache-name: cache-node-modules
29+
with:
30+
path: node_modules
31+
key: ${{ runner.os }}-build-${{ env.cache-name }}-node-v${{ steps.resolved-node-version.outputs.NODE_VERSION }}-${{ hashFiles('**/package-lock.json', 'patches/**/*.patch') }}
32+
33+
# Cache hit: If the cache key matches,
34+
# /node_modules/ will have been copied from a previous run.
35+
# (Run the post-install step, `npm run copy-fonts`)
36+
- name: Run copy-fonts (if using cached node_modules)
37+
if: steps.cache-nodemodules.outputs.cache-hit == 'true'
38+
run: npm run copy-fonts
39+
40+
# Cache miss: If node_modules has not been cached,
41+
# `npm install`
42+
# (This includes `npm run copy-fonts` as post-install step)
43+
- name: Install JavaScript dependencies (npm install)
44+
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
45+
run: npm install
46+
47+
# Check for Biome formatting errors
48+
- name: Check Biome formatting, import order and linter
49+
run: npm run lint:biome

.github/workflows/ci-main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
darker:
99
uses: ./.github/workflows/darker.yml
1010

11+
biome:
12+
uses: ./.github/workflows/biome.yml
13+
1114
pytest:
1215
uses: ./.github/workflows/pytest.yml
1316

@@ -19,10 +22,12 @@ jobs:
1922
failure() &&
2023
(needs.darker.result == 'failure' || needs.darker.result == 'timed_out' ||
2124
needs.pytest.result == 'failure' || needs.pytest.result == 'timed_out' ||
25+
needs.biome.result == 'failure' || needs.biome.result == 'timed_out' ||
2226
needs.npm-test.result == 'failure' || needs.npm-test.result == 'timed_out')
2327
needs:
2428
- darker
2529
- pytest
30+
- biome
2631
- npm-test
2732
uses: './.github/workflows/zulip.yml'
2833
secrets: inherit

.github/workflows/ci-pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
outputs:
1717
all: ${{ steps.filter.outputs.all }}
1818
darker: ${{ steps.filter.outputs.darker }}
19+
biome: ${{ steps.filter.outputs.biome }}
1920
pytest: ${{ steps.filter.outputs.pytest }}
2021
npm-test: ${{ steps.filter.outputs.npm-test }}
2122

@@ -24,6 +25,11 @@ jobs:
2425
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.darker == 'true'
2526
uses: ./.github/workflows/darker.yml
2627

28+
biome:
29+
needs: changes
30+
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.biome == 'true'
31+
uses: ./.github/workflows/biome.yml
32+
2733
pytest:
2834
needs: changes
2935
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.pytest == 'true'

.github/workflows/npm-test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ jobs:
6565
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
6666
run: npm install
6767

68-
# Check for Biome formatting errors
69-
- name: Check Biome formatting, import order and linter
70-
run: npm run lint:biome
71-
7268
# Check for TypeScript errors
7369
- name: Check TypeScript
7470
run: npm run lint:types

.github/workflows/release-2-stabilize.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
outputs:
1919
all: ${{ steps.filter.outputs.all }}
2020
darker: ${{ steps.filter.outputs.darker }}
21+
biome: ${{ steps.filter.outputs.biome }}
2122
pytest: ${{ steps.filter.outputs.pytest }}
2223
npm-test: ${{ steps.filter.outputs.npm-test }}
2324

@@ -26,6 +27,11 @@ jobs:
2627
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.darker == 'true'
2728
uses: ./.github/workflows/darker.yml
2829

30+
biome:
31+
needs: changes
32+
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.biome == 'true'
33+
uses: ./.github/workflows/biome.yml
34+
2935
pytest:
3036
needs: changes
3137
if: needs.changes.outputs.all == 'true' || needs.changes.outputs.pytest == 'true'

.github/workflows/release-3-tag.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
darker:
1313
uses: ./.github/workflows/darker.yml
1414

15+
biome:
16+
uses: ./.github/workflows/biome.yml
17+
1518
pytest:
1619
uses: ./.github/workflows/pytest.yml
1720

biome.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"node_modules/**",
66
"jsapp/compiled/**",
77
"*.css",
8+
// Ignore minified committed JS files.
89
"*.min.js",
910
"*-min.js",
1011
"bootstrap*.js",

0 commit comments

Comments
 (0)