Files
server-scripts/.gitea/workflows/haven-notify.yaml
2026-07-23 07:39:16 -03:00

113 lines
3.4 KiB
YAML

name: Haven Notify Build and Deploy
on:
push:
branches:
- main
paths:
- "haven-notify/**"
- ".gitea/workflows/haven-notify.yaml"
pull_request:
branches:
- main
paths:
- "haven-notify/**"
- ".gitea/workflows/haven-notify.yaml"
workflow_dispatch: {}
env:
IMAGE: git.ivanch.me/ivanch/haven-notify
jobs:
test:
name: Test Haven Notify
runs-on: runner-full-amd64
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: haven-notify/go.mod
cache-dependency-path: haven-notify/go.sum
- name: Verify formatting
working-directory: haven-notify
run: |
unformatted="$(gofmt -l *.go)"
if [ -n "$unformatted" ]; then
echo "The following Go files need formatting:"
echo "$unformatted"
exit 1
fi
- name: Verify Docker access
run: docker info
- name: Run static analysis
working-directory: haven-notify
run: go vet ./...
- name: Run race tests and collect coverage
working-directory: haven-notify
run: go test -race -shuffle=on -count=1 -covermode=atomic -coverprofile=coverage.out ./...
- name: Enforce coverage threshold
working-directory: haven-notify
run: |
coverage="$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%", "", $3); print $3}')"
echo "Statement coverage: ${coverage}%"
awk -v coverage="$coverage" 'BEGIN { exit !(coverage + 0 >= 90) }'
- name: Run fuzz smoke test
working-directory: haven-notify
run: go test -run=^$ -fuzz=FuzzErrorNotificationHandler -fuzztime=10s .
- name: Run container end-to-end tests
working-directory: haven-notify
run: go test -tags=e2e -run '^TestContainerE2E$' -count=1 -timeout=5m -v .
build:
name: Build Haven Notify Image
runs-on: runner-slim
needs: test
if: ${{ (gitea.event_name == 'push' || gitea.event_name == 'workflow_dispatch') && gitea.ref == 'refs/heads/main' }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build and Push Multi-Arch Image
uses: https://git.ivanch.me/ivanch/pipeline-actions/build-and-push@main
with:
image: ${{ env.IMAGE }}
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
ssh_key: ${{ secrets.SSH_KEY_DOCKERBUILD }}
build_context: haven-notify
build-pr:
name: Build Haven Notify Image (PR)
runs-on: runner-full-amd64
needs: test
if: ${{ gitea.event_name == 'pull_request' }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build Docker image
run: docker build --pull --tag haven-notify:pr-${{ gitea.sha }} haven-notify
deploy:
name: Deploy Haven Notify (internal)
runs-on: runner-slim
needs: build
if: ${{ (gitea.event_name == 'push' || gitea.event_name == 'workflow_dispatch') && gitea.ref == 'refs/heads/main' }}
steps:
- name: Rollout Restart Haven Notify
uses: https://git.ivanch.me/ivanch/pipeline-actions/deploy-restart@main
with:
kube_config: ${{ secrets.KUBE_CONFIG }}
deployment_name: haven-notify
namespace: infra