mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2025-12-27 11:06:35 +00:00
ci: add Makefile-driven CI with unit, integration and e2e tests
- add GitHub Actions CI workflow using Makefile targets exclusively - run unit, integration and e2e tests via `make test` - publish Docker image to GHCR on SemVer tags - force-update `stable` git tag after successful release - add integration test for seed CLI (CSV upsert behavior) - extend Makefile with test-unit and test-integration targets https://chatgpt.com/share/694ee54f-b814-800f-a714-e87563e538b7
This commit is contained in:
91
.github/workflows/ci.yml
vendored
Normal file
91
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
name: CI (make tests, stable, publish)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
tags: ["v*.*.*"] # SemVer tags like v1.2.3
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: write # push/update 'stable' tag
|
||||
packages: write # push to GHCR
|
||||
|
||||
env:
|
||||
IMAGE_NAME: baudolo
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_REPO: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: make test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Show docker info
|
||||
run: |
|
||||
docker version
|
||||
docker info
|
||||
|
||||
- name: Run all tests via Makefile
|
||||
run: |
|
||||
make test
|
||||
|
||||
- name: Upload E2E artifacts (always)
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-artifacts
|
||||
path: artifacts
|
||||
if-no-files-found: ignore
|
||||
|
||||
stable_and_publish:
|
||||
name: Mark stable + publish image (SemVer tags only)
|
||||
needs: [test]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
steps:
|
||||
- name: Checkout (full history for tags)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Derive version from tag
|
||||
id: ver
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/tags/}" # v1.2.3
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Mark 'stable' git tag (force update)
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -f stable "${GITHUB_SHA}"
|
||||
git push -f origin stable
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build image (Makefile)
|
||||
run: |
|
||||
make build
|
||||
|
||||
- name: Tag image for registry
|
||||
run: |
|
||||
# local image built by Makefile is: baudolo:local
|
||||
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:${{ steps.ver.outputs.tag }}"
|
||||
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:stable"
|
||||
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:sha-${GITHUB_SHA::12}"
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
docker push "${REGISTRY}/${IMAGE_REPO}:${{ steps.ver.outputs.tag }}"
|
||||
docker push "${REGISTRY}/${IMAGE_REPO}:stable"
|
||||
docker push "${REGISTRY}/${IMAGE_REPO}:sha-${GITHUB_SHA::12}"
|
||||
Reference in New Issue
Block a user