Skip to content

Commit b5048ae

Browse files
committed
Enhance test coverage and CI workflow configuration
1 parent a3ff660 commit b5048ae

4 files changed

Lines changed: 56 additions & 32 deletions

File tree

.github/workflows/gke-cd.yml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,17 @@
1-
name: Test FNS API and deploy to Cloud Run
1+
name: Deploy to Cloud Run
22

33
on:
44
push:
55
branches:
66
- master
7-
- feature/*
8-
- develop
9-
pull_request:
10-
branches:
11-
- master
12-
- feature/*
13-
- develop
147

158
jobs:
16-
test:
17-
name: Run Backend Tests
18-
runs-on: ubuntu-latest
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v2
22-
23-
- name: Set up Python 3.9
24-
uses: actions/setup-python@v2
25-
with:
26-
python-version: 3.9
27-
28-
- name: Install dependencies
29-
run: pip install -r requirements.txt
30-
31-
- name: Run tests
32-
run: python -m unittest tests/test_backend.py
33-
349
build-and-push-image:
3510
name: Build and Push Docker Image
3611
runs-on: ubuntu-latest
37-
needs: test
38-
if: github.ref == 'refs/heads/master' # Condition: Only run on master branch
3912
steps:
4013
- name: Checkout code
41-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
4215

4316
- name: Google Cloud Auth
4417
uses: google-github-actions/auth@v2
@@ -67,10 +40,9 @@ jobs:
6740
name: Deploy to Cloud Run
6841
runs-on: ubuntu-latest
6942
needs: build-and-push-image
70-
if: github.ref == 'refs/heads/master' # Condition: Only run on master branch
7143
steps:
72-
- name: Checkout code (again, if needed)
73-
uses: actions/checkout@v2
44+
- name: Checkout code
45+
uses: actions/checkout@v3
7446

7547
- name: Google Cloud Auth
7648
uses: google-github-actions/auth@v2
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Test Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- feature/*
8+
- develop
9+
pull_request:
10+
branches:
11+
- master
12+
- feature/*
13+
- develop
14+
15+
jobs:
16+
test-coverage:
17+
name: Run Tests with Coverage
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python 3.9
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: 3.9
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements.txt
32+
33+
- name: Run tests with coverage
34+
run: |
35+
pytest --cov=backend --cov-report=xml --cov-report=html tests/
36+
37+
- name: Upload coverage to Codecov
38+
uses: codecov/codecov-action@v3
39+
with:
40+
file: ./coverage.xml
41+
fail_ci_if_error: false
42+
43+
- name: Deploy coverage report to GitHub Pages
44+
uses: JamesIves/github-pages-deploy-action@v4
45+
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
46+
with:
47+
folder: htmlcov
48+
branch: gh-pages
49+
clean: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[![Static Badge](https://img.shields.io/badge/version-1.1.0-blue)](https://github.com/MirkoZETA/FlexNetSim-API)
44
![Static Badge](https://img.shields.io/badge/language-python-blue)
55
[![Static Badge](https://img.shields.io/badge/licese-MIT-green)](https://github.com/MirkoZETA/FlexNetSim-API/blob/master/LICENSE)
6+
[![Test Coverage](https://github.com/MirkoZETA/FlexNetSim-API/actions/workflows/test-coverage.yml/badge.svg)](https://github.com/MirkoZETA/FlexNetSim-API/actions/workflows/test-coverage.yml)
7+
[![Coverage Report](https://img.shields.io/badge/coverage-report-blue)](https://mirkoZETA.github.io/FlexNetSim-API/)
68

79
A lightweight API for running optical network simulations with [Flex Net Sim C++](https://gitlab.com/DaniloBorquez/flex-net-sim).
810

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
flask
22
gunicorn
33
pytest
4+
pytest-cov
45
flask-testing

0 commit comments

Comments
 (0)