Skip to content

Commit d3aac49

Browse files
committed
Optimizing the pr-check-tests workflow with proper caching and modern actions
1 parent 98eb880 commit d3aac49

1 file changed

Lines changed: 101 additions & 54 deletions

File tree

.github/workflows/pr-check-tests.yml

Lines changed: 101 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,86 +5,133 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
811
jobs:
12+
# LINTING
913
linting:
10-
runs-on: ubuntu-latest
1114
name: Linting
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
1218
steps:
13-
- name: Checkout Code
14-
uses: actions/checkout@v3
19+
- name: Checkout code
20+
uses: actions/checkout@v4
1521

16-
- name: Set up Node.js
17-
uses: actions/setup-node@v3
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
1824
with:
19-
node-version: "18"
25+
node-version: 18
26+
cache: "npm"
27+
cache-dependency-path: frontend/package-lock.json
28+
29+
# Frontend Dependencies Installation
2030

21-
- name: Install Dependencies
22-
run: |
23-
cd frontend
24-
npm install
25-
cd ..
26-
cd backend
27-
pip install pre-commit ruff black
28-
cd ..
29-
- name: Run Linters
31+
- name: Install frontend dependencies
32+
working-directory: frontend
33+
run: npm ci
34+
35+
- name: Run frontend linters
36+
working-directory: frontend
3037
run: |
31-
cd frontend/
3238
npm run lint:check
3339
npm run format:check
34-
cd ..
35-
cd backend/
36-
pre-commit run --config ../.pre-commit-config.yaml --all-files || exit 1
37-
cd ..
38-
cd frontend/src-tauri/
39-
cargo fmt -- --check
40-
41-
# Frontend Test Job
42-
frontend:
43-
runs-on: ubuntu-latest
44-
name: Frontend Tests
45-
steps:
46-
- name: Checkout Code
47-
uses: actions/checkout@v3
4840
49-
- name: Set up Node.js
50-
uses: actions/setup-node@v3
41+
- name: Setup Python
42+
uses: actions/setup-python@v5
5143
with:
52-
node-version: "18"
44+
python-version: "3.11"
45+
cache: "pip"
46+
47+
- name: Install backend lint tools
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install pre-commit ruff black
5351
54-
- name: Install Dependencies & Run Tests
52+
- name: Run backend linters
53+
working-directory: backend
5554
run: |
56-
cd frontend
57-
npm install
58-
npm test
55+
pre-commit run --config ../.pre-commit-config.yaml --all-files
56+
57+
# RUST
58+
59+
- name: Setup Rust
60+
uses: dtolnay/rust-toolchain@stable
5961

60-
# Backend Test Job
61-
backend:
62+
- name: Run cargo fmt
63+
working-directory: frontend/src-tauri
64+
run: cargo fmt -- --check
65+
66+
# FRONTEND TESTS
67+
frontend-tests:
68+
name: Frontend Tests
6269
runs-on: ubuntu-latest
70+
timeout-minutes: 15
71+
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: 18
80+
cache: "npm"
81+
cache-dependency-path: frontend/package-lock.json
82+
83+
- name: Install dependencies
84+
working-directory: frontend
85+
run: npm ci
86+
87+
- name: Run frontend tests
88+
working-directory: frontend
89+
run: npm test -- --ci
90+
91+
# BACKEND TESTS
92+
backend-tests:
6393
name: Backend Tests
94+
runs-on: ubuntu-latest
95+
timeout-minutes: 20
96+
97+
strategy:
98+
fail-fast: false
99+
matrix:
100+
python-version: ["3.11"]
101+
64102
steps:
65-
- name: Checkout Code
66-
uses: actions/checkout@v3
103+
- name: Checkout code
104+
uses: actions/checkout@v4
67105

68-
- name: Set up Python
69-
uses: actions/setup-python@v4
106+
- name: Setup Python
107+
uses: actions/setup-python@v5
70108
with:
71-
python-version: "3.11"
109+
python-version: ${{ matrix.python-version }}
110+
cache: "pip"
72111

73-
- name: Build check(Main backend)
112+
- name: Install backend dependencies
113+
working-directory: backend
74114
run: |
75-
cd backend
76115
python -m pip install --upgrade pip
77116
pip install -r requirements.txt
78-
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
79117
80-
- name: Build check(Sync Microservice)
118+
- name: Build check (Main Backend)
119+
working-directory: backend
81120
run: |
82-
cd sync-microservice
83-
pip install -r requirements.txt
84-
pyinstaller main.py --name PictoPy_Sync_Microservice --onedir --distpath dist
121+
pyinstaller main.py \
122+
--name PictoPy_Server \
123+
--onedir \
124+
--distpath dist
85125
86-
- name: Run Tests
126+
- name: Build check (Sync Microservice)
127+
working-directory: sync-microservice
87128
run: |
88-
cd backend
89-
pytest
129+
pip install -r requirements.txt
130+
pyinstaller main.py \
131+
--name PictoPy_Sync_Microservice \
132+
--onedir \
133+
--distpath dist
90134
135+
- name: Run backend tests
136+
working-directory: backend
137+
run: pytest -v

0 commit comments

Comments
 (0)