Skip to content

Commit 9ebedb3

Browse files
committed
Add GitHub Actions CI with backend tests and frontend lint/build
- Add orchestrating workflow (pr.yml) with path-based change detection using dorny/paths-filter, concurrency cancellation, and ci-complete sentinel job for branch protection - Add backend test workflow: builds Docker image, runs pytest on test_web_basic.py, verifies module imports - Add frontend lint workflow: prettier --check, eslint, vite build - Add pytest to dockerfile - Add lint:check and format:check scripts to frontend/package.json - Fix 6 pre-existing ESLint errors: - Remove unused defineComponent import (ViewCampaign.vue) - Remove unused downloadReviews function (RoundInfo.vue) - Remove unused props assignment (RoundView.vue) - Add eslint-disable for multi-word component name (Vote.vue) - Remove unused getCommonsImageUrl imports (VoteEdit.vue, VoteRanking.vue) - Remove pdb.set_trace() calls from test_web_basic.py (would hang CI) - Run prettier --write across frontend/src/ to establish baseline - Delete dead .travis.yml (Python 2.7, Travis CI abandoned)
1 parent e624c1b commit 9ebedb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4539
-4288
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint & Build Frontend (Vue)
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint-and-build:
8+
name: Lint & Build
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 10
11+
defaults:
12+
run:
13+
working-directory: ./frontend
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Cache npm dependencies
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.npm
27+
key: npm-${{ runner.os }}-${{ hashFiles('frontend/package-lock.json') }}
28+
restore-keys: npm-${{ runner.os }}-
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Check formatting (Prettier)
34+
run: npx prettier --check src/
35+
36+
- name: Lint (ESLint)
37+
run: npx eslint src/ --ext .vue,.js,.jsx,.cjs,.mjs
38+
39+
- name: Build
40+
run: npm run build

.github/workflows/pr.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
changes:
19+
name: Detect Changes
20+
runs-on: ubuntu-latest
21+
outputs:
22+
backend: ${{ steps.filter.outputs.backend }}
23+
frontend: ${{ steps.filter.outputs.frontend }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dorny/paths-filter@v3
27+
id: filter
28+
with:
29+
filters: |
30+
backend:
31+
- 'montage/**'
32+
- 'requirements.txt'
33+
- 'requirements.in'
34+
- 'setup.py'
35+
- 'dockerfile'
36+
frontend:
37+
- 'frontend/**'
38+
39+
test-backend:
40+
name: Test Backend (Python)
41+
needs: changes
42+
if: needs.changes.outputs.backend == 'true'
43+
uses: ./.github/workflows/test-backend.yml
44+
45+
lint-frontend:
46+
name: Lint & Build Frontend (Vue)
47+
needs: changes
48+
if: needs.changes.outputs.frontend == 'true'
49+
uses: ./.github/workflows/lint-frontend.yml
50+
51+
ci-complete:
52+
name: CI Complete
53+
runs-on: ubuntu-latest
54+
needs: [test-backend, lint-frontend]
55+
if: always()
56+
steps:
57+
- name: Check job results
58+
run: |
59+
for job in test-backend lint-frontend; do
60+
case "$job" in
61+
test-backend) result="${{ needs.test-backend.result }}" ;;
62+
lint-frontend) result="${{ needs.lint-frontend.result }}" ;;
63+
esac
64+
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
65+
echo "::error::Job $job failed with result: $result"
66+
exit 1
67+
fi
68+
done
69+
echo "All CI jobs passed or were correctly skipped."

.github/workflows/test-backend.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test Backend (Python)
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
name: Run Backend Tests
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 10
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Build Docker image
16+
run: docker build -t montage-ci -f dockerfile .
17+
18+
- name: Run pytest
19+
run: |
20+
docker run --rm \
21+
-v "${{ github.workspace }}":/app \
22+
-e PYTHONPATH=/app \
23+
montage-ci \
24+
python -m pytest montage/tests/test_web_basic.py \
25+
-v --tb=short -p no:cacheprovider
26+
27+
- name: Verify backend imports
28+
run: |
29+
docker run --rm \
30+
-v "${{ github.workspace }}":/app \
31+
-e PYTHONPATH=/app \
32+
montage-ci \
33+
python -c "from montage import loaders, rdb, admin_endpoints, juror_endpoints; print('All modules import OK')"

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ COPY requirements.txt .
88

99
RUN pip install --upgrade pip
1010
RUN pip install -r requirements.txt
11+
RUN pip install pytest
1112

1213
EXPOSE 5000

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"preview": "vite preview",
1010
"toolforge:build": "export SHELL=/bin/sh && npm run build && cp -r dist/* ../montage/static",
1111
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
12-
"format": "prettier --write src/"
12+
"format": "prettier --write src/",
13+
"lint:check": "eslint src/ --ext .vue,.js,.jsx,.cjs,.mjs",
14+
"format:check": "prettier --check src/"
1315
},
1416
"dependencies": {
1517
"@wikimedia/codex": "^1.14.0",

frontend/src/App.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<template>
22
<app-header />
3-
<main class="main-container" >
3+
<main class="main-container">
44
<router-view />
55
</main>
6-
<app-footer />
6+
<app-footer />
77
</template>
88

99
<script setup>
1010
import { RouterView } from 'vue-router'
1111
import AppHeader from '@/components/AppHeader.vue'
1212
import AppFooter from '@/components/AppFooter.vue'
13-
1413
</script>
1514

1615
<style scoped>

frontend/src/assets/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060

6161
.cdx-select-vue__handle {
6262
min-width: 120px;
63-
}
63+
}

frontend/src/components/AppFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{ $t('montage-about') }}</a
1111
>
1212
<a href="https://github.com/hatnote/montage" class="footer-link" target="_blank">
13-
{{ $t('montage-source-code') }}
13+
{{ $t('montage-source-code') }}
1414
</a>
1515
</div>
1616
<div class="footer-right">

frontend/src/components/AppHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<span>{{ userStore.user.username }}</span>
99
</div>
1010
<cdx-button action="destructive" weight="quiet" @click="userStore.logout">
11-
{{ $t('montage-login-logout') }}
11+
{{ $t('montage-login-logout') }}
1212
</cdx-button>
1313
</div>
1414
<cdx-select

0 commit comments

Comments
 (0)