Skip to content

Commit c30868b

Browse files
committed
Bonus Task
1 parent 3410a21 commit c30868b

4 files changed

Lines changed: 96 additions & 3 deletions

File tree

.github/workflows/go-ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches: [ master, lab03 ]
6+
paths:
7+
- 'app_go/**'
8+
- '.github/workflows/go-ci.yml'
9+
pull_request:
10+
branches: [ master ]
11+
paths:
12+
- 'app_go/**'
13+
14+
jobs:
15+
test:
16+
name: Test Go Application
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.23'
27+
cache-dependency-path: app_go/go.sum
28+
29+
- name: Install dependencies
30+
working-directory: ./app_go
31+
run: go mod download
32+
33+
- name: Run gofmt
34+
working-directory: ./app_go
35+
run: |
36+
gofmt -l .
37+
test -z "$(gofmt -l .)"
38+
39+
- name: Run go vet
40+
working-directory: ./app_go
41+
run: go vet ./...
42+
43+
- name: Run tests
44+
working-directory: ./app_go
45+
run: go test -v ./...
46+
47+
docker:
48+
name: Build and Push Docker Image
49+
runs-on: ubuntu-latest
50+
needs: test
51+
if: github.event_name == 'push'
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Log in to Docker Hub
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_TOKEN }}
65+
66+
- name: Extract metadata
67+
id: meta
68+
uses: docker/metadata-action@v5
69+
with:
70+
images: ${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service-go
71+
tags: |
72+
type=raw,value=latest
73+
type=sha,prefix={{date 'YYYY.MM.DD'}}-
74+
75+
- name: Build and push
76+
uses: docker/build-push-action@v6
77+
with:
78+
context: ./app_go
79+
push: true
80+
tags: ${{ steps.meta.outputs.tags }}
81+
labels: ${{ steps.meta.outputs.labels }}
82+
cache-from: type=gha
83+
cache-to: type=gha,mode=max

.github/workflows/python-ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ jobs:
3939
pip install ruff
4040
ruff check . --output-format=github || true
4141
42-
- name: Run tests
42+
- name: Run tests with coverage
4343
working-directory: ./app_python
4444
run: |
45-
pytest -v --cov=. --cov-report=term --cov-report=xml
45+
pytest -v --cov=. --cov-report=term --cov-report=lcov
46+
47+
- name: Upload coverage to Coveralls
48+
uses: coverallsapp/github-action@v2
49+
with:
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
path-to-lcov: ./app_python/coverage.lcov
52+
flag-name: python
53+
parallel: false
4654

4755
docker:
4856
name: Build and Push Docker Image

app_python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Python CI](https://github.com/3llimi/DevOps-Core-Course/actions/workflows/python-ci.yml/badge.svg)](https://github.com/3llimi/DevOps-Core-Course/actions/workflows/python-ci.yml)
2+
[![Coverage Status](https://coveralls.io/repos/github/3llimi/DevOps-Core-Course/badge.svg)](https://coveralls.io/github/3llimi/DevOps-Core-Course)
23
# DevOps Info Service
34

45
A Python web service that provides system and runtime information. Built with FastAPI for the DevOps Core Course.

app_python/requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
pytest==8.3.4
33
pytest-cov==6.0.0
44
httpx==0.28.1
5-
ruff==0.8.4
5+
ruff==0.8.4
6+
coveralls==4.0.1

0 commit comments

Comments
 (0)