Skip to content

Commit 61d0e65

Browse files
Merge pull request #3 from AlessiaFrunza/feature/ci-pipeline
Added CI pipeline
2 parents e7be138 + 434d3b1 commit 61d0e65

1 file changed

Lines changed: 55 additions & 2 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: CI/CD Pipeline
2-
32
on:
43
release:
54
types: [ published ]
@@ -8,7 +7,6 @@ on:
87
- '**'
98
tags-ignore:
109
- '**'
11-
1210
jobs:
1311
lint:
1412
name: Lint Code
@@ -19,6 +17,19 @@ jobs:
1917
- name: Checkout code
2018
uses: actions/checkout@v4
2119

20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install ruff
29+
30+
- name: Lint with Ruff
31+
run: ruff check app/ tests/
32+
2233
test:
2334
name: Run Tests
2435
runs-on: ubuntu-latest
@@ -28,6 +39,20 @@ jobs:
2839
- name: Checkout code
2940
uses: actions/checkout@v4
3041

42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: '3.11'
46+
47+
- name: Install dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install -r requirements.txt
51+
pip install pytest pytest-cov httpx
52+
53+
- name: Run tests with coverage
54+
run: pytest --cov=app --cov-report=term-missing --cov-fail-under=80
55+
3156
build:
3257
name: Build Docker Image
3358
runs-on: ubuntu-latest
@@ -40,3 +65,31 @@ jobs:
4065
steps:
4166
- name: Checkout code
4267
uses: actions/checkout@v4
68+
69+
- name: Log in to GitHub Container Registry
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Lowercase repository name
77+
id: repo
78+
run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
79+
80+
- name: Extract version tag
81+
id: vars
82+
run: |
83+
if [[ "${{ github.event_name }}" == "release" ]]; then
84+
echo "tags=ghcr.io/${{ steps.repo.outputs.name }}:${{ github.ref_name }},ghcr.io/${{ steps.repo.outputs.name }}:latest" >> $GITHUB_OUTPUT
85+
else
86+
echo "tags=ghcr.io/${{ steps.repo.outputs.name }}:${{ github.sha }}" >> $GITHUB_OUTPUT
87+
fi
88+
89+
- name: Build and push Docker image
90+
uses: docker/build-push-action@v6
91+
with:
92+
context: .
93+
file: docker/Dockerfile
94+
push: true
95+
tags: ${{ steps.vars.outputs.tags }}

0 commit comments

Comments
 (0)