Skip to content

Commit e9667a9

Browse files
committed
Added CI pipeline
1 parent e7be138 commit e9667a9

1 file changed

Lines changed: 51 additions & 2 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 51 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,27 @@ 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: Extract version tag
77+
id: vars
78+
run: |
79+
if [[ "${{ github.event_name }}" == "release" ]]; then
80+
echo "tags=ghcr.io/${{ github.repository }}:${{ github.ref_name }},ghcr.io/${{ github.repository }}:latest" >> $GITHUB_OUTPUT
81+
else
82+
echo "tags=ghcr.io/${{ github.repository }}:${{ github.sha }}" >> $GITHUB_OUTPUT
83+
fi
84+
85+
- name: Build and push Docker image
86+
uses: docker/build-push-action@v6
87+
with:
88+
context: .
89+
file: docker/Dockerfile
90+
push: true
91+
tags: ${{ steps.vars.outputs.tags }}

0 commit comments

Comments
 (0)