Skip to content

Commit ff41dec

Browse files
authored
Merge pull request #22 from AdvancedSoftwareEngineeringGroup3/Ma-Golden-server-ci
Create backend-ci.yml
2 parents 8c6eb8c + b1e4251 commit ff41dec

2 files changed

Lines changed: 75 additions & 2 deletions

File tree

.github/workflows/backend-ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Backend CI
5+
6+
on:
7+
push:
8+
branches: [ "develop", "main" ]
9+
pull_request:
10+
branches: [ "develop" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
lint:
17+
name: Lint Python Code (PEP8)
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.10"
28+
29+
- name: Install dependencies
30+
run: |
31+
cd server
32+
python -m pip install --upgrade pip
33+
pip install flake8 black
34+
- name: Run flake8 (Linting)
35+
run: |
36+
cd server
37+
flake8 src/ tests/
38+
- name: Run Black (Formatting Check)
39+
run: |
40+
cd server
41+
black --check --diff src/ tests/
42+
test:
43+
name: Run Backend Tests
44+
runs-on: ubuntu-latest
45+
needs: lint # Ensures linting passes before running tests
46+
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v3
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: "3.10"
55+
56+
- name: Install dependencies
57+
run: |
58+
cd server
59+
python -m pip install --upgrade pip
60+
pip install -r requirements.txt
61+
62+
- name: Create .env file in CI
63+
run: |
64+
cd server
65+
touch .env
66+
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env
67+
echo "SUPABASE_URL=${{ secrets.SUPABASE_KEY }}" >> .env
68+
echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> .env
69+
70+
- name: Run Tests
71+
run: |
72+
cd server
73+
pytest tests/ --ignore=tests/test_database_connection.py

server/src/luas_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def get(self, stop):
6868
while True:
6969
stop = str(
7070
input(
71-
'Enter stop code to see live arrivals and departures,'
72-
'or "exit" to leave: '
71+
"Enter stop code to see live arrivals and departures,"
72+
' or "exit" to leave: '
7373
)
7474
)
7575
if stop == "exit":

0 commit comments

Comments
 (0)