From 022ae1daef98dd7dafb00188f021ccfa3e4a0659 Mon Sep 17 00:00:00 2001 From: "Archimedes (Paperclip)" Date: Tue, 24 Nov 2026 12:22:25 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20Gitea=20Actions=20f=C3=BCr=20Lint,=20Test?= =?UTF-8?q?s=20und=20Image-Build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ci.yml führt bei PRs und Pushes auf main die Upstream-Skripte aus (npm ci inkl. Build, lint:dry, stylelint:dry, test). image.yml baut das unveränderte Upstream-Dockerfile bei Pushes auf main und Tags v* und pusht nach git.morlana.online/f.weber/homebrewery-oidc. .github/ bleibt unverändert. Closes #4 Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 60 ++++++++++++++++++++++++ .gitea/workflows/image.yml | 94 ++++++++++++++++++++++++++++++++++++++ FORK.md | 32 +++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/image.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 00000000..ef634bba --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,60 @@ +# Fork-CI für Pull Requests und main (Gitea #4, FLW-82). +# Nutzt ausschließlich die Upstream-npm-Skripte; die Upstream-CI unter .github/ und +# .circleci/ bleibt unverändert (Merges aus naturalcrit/homebrewery konfliktfrei). +# Läuft auf jedem Gitea act_runner mit dem Label ubuntu-latest. +name: CI + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + # package.json verlangt Node >=26.4.0 und npm >=10.8 <12; das Lockfile zieht das + # npm-Paket "node" ^26.13.0. Lokal verifiziert mit Node 26.13.1 / npm 11.20.0. + NODE_VERSION: 26.13.1 + +jobs: + app: + name: App (npm ci + Build, ESLint, Stylelint, Jest) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-node@v7 + with: + node-version: ${{ env.NODE_VERSION }} + package-manager-cache: false + + # npm-Cache nur mit Repo-Variable CI_CACHE=true: Ist der Cache-Server des + # act_runner aus dem Job-Container nicht erreichbar, kostet jeder + # Cache-Schritt mehrere Minuten Timeout. + - uses: actions/cache@v6 + if: vars.CI_CACHE == 'true' + with: + path: ~/.npm + key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + restore-keys: npm-${{ runner.os }}- + + # postinstall führt "npm run build" (vite build) aus, prüft also auch den Build. + - name: Abhängigkeiten und Build (npm ci) + run: npm ci --no-audit --no-fund + + # Upstream hat derzeit nur Warnungen (keine Fehler); Warnungen brechen nicht ab. + - name: ESLint (npm run lint:dry) + run: npm run lint:dry + + - name: Stylelint (npm run stylelint:dry) + run: npm run stylelint:dry + + # Kommt ohne MongoDB aus (Mongoose wird in den Specs gemockt). + - name: Jest (npm test) + run: npm test diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml new file mode 100644 index 00000000..6505e97d --- /dev/null +++ b/.gitea/workflows/image.yml @@ -0,0 +1,94 @@ +# Container-Image bauen und in die Gitea-Container-Registry pushen (Gitea #4, FLW-82). +# Baut das unveränderte Upstream-Dockerfile nach +# git.morlana.online/f.weber/homebrewery-oidc +# Tags: +# push auf main -> :main, :sha-<7 Zeichen> +# Tag vX.Y.Z -> :vX.Y.Z, :latest, :sha-<7 Zeichen> (Vorabversionen wie v1.0.0-rc.1 ohne :latest) +# Login: Repo-Secret REGISTRY_TOKEN (PAT mit write:package). Fehlt es, wird der +# automatische GITEA_TOKEN versucht. Details in FORK.md, Abschnitt "CI and container image". +name: Image + +on: + push: + branches: [main] + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: read + packages: write + +concurrency: + group: image-${{ github.ref }} + cancel-in-progress: false + +env: + REGISTRY: git.morlana.online + IMAGE: git.morlana.online/f.weber/homebrewery-oidc + +jobs: + image: + name: Image bauen und pushen + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v7 + + - name: Tags und Labels bestimmen + id: meta + env: + REF: ${{ github.ref }} + REF_NAME: ${{ github.ref_name }} + SHA: ${{ github.sha }} + SOURCE: ${{ github.server_url }}/${{ github.repository }} + run: | + names="sha-${SHA:0:7}" + version="sha-${SHA:0:7}" + case "$REF" in + refs/heads/main) + names="${names} main" + version="main" + ;; + refs/tags/v*) + names="${names} ${REF_NAME}" + version="${REF_NAME}" + if [[ "$REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + names="${names} latest" + fi + ;; + esac + tags="" + for n in $names; do tags="${tags:+${tags},}${IMAGE}:${n}"; done + { + echo "tags=${tags}" + echo "labels<> "$GITHUB_OUTPUT" + echo "Tags: ${names}" + + - uses: docker/setup-buildx-action@v4 + + - uses: docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.REGISTRY_TOKEN != '' && (vars.REGISTRY_USER || github.repository_owner) || github.actor }} + password: ${{ secrets.REGISTRY_TOKEN || secrets.GITEA_TOKEN }} + + - name: Image bauen und pushen + uses: docker/build-push-action@v7 + with: + context: . + # Repo-Variable IMAGE_PLATFORMS; Ziel ist linux/amd64. + platforms: ${{ vars.IMAGE_PLATFORMS || 'linux/amd64' }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + provenance: false + cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max,image-manifest=true,oci-mediatypes=true,ignore-error=true diff --git a/FORK.md b/FORK.md index a13f39b5..6f646b91 100644 --- a/FORK.md +++ b/FORK.md @@ -68,6 +68,38 @@ stop for review instead of force-pushing. Never merge `main` into `upstream`. Use a feature branch from current `main` and a reviewed PR for fork changes. Keep credentials in the environment; never put tokens in remote URLs or files. +## CI and container image + +Fork-owned Gitea Actions workflows live in `.gitea/workflows/`. The upstream CI in +`.github/` and `.circleci/` stays untouched (it does not run on Gitea) so upstream +merges remain conflict-free. + +| Workflow | Trigger | What it does | +| --- | --- | --- | +| `ci.yml` | pull requests, push to `main` | `npm ci` (includes the Vite build via `postinstall`), `npm run lint:dry`, `npm run stylelint:dry`, `npm test`. Upstream currently has ESLint warnings but no errors; warnings do not fail the job. The tests need no MongoDB. | +| `image.yml` | push to `main`, tags `v*`, manual | builds the unchanged upstream `Dockerfile` and pushes `git.morlana.online/f.weber/homebrewery-oidc` | + +Image tags: + +| Event | Tags | +| --- | --- | +| push to `main` | `main`, `sha-<7 chars>` | +| tag `vX.Y.Z` | `vX.Y.Z`, `latest`, `sha-<7 chars>` (pre-release tags such as `v1.0.0-rc.1` get no `latest`) | + +`buildcache` is the BuildKit layer cache, not a runnable image. + +Runner and repository settings (repository → Settings → Actions): + +- **Runner:** jobs use `runs-on: ubuntu-latest` (public runner, as in the DnD Character Manager). +- **Secret `REGISTRY_TOKEN`:** access token of an account with write access to the + `f.weber` packages, scope `write:package`. Without it the workflow falls back to the + automatic `GITEA_TOKEN`, which may not be allowed to push packages. +- **Variable `REGISTRY_USER`** (optional): owner of `REGISTRY_TOKEN`; defaults to the repository owner. +- **Variable `CI_CACHE`** (optional): `true` enables the npm cache. Leave it unset until the + act_runner cache server is reachable from job containers; otherwise every cache step + waits for a connection timeout. +- **Variable `IMAGE_PLATFORMS`** (optional): defaults to `linux/amd64`. + ## Fork roadmap These are planned features, not functionality delivered by the initial import: