Skip to content

Commit 156e3fb

Browse files
committed
ci: add CI pipeline workflow (lint, build, test)
1 parent 4f066a2 commit 156e3fb

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

.github/workflows/ci-pipeline.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
env:
10+
CI: true
11+
NODE_VERSION: '20'
12+
PYTHON_VERSION: '3.12'
13+
14+
jobs:
15+
lint_python:
16+
name: Lint Python Files
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
cache: 'pip'
28+
cache-dependency-path: server/requirements.txt
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install flake8
34+
35+
- name: Print working directory
36+
run: pwd
37+
38+
- name: Run Linter
39+
run: |
40+
pwd
41+
# Find all Python files recursively and run flake8 on them
42+
find . -name "*.py" -exec flake8 {} +
43+
echo "Linted all the python files successfully"
44+
45+
lint_js:
46+
name: Lint JavaScript Files
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Checkout Repository
51+
uses: actions/checkout@v4
52+
53+
- name: Install Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: ${{ env.NODE_VERSION }}
57+
58+
- name: Install JSHint
59+
run: npm install jshint --global
60+
61+
- name: Run Linter
62+
run: |
63+
# Find all JavaScript files and run JSHint on them
64+
find ./server/database -name "*.js" -exec jshint {} +
65+
echo "Linted all the js files successfully"
66+
67+
build_frontend:
68+
name: Build and Test Frontend
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- name: Checkout Repository
73+
uses: actions/checkout@v4
74+
75+
- name: Setup Node.js
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: ${{ env.NODE_VERSION }}
79+
cache: 'npm'
80+
cache-dependency-path: server/frontend/package-lock.json
81+
82+
- name: Install dependencies
83+
working-directory: ./server/frontend
84+
run: npm ci
85+
86+
- name: Run tests
87+
working-directory: ./server/frontend
88+
run: npm test -- --watchAll=false --passWithNoTests
89+
continue-on-error: true
90+
91+
- name: Build application
92+
working-directory: ./server/frontend
93+
run: npm run build
94+
95+
build_database:
96+
name: Build and Test Database Service
97+
runs-on: ubuntu-latest
98+
99+
steps:
100+
- name: Checkout Repository
101+
uses: actions/checkout@v4
102+
103+
- name: Setup Node.js
104+
uses: actions/setup-node@v4
105+
with:
106+
node-version: ${{ env.NODE_VERSION }}
107+
cache: 'npm'
108+
cache-dependency-path: server/database/package-lock.json
109+
110+
- name: Install dependencies
111+
working-directory: ./server/database
112+
run: npm ci
113+
114+
- name: Run tests (if available)
115+
working-directory: ./server/database
116+
run: npm test || echo "No tests specified yet"
117+
118+
test_python:
119+
name: Test Python Django App
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- name: Checkout Repository
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Python
127+
uses: actions/setup-python@v5
128+
with:
129+
python-version: ${{ env.PYTHON_VERSION }}
130+
cache: 'pip'
131+
cache-dependency-path: server/requirements.txt
132+
133+
- name: Install dependencies
134+
working-directory: ./server
135+
run: |
136+
python -m pip install --upgrade pip
137+
pip install -r requirements.txt
138+
139+
- name: Run Django tests
140+
working-directory: ./server
141+
run: python manage.py test
142+
continue-on-error: true

0 commit comments

Comments
 (0)