Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Go CI (Lab03 Bonus)

on:
push:
branches: [lab03, main, master]
paths:
- "lab3c/app_go/**"
- ".github/workflows/go-ci.yml"
pull_request:
branches: [lab03, main, master]
paths:
- "lab3c/app_go/**"
- ".github/workflows/go-ci.yml"

concurrency:
group: go-ci-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
name: Lint and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: lab3c/app_go
args: --timeout=5m

- name: Run tests
working-directory: lab3c/app_go
run: go test ./...

docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set version (CalVer)
run: echo "VERSION=$(date +%Y.%m.%d)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./lab3c/app_go
file: ./lab3c/app_go/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-go:${{ env.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-go:latest
cache-from: type=gha
cache-to: type=gha,mode=max
109 changes: 109 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Python CI (Lab03)

on:
push:
branches: [lab3, main, master]
paths:
- "lab3c/app_python/**"
- ".github/workflows/python-ci.yml"
pull_request:
branches: [lab3, main, master]
paths:
- "lab3c/app_python/**"
- ".github/workflows/python-ci.yml"

concurrency:
group: python-ci-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
name: Lint and Test
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
strategy:
fail-fast: true
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
lab3c/app_python/requirements.txt
lab3c/app_python/requirements-dev.txt

- name: Install dependencies
working-directory: lab3c/app_python
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt

- name: Lint (ruff)
working-directory: lab3c/app_python
run: ruff check .

- name: Run tests with coverage
working-directory: lab3c/app_python
run: pytest --cov=app --cov-report=xml --cov-report=term

- name: Upload coverage to Codecov
if: ${{ env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v4
with:
files: lab3c/app_python/coverage.xml
token: ${{ env.CODECOV_TOKEN }}

- name: Install Snyk CLI
if: ${{ env.SNYK_TOKEN != '' }}
run: npm install -g snyk

- name: Snyk scan
if: ${{ env.SNYK_TOKEN != '' }}
working-directory: lab3c/app_python
run: snyk test --file=requirements.txt --package-manager=pip
env:
SNYK_TOKEN: ${{ env.SNYK_TOKEN }}

docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set version (CalVer)
run: echo "VERSION=$(date +%Y.%m.%d)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./lab3c/app_python
file: ./lab3c/app_python/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-python:${{ env.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-python:latest
cache-from: type=gha
cache-to: type=gha,mode=max
7 changes: 7 additions & 0 deletions lab2c/app_go/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.exe
*.log
.git/
.gitignore
.idea/
.vscode/
docs/
21 changes: 21 additions & 0 deletions lab2c/app_go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.22 AS builder

WORKDIR /src

COPY go.mod ./
RUN go mod download

COPY main.go ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o devops-info

FROM gcr.io/distroless/static-debian12:nonroot

WORKDIR /app
COPY --from=builder /src/devops-info /app/devops-info

ENV HOST=0.0.0.0 \
PORT=5000

EXPOSE 5000

ENTRYPOINT ["/app/devops-info"]
41 changes: 41 additions & 0 deletions lab2c/app_go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# DevOps Info Service (Go)

## Overview
Compiled-language version of the DevOps info service. It exposes the same two endpoints as the Python app and keeps the JSON response structure consistent.

## Prerequisites
- Go 1.22+ installed

## Build and Run
Run directly:
```bash
go run main.go
```

Build a binary:
```bash
go build -o devops-info
./devops-info
```

Windows build/run:
```bash
go build -o devops-info.exe
.\devops-info.exe
```

Custom config examples:
```bash
PORT=8080 go run main.go
HOST=127.0.0.1 PORT=3000 go run main.go
```

## API Endpoints
- `GET /` - Service and system information
- `GET /health` - Health check

## Configuration
| Variable | Default | Description |
| --- | --- | --- |
| `HOST` | `0.0.0.0` | Bind address for the server |
| `PORT` | `5000` | Port to listen on |
Loading
Loading