forked from mtusi2026/mtusi2026lab2
84 lines
2.2 KiB
YAML
84 lines
2.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main, solution/bvt2303-plastinin]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ci-${{ github.repository }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout exact commit
|
|
run: |
|
|
git init .
|
|
git remote add origin https://gitea.privcloud.tech/${{ github.repository }}.git
|
|
git fetch --depth=1 origin ${{ github.sha }}
|
|
git checkout --detach FETCH_HEAD
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: false
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Check contract
|
|
run: make check
|
|
|
|
- name: Validate OpenAPI
|
|
run: |
|
|
python -m venv .venv
|
|
.venv/bin/python -m pip install -r requirements-dev.txt
|
|
make validate PYTHON=.venv/bin/python
|
|
|
|
- name: Check formatting
|
|
run: test -z "$(gofmt -l cmd internal migrations)"
|
|
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@v6.5.2
|
|
with:
|
|
version: v2.13.2
|
|
args: --timeout=5m
|
|
|
|
- name: Unit tests and build
|
|
run: |
|
|
go test -race ./...
|
|
go build ./cmd/messenger
|
|
|
|
- name: Prepare local stack
|
|
run: |
|
|
cp lab2.env.example .env
|
|
./scripts/init-local-secrets.sh
|
|
docker compose config --quiet
|
|
docker compose up -d --build --wait --wait-timeout 120
|
|
|
|
- name: Public smoke
|
|
run: make test
|
|
|
|
- name: PostgreSQL and Valkey integration tests
|
|
run: docker compose --profile tests run --rm --build tests
|
|
|
|
- name: Dependency outage recovery
|
|
run: go run ./cmd/dependencycheck
|
|
|
|
- name: Persistence test
|
|
run: make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
|
|
|
- name: Container logs
|
|
if: failure()
|
|
run: if [ -f .env ]; then docker compose logs --no-color --tail=200; fi
|
|
|
|
- name: Stop local stack
|
|
if: always()
|
|
run: if [ -f .env ]; then docker compose --profile tests down -v --remove-orphans; fi
|