Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c93896051 | |||
| 5859189910 | |||
| 607a0f6360 | |||
| c19f0b79ec | |||
| 41b1119f21 | |||
| 0b683a7166 | |||
| 6988488e04 | |||
| 14b8280241 | |||
| 30cd407018 | |||
| 3de301aa92 | |||
| 4dcbb11f20 | |||
| 9da134bdaf | |||
| 752bbb332f | |||
| 45404dc002 | |||
| 5a00763d8f | |||
| 4a79ce9d17 | |||
| 9d402578bd | |||
| 63ce59e604 | |||
| a566998180 | |||
| 1239cc5673 | |||
| 20a6099969 | |||
| c7141fc28f | |||
| c87e585918 | |||
| 8f4725e23f | |||
| f35c24857f | |||
| c233ef8975 | |||
| f32b345f58 | |||
| 0740dbf815 | |||
| 0efd7db43a | |||
| 705af709c4 | |||
| 1d396c8278 | |||
| 16b25970ff | |||
| 52601104b0 | |||
| 8312cff6ec | |||
| 8c11306f2b | |||
| 2ae96a5355 | |||
| fc76234379 | |||
| 0fa291f103 | |||
| db47775249 | |||
| 1be3b5b434 | |||
| 544ec4afe4 | |||
| 815c39c6a7 | |||
| ccec73e40a | |||
| 26394e5a54 | |||
| 8d9bd42f6c | |||
| 69d574955c | |||
| cbd63b7581 | |||
| ae84083eae | |||
| 2d3fd96768 | |||
| 95f0aca47e | |||
| b6c4d5ae4f | |||
| 5e011b3993 | |||
| 5f14554b1f | |||
| 416939fb82 | |||
| ccf833d698 | |||
| 5848f47c0e | |||
| b32a97ed9b | |||
| e853e22d1d | |||
| 83e35f5324 | |||
| 95257c17b9 | |||
| b51adf3410 | |||
| daa5dc58ed | |||
| 5ac7516672 | |||
| 622e8acdc5 | |||
| 6e26281fea |
@@ -2,13 +2,14 @@ name: CI Feature
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
|
- feature/docker-kuntoon
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
load-config:
|
load-config:
|
||||||
name: Load example-gitea-env.conf to pipeline env
|
name: Load example-gitea-env.conf to pipeline env
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
config_path: .gitea/workflows/example-gitea-env.conf
|
config_path: .gitea/workflows/example-gitea-env.conf
|
||||||
@@ -16,7 +17,7 @@ jobs:
|
|||||||
bats:
|
bats:
|
||||||
name: Bats tests
|
name: Bats tests
|
||||||
needs: [load-config]
|
needs: [load-config]
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-bats-tests.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-bats-tests.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
@@ -25,7 +26,7 @@ jobs:
|
|||||||
cucumber:
|
cucumber:
|
||||||
name: Cucumber tests
|
name: Cucumber tests
|
||||||
needs: [load-config]
|
needs: [load-config]
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-cucumber-tests.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-cucumber-tests.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
@@ -35,7 +36,7 @@ jobs:
|
|||||||
name: Report Summary
|
name: Report Summary
|
||||||
needs: [load-config, bats, cucumber]
|
needs: [load-config, bats, cucumber]
|
||||||
if: always()
|
if: always()
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-report-summary.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-report-summary.yml@feature/docker-kuntoon
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
suites: bats cucumber
|
suites: bats cucumber
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ name: CI Main
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- feature/docker-kuntoon
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
load-config:
|
load-config:
|
||||||
name: Load example-gitea-env.conf to pipeline env
|
name: Load example-gitea-env.conf to pipeline env
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
config_path: .gitea/workflows/example-gitea-env.conf
|
config_path: .gitea/workflows/example-gitea-env.conf
|
||||||
@@ -16,7 +17,7 @@ jobs:
|
|||||||
check-version:
|
check-version:
|
||||||
name: Check existing artifact
|
name: Check existing artifact
|
||||||
needs: [load-config]
|
needs: [load-config]
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/check-version.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/check-version.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
@@ -25,7 +26,7 @@ jobs:
|
|||||||
name: Bats tests
|
name: Bats tests
|
||||||
needs: [load-config, check-version]
|
needs: [load-config, check-version]
|
||||||
if: needs.check-version.outputs.artifact_exists != 'true'
|
if: needs.check-version.outputs.artifact_exists != 'true'
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-bats-tests.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-bats-tests.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
@@ -35,27 +36,27 @@ jobs:
|
|||||||
name: Cucumber tests
|
name: Cucumber tests
|
||||||
needs: [load-config, check-version]
|
needs: [load-config, check-version]
|
||||||
if: needs.check-version.outputs.artifact_exists != 'true'
|
if: needs.check-version.outputs.artifact_exists != 'true'
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-cucumber-tests.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-cucumber-tests.yml@feature/docker-kuntoon
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
cucumber-node-image: node:22
|
cucumber-node-image: node:22
|
||||||
|
|
||||||
build-push:
|
|
||||||
name: Build & Push Docker
|
|
||||||
needs: [load-config, check-version, bats, cucumber]
|
|
||||||
if: needs.check-version.outputs.artifact_exists != 'true'
|
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/docker-build-push.yml@main
|
|
||||||
secrets: inherit
|
|
||||||
with:
|
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
|
||||||
version: ${{ needs.check-version.outputs.version }}
|
|
||||||
|
|
||||||
report-summary:
|
report-summary:
|
||||||
name: Report Summary
|
name: Report Summary
|
||||||
needs: [load-config, bats, cucumber]
|
needs: [load-config, bats, cucumber]
|
||||||
if: always()
|
if: always()
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/example-report-summary.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/example-report-summary.yml@feature/docker-kuntoon
|
||||||
with:
|
with:
|
||||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
suites: bats cucumber
|
suites: bats cucumber
|
||||||
|
|
||||||
|
build-push:
|
||||||
|
name: Build & Push Docker
|
||||||
|
needs: [load-config, check-version, bats, cucumber]
|
||||||
|
if: needs.check-version.outputs.artifact_exists != 'true'
|
||||||
|
uses: niko/gitea-ci-library/.gitea/workflows/docker-build-push.yml@feature/docker-kuntoon
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||||
|
version: ${{ needs.check-version.outputs.version }}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ Provider-repossa (`gitea-ci-library`) kansioiden omistajuus on seuraava:
|
|||||||
|
|
||||||
| Kansio / Tiedosto | Omistaja | Tyyppi |
|
| Kansio / Tiedosto | Omistaja | Tyyppi |
|
||||||
|-------------------|----------|--------|
|
|-------------------|----------|--------|
|
||||||
| `.gitea/workflows/` | Sekoitettu | Providerin reusable workflowt + consumerin example-pipeline |
|
| `.gitea/workflows/` | Sekoitettu | Providerin reusable workflowt + consumerin pipeline |
|
||||||
| `.gitea/workflows/example-gitea-env.conf` | Consumer | KEY=VALUE config |
|
| `.gitea/workflows/gitea-env.conf` | Consumer | KEY=VALUE config |
|
||||||
| `.gitea/scripts/` | Consumer | Consumer-skriptit |
|
| `.gitea/scripts/` | Consumer | Consumer-skriptit |
|
||||||
| `scripts/` | Provider | Providerin sisäiset työkalut |
|
| `scripts/` | Provider | Providerin sisäiset työkalut |
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ uses: org/repo/scripts/workflow.yml@branch
|
|||||||
```
|
```
|
||||||
|
|
||||||
Tästä syystä providerin reusable workflowt (`config-provider.yml`,
|
Tästä syystä providerin reusable workflowt (`config-provider.yml`,
|
||||||
`check-version.yml`, `docker-build-push.yml`) ovat samassa `.gitea/workflows/`-kansiossa
|
`build-feature.yml`) ovat samassa `.gitea/workflows/`-kansiossa consumerin
|
||||||
consumerin esimerkkipipeline-tiedostojen (`example-*`) kanssa.
|
pipeline-tiedostojen (`ci.yml`) kanssa.
|
||||||
|
|
||||||
Erottelu on nimessä ja dokumentaatiossa, ei kansiorakenteessa:
|
Erottelu on nimessä ja dokumentaatiossa, ei kansiorakenteessa:
|
||||||
- `config-provider.yml`, `check-version.yml`, `docker-build-push.yml` — providerin tarjoamia
|
- `config-provider.yml`, `build-feature.yml` — providerin tarjoamia
|
||||||
- `example-feature.yml`, `example-main.yml`, `example-*.yml` — consumer-esimerkkejä
|
- `ci.yml` — consumerin omistamia
|
||||||
|
|
||||||
## Providerin `scripts/` (juuressa)
|
## Providerin `scripts/` (juuressa)
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ Consumerin omat skriptit, osana consumerin pipeline-logiikkaa.
|
|||||||
Kutsutaan consumerin workflowista ilman tupla checkouttia:
|
Kutsutaan consumerin workflowista ilman tupla checkouttia:
|
||||||
`.gitea/scripts/bats-report.sh`.
|
`.gitea/scripts/bats-report.sh`.
|
||||||
|
|
||||||
## Consumerin `.gitea/workflows/example-gitea-env.conf`
|
## Consumerin `.gitea/workflows/gitea-env.conf`
|
||||||
|
|
||||||
Consumerin konfiguraatiotiedosto. Providerin `config-provider.yml`
|
Consumerin konfiguraatiotiedosto. Providerin `config-provider.yml`
|
||||||
lukee tämän ja muuntaa JSONiksi, mutta consumer omistaa sisällön.
|
lukee tämän ja muuntaa JSONiksi, mutta consumer omistaa sisällön.
|
||||||
@@ -61,7 +61,8 @@ lukee tämän ja muuntaa JSONiksi, mutta consumer omistaa sisällön.
|
|||||||
|
|
||||||
- Provider voi muuttaa `scripts/` ja `config-provider.yml` sisältöä
|
- Provider voi muuttaa `scripts/` ja `config-provider.yml` sisältöä
|
||||||
ilman consumerin hyväksyntää (versiovaihdon yhteydessä)
|
ilman consumerin hyväksyntää (versiovaihdon yhteydessä)
|
||||||
- Consumer voi muuttaa `example-*.yml` ja `.gitea/scripts/` sisältöä
|
- Consumer voi muuttaa `.gitea/workflows/ci.yml`,
|
||||||
|
`.gitea/workflows/build-feature.yml` ja `.gitea/scripts/` sisältöä
|
||||||
ilman providerin muutoksia
|
ilman providerin muutoksia
|
||||||
- Providerin workflowt käyttävät `.ci/scripts/...` -polkua (tupla checkout)
|
- Providerin workflowt käyttävät `.ci/scripts/...` -polkua (tupla checkout)
|
||||||
- Consumerin workflowt käyttävät `.gitea/scripts/...` -polkua (natiivi checkout)
|
- Consumerin workflowt käyttävät `.gitea/scripts/...` -polkua (natiivi checkout)
|
||||||
|
|||||||
+62
-40
@@ -1,6 +1,6 @@
|
|||||||
# AI Context: Gitea Actions CI -kirjasto
|
# AI Context: Gitea Actions CI -kirjasto
|
||||||
|
|
||||||
**Updated**: 2026-06-15 (siivottu, provider/consumer-erottelu valmis)
|
**Updated**: 2026-06-12 (POC-vaihe, suunniteltu uudelleenkirjoitus)
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
Gitea Actions reusable workflow -kirjasto mikropalveluiden build-, testaus-,
|
Gitea Actions reusable workflow -kirjasto mikropalveluiden build-, testaus-,
|
||||||
@@ -8,68 +8,90 @@ raportointi-, deployment- ja test flow -prosessien orkestrointiin. Korvaa
|
|||||||
`ci-jenkins-library`:n Gitea-natiivilla toteutuksella. Mikropalvelut
|
`ci-jenkins-library`:n Gitea-natiivilla toteutuksella. Mikropalvelut
|
||||||
käyttävät kirjastoa `uses:`-direktiivillä.
|
käyttävät kirjastoa `uses:`-direktiivillä.
|
||||||
|
|
||||||
|
POC on valmis: raporttien julkaisu git-pagesiin ja commit-status linkillä
|
||||||
|
toimii.
|
||||||
|
|
||||||
## Monorepo: kaksi erillistä kokonaisuutta
|
## Monorepo: kaksi erillistä kokonaisuutta
|
||||||
|
|
||||||
|
Tämä repo on käytännössä monorepo, jossa on kaksi itsenäistä osaa:
|
||||||
|
|
||||||
### 1. Juuri (`gitea-ci-library`)
|
### 1. Juuri (`gitea-ci-library`)
|
||||||
Provider-kirjasto: reusable workflowt, scriptit, ADRt, dokumentaatio.
|
Provider-kirjasto: reusable workflowt, scriptit, ADRt, dokumentaatio.
|
||||||
Consumer kutsuu provider-workflowta `uses:`-direktiivillä.
|
Consumer kutsuu `build-feature.yml`-workflowa `uses:`-direktiivillä.
|
||||||
|
|
||||||
### 2. `git-pages/` — oma kokonaisuus
|
### 2. `git-pages/` — oma kokonaisuus
|
||||||
Helm-chartti Codeberg git-pagesille. Täysin itsenäinen — oma dokumentaatio,
|
Helm-chartti Codeberg git-pagesille. Täysin itsenäinen — oma dokumentaatio,
|
||||||
omat tekniset valinnat, oma design-rationale. Kaikki git-pages-spesifi tieto
|
omat tekniset valinnat, oma design-rationale. Kohdeltava kuten se olisi jo
|
||||||
kuuluu `git-pages/docs/`-alle, ei juuren `docs/`-kansioon.
|
oma reponsa: kaikki git-pages-spesifi tieto kuuluu `git-pages/docs/`- alle,
|
||||||
|
ei juuren `docs/`-kansioon.
|
||||||
|
|
||||||
|
### Rajapinta juuren ja git-pagesin välillä
|
||||||
|
|
||||||
|
Ohut ja yksiselitteinen:
|
||||||
|
|
||||||
|
```
|
||||||
|
scripts/publish-git-pages.sh <report-dir>
|
||||||
|
→ PATCH tar osoitteeseen GIT_PAGES_URL
|
||||||
|
→ palauttaa BASE URL:n
|
||||||
|
|
||||||
|
git-pages tarjoaa:
|
||||||
|
- HTTP endpoint (GET/PATCH/PUT)
|
||||||
|
- retention (automaattinen)
|
||||||
|
- TLS, BasicAuth (Traefik)
|
||||||
|
```
|
||||||
|
|
||||||
|
Juuri ei tiedä git-pagesin sisäisestä toiminnasta (storage v2, .index,
|
||||||
|
blob-arkkitehtuuri). Git-pages ei tiedä workflowista, scripteistä tai
|
||||||
|
provider-logiikasta.
|
||||||
|
|
||||||
|
## Architecture (POC-tila)
|
||||||
|
- **Provider & Consumer -malli**: `build-feature.yml` on lukittu rajapinta.
|
||||||
|
ADR 0005.
|
||||||
|
- **Raporttien hostaus**: git-pages Helm-chartilla (`git-pages/`), `GIT_PAGES_URL` määrittää perusosoitteen.
|
||||||
|
- **Retention**: sidecar samassa podissa, HTTP API localhost:3000,
|
||||||
|
Gitea API branch-check.
|
||||||
|
- **Commit-status**: Gitea Actions näyttää automaattisesti. API vain
|
||||||
|
custom-linkkiin. ADR 0004.
|
||||||
|
- **Julkaisu**: `publish-git-pages.sh` → PATCH tar git-pagesiin.
|
||||||
|
|
||||||
## Repository Structure
|
## Repository Structure
|
||||||
|
|
||||||
| Path | Purpose |
|
| Path | Purpose |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `.gitea/workflows/config-provider.yml` | Provider: lataa + validoi config-tiedoston, tuottaa `env_json` |
|
| `.gitea/workflows/` | Reusable workflowt (`build-feature.yml`, `config-provider.yml`) |
|
||||||
| `.gitea/workflows/check-version.yml` | Provider: tarkistaa onko commitille jo artifact, laskee version |
|
| `scripts/` | `publish-git-pages.sh`, `report-status.sh`, `dispatch-workflow.sh` |
|
||||||
| `.gitea/workflows/docker-build-push.yml` | Provider: buildaa + puskea Docker-imagen, tagittaa commitin |
|
| **`git-pages/`** | **Oma kokonaisuus: Helm-chartti + docs + retention** |
|
||||||
| `.gitea/workflows/example-*` | **Consumer-esimerkki**: tämän repon oma CI (dogfood) |
|
| `docs/` | Root-tason arkkitehtuuri, ADRt (0001–0005) |
|
||||||
| `scripts/` | Provider-skriptit: `report-status.sh`, `publish-git-pages.sh`, `ci-validate.sh` |
|
|
||||||
| `.gitea/scripts/` | **Consumer-skriptit**: `bats-coverage.sh`, `bats-report.sh` |
|
|
||||||
| `docs/` | Arkkitehtuuri, ADRt (0004–0008) |
|
|
||||||
| `docs/adr/` | Architecture Decision Records |
|
| `docs/adr/` | Architecture Decision Records |
|
||||||
| `git-pages/` | Raporttien hostaus (Helm-chartti) |
|
|
||||||
| `tests/` | Bats-testit skripteille |
|
| `tests/` | Bats-testit skripteille |
|
||||||
|
| `.gitea/workflows/ci.yml` | Dogfood — kutsuu `build-feature.yml`:a |
|
||||||
|
|
||||||
### Provider workflowt (3 kpl)
|
**Tarkemmat git-pages-asiat:** `git-pages/docs/` (implementation-notes,
|
||||||
|
architecture, design-rationale, secrets, tech-stack).
|
||||||
| Workflow | Input | Output | Kuvaus |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `config-provider.yml` | `config_path` | `env_json`, `config_path` | Validoi ja jäsentää `.conf` → JSON. Sama kutsu hoitaa validoinnin. |
|
|
||||||
| `check-version.yml` | `env_json` | `artifact_exists`, `version` | Tarkistaa git-tagit ja `package.json`:n, laskee seuraavan version. Vain main-haarassa. |
|
|
||||||
| `docker-build-push.yml` | `env_json`, `version` | — | Buildaa Docker-imagen, puskea rekisteriin, tagittaa commitin. |
|
|
||||||
|
|
||||||
### Example-tiedostot (consumer-referenssi)
|
|
||||||
|
|
||||||
| Tiedosto | Laukaisin | Flow |
|
|
||||||
|---|---|---|
|
|
||||||
| `example-feature.yml` | push [ei main] | load-config → bats + cucumber → report-summary |
|
|
||||||
| `example-main.yml` | push [main] | load-config → check-version → bats + cucumber → report-summary → docker-build-push |
|
|
||||||
| `example-bats-tests.yml` | workflow_call | Unit-testit Batsilla, raportit git-pagesiin, status linkillä |
|
|
||||||
| `example-cucumber-tests.yml` | workflow_call | Hyväksymätestit Cucumberilla, raportit git-pagesiin, status linkillä |
|
|
||||||
| `example-report-summary.yml` | workflow_call | `GITHUB_STEP_SUMMARY`-taulukko raporttilinkeillä (Gitea 1.27+) |
|
|
||||||
| `example-gitea-env.conf` | — | KEY=VALUE config tälle repolle |
|
|
||||||
|
|
||||||
## Key Technical Decisions
|
## Key Technical Decisions
|
||||||
|
- **Provider & Consumer**: `build-feature.yml` lukittu rajapinta, muu koodi
|
||||||
- **Provider & Consumer -malli**: `example-*`-tiedostot ovat consumer-esimerkkejä, provider-workflowt reusableja. ADR 0005.
|
vapaasti muutettavissa
|
||||||
- **Vain Gitea, vain reusable workflowt**: ei custom actioneita, ei multi-platform
|
- **Vain Gitea, vain reusable workflowt**: ei custom actioneita, ei
|
||||||
- **Commit-status API vain raporttilinkeille**: Tool-jobit luottavat natiiviin. Test-jobit käyttävät API:a koska se on ainoa tapa upottaa raporttilinkki. ADR 0004, 0007.
|
multi-platform
|
||||||
- **Exit-koodi on ainoa onnistumisen mittari**: Ei pipeä, ei tiedostoheuristiikkaa. ADR 0008.
|
|
||||||
- **Raportit git-pagesissa**: HTML selailtavissa, retention automaattinen
|
- **Raportit git-pagesissa**: HTML selailtavissa, retention automaattinen
|
||||||
- **GITHUB_STEP_SUMMARY**: Summary-näkymä raporttilinkeille Gitea 1.27:ssä (forward-compat)
|
- **Git-pages omana kokonaisuutena**: voi erottaa omaksi repokseen
|
||||||
|
tulevaisuudessa
|
||||||
|
|
||||||
|
## Tech Stack (POC)
|
||||||
|
- **Runtime:** Bash, curl, jq, python3 (retention whiteout)
|
||||||
|
- **Alusta:** Gitea Actions, Gitea act runner
|
||||||
|
- **Hostaus:** git-pages 0.9.1 (Codeberg), Traefik, cert-manager
|
||||||
|
- **Integraatiot:** Gitea REST API, Gitea Packages
|
||||||
|
|
||||||
## Common Commands
|
## Common Commands
|
||||||
- Helm-asennus: `helm upgrade --install git-pages ./git-pages -n <ns> -f <values>`
|
- Helm-asennus: `helm upgrade --install git-pages ./git-pages -n <ns> -f <values>`
|
||||||
- Julkaisu: `bash scripts/publish-git-pages.sh <report-dir>`
|
- Julkaisu: `bash scripts/publish-git-pages.sh <report-dir>`
|
||||||
- Status: `bash scripts/report-status.sh <state> <desc> <context> [suite] [url]`
|
- Status: `bash scripts/report-status.sh <state> <desc> <url> <context>`
|
||||||
|
|
||||||
## What NOT to Do
|
## What NOT to Do
|
||||||
- Älä lisää tukea muille Git-alustoille
|
- Älä lisää tukea muille Git-alustoille
|
||||||
- Älä lisää Docker custom actioneita ilman pakottavaa syytä
|
- Älä lisää Docker custom actioneita ilman pakottavaa syytä
|
||||||
- Älä kirjoita git-pages-spesifiä tietoa juuren `docs/`-kansioon
|
- Älä kirjoita git-pages-spesifiä tietoa juuren `docs/`-kansioon —
|
||||||
- Älä käytä commit-status API:a jollei ole raporttia linkitettäväksi (ADR 0007)
|
kuuluu `git-pages/docs/`-alle
|
||||||
- Älä käytä pipeä `run`-komennon viimeisenä — se syö exit-koodin (ADR 0008)
|
- Älä POSTaa commit-status APIin jokaiselle vaiheelle — natiivi riittää
|
||||||
|
|||||||
+17
-37
@@ -1,6 +1,7 @@
|
|||||||
# Architecture — Gitea Actions CI -kirjasto
|
# Architecture — Gitea Actions CI -kirjasto
|
||||||
|
|
||||||
> Normatiivinen lähde: ADR 0004, 0005, 0006, 0007, 0008.
|
> ⚠️ POC-vaihe. Tämä dokumentti kuvaa suunniteltua arkkitehtuuria.
|
||||||
|
> Normatiivinen lähde: ADR 0004, ADR 0005, `docs/design-rationale.md`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -17,52 +18,31 @@ Kirjasto on Gitea-spesifi. Raportit hallinnoidaan git-pages Helm-chartilla
|
|||||||
|
|
||||||
| Rooli | Kuvaus |
|
| Rooli | Kuvaus |
|
||||||
|-------|--------|
|
|-------|--------|
|
||||||
| **Provider** | `gitea-ci-library` — tarjoaa reusable workflowt (`config-provider.yml`, `check-version.yml`, `docker-build-push.yml`) ja scriptit |
|
| **Provider** | `gitea-ci-library` — tarjoaa `build-feature.yml` (lukittu rajapinta) sekä scriptit |
|
||||||
| **Consumer** | Mikropalveluprojekti — kutsuu `uses:`-direktiivillä, omistaa pipeline-logiikan. Tämän repon oma toteutus: `example-*`-tiedostot |
|
| **Consumer** | Mikropalveluprojekti — kutsuu `uses:`-direktiivillä, omistaa pipeline-logiikan |
|
||||||
|
|
||||||
Tarkemmin: ADR 0005.
|
Tarkemmin: ADR 0005.
|
||||||
|
|
||||||
## Komponentit
|
## Komponentit (POC)
|
||||||
|
|
||||||
| Komponentti | Tyyppi | Kuvaus |
|
| Komponentti | Tila |
|
||||||
|---|---|---|
|
|-------------|------|
|
||||||
| `config-provider.yml` | Provider | Lataa + validoi `.conf`-tiedoston, tuottaa `env_json` |
|
| `build-feature.yml` | Toimii. Ainoa reusable workflow. |
|
||||||
| `check-version.yml` | Provider | Tarkistaa git-tagit, laskee version, palauttaa `artifact_exists` + `version` |
|
| `publish-git-pages.sh` | Toimii. PATCH tar git-pagesiin. |
|
||||||
| `docker-build-push.yml` | Provider | Buildaa Docker-imagen, puskea rekisteriin, tagittaa commitin |
|
| `report-status.sh` | Toimii. POSTaa commit-status (vain custom-linkkiin). |
|
||||||
| `example-feature.yml` | Consumer | Feature-haaran CI: load-config → bats + cucumber → summary |
|
| `dispatch-workflow.sh` | Toimii. Dispatchee workflown ja pollaa valmistumista. |
|
||||||
| `example-main.yml` | Consumer | Main-haaran CI: load-config → check-version → bats + cucumber → summary → docker |
|
| `git-pages/` | Helm-chartti raporttien hostaukseen. Oma kokonaisuus, tarkemmin: `git-pages/docs/`. |
|
||||||
| `example-bats-tests.yml` | Consumer | Unit-testit Batsilla |
|
|
||||||
| `example-cucumber-tests.yml` | Consumer | Hyväksymätestit Cucumberilla |
|
|
||||||
| `example-report-summary.yml` | Consumer | `GITHUB_STEP_SUMMARY`-taulukko (Gitea 1.27+) |
|
|
||||||
| `publish-git-pages.sh` | Provider-skripti | PATCH tar git-pagesiin |
|
|
||||||
| `report-status.sh` | Provider-skripti | POSTaa commit-status (vain custom-linkkiin) |
|
|
||||||
| `ci-validate.sh` | Provider-skripti | Validoi `.conf`-tiedoston ja tarkistaa secretit |
|
|
||||||
| `dispatch-workflow.sh` | Provider-skripti | Dispatchee workflown ja pollaa valmistumista |
|
|
||||||
| `git-pages/` | Infra | Helm-chartti raporttien hostaukseen. Oma kokonaisuus |
|
|
||||||
|
|
||||||
## Statusraportointi
|
|
||||||
|
|
||||||
| Job-tyyppi | Mekanismi | Syy |
|
|
||||||
|---|---|---|
|
|
||||||
| Tool-jobit | Vain Gitea natiivi job-status | Ei raporttia linkitettäväksi |
|
|
||||||
| Test-jobit | Commit-status API linkillä | Ainoa tapa upottaa raporttilinkki commit-näkymään |
|
|
||||||
| Docker-build-push | Commit-status API linkillä | Linkki Docker registryyn |
|
|
||||||
|
|
||||||
Tarkemmin: ADR 0004, 0007.
|
|
||||||
|
|
||||||
## Ulkoiset palvelut
|
## Ulkoiset palvelut
|
||||||
|
|
||||||
| Palvelu | Rooli |
|
| Palvelu | Rooli |
|
||||||
|---|---|
|
|---------|-------|
|
||||||
| Gitea REST API | Commit-status (vain custom-linkit), git-tagit |
|
| **Gitea REST API** | Commit-status, workflow-dispatch, run-pollaus |
|
||||||
| Gitea Packages | Docker-imagen säilytys |
|
| **Gitea Packages** | Docker-imagen säilytys |
|
||||||
| git-pages | Raporttien hostaus |
|
| **git-pages** | Raporttien hostaus |
|
||||||
|
|
||||||
## Arkkitehtuuriset rajoitteet
|
## Arkkitehtuuriset rajoitteet
|
||||||
|
|
||||||
- Provider-workflowt ovat reusableja (`workflow_call`), consumer omistaa orkestroinnin
|
- `build-feature.yml` on ainoa consumerin kutsuma rajapinta (ADR 0005)
|
||||||
- Gitea Actionsin natiivi commit-status on ensisijainen (ADR 0004)
|
- Gitea Actionsin natiivi commit-status on ensisijainen (ADR 0004)
|
||||||
- API:a käytetään vain custom-linkkeihin (ADR 0007)
|
|
||||||
- Exit-koodi on ainoa onnistumisen mittari — ei pipeä (ADR 0008)
|
|
||||||
- Raportit ovat julkisia URL:lla (osoite tunnettava)
|
- Raportit ovat julkisia URL:lla (osoite tunnettava)
|
||||||
- Consumer-skriptit `.gitea/scripts/`-alla, provider-skriptit `scripts/`-alla (ADR 0006)
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
**⚠️ STATUS: OSITTAIN VANHENTUNUT** — Statusraportointi (7) ja exit-koodit (8)
|
**⚠️ STATUS: ALERT DRAFT** — Ei ole validoitu. Voi sisältää virheellisiä tai puutteellisia käytäntöjä.
|
||||||
on formalisoitu ADR:iin 0007 ja 0008. Loput osiot validioitu POC-ajossa.
|
|
||||||
|
|
||||||
|
|
||||||
# CI Pipeline Practices
|
# CI Pipeline Practices
|
||||||
|
|||||||
+336
-72
@@ -1,126 +1,390 @@
|
|||||||
# Reusable workflowt
|
# Reusable workflowt
|
||||||
|
|
||||||
> Provider-workflowt tarjoavat ydintoiminnallisuuden. Consumer kokoaa ne
|
> ⚠️ **POC-vaihe.** Toteutettu: `quality-gate.yml`. Suunnitteilla:
|
||||||
> haluamakseen pipelineksi. Esimerkkitoteutus: `example-*`-tiedostot.
|
> `ci-master.yml`, `deploy.yml`, `test.yml`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Yhteiset konventiot
|
## Yhteiset konventiot
|
||||||
|
|
||||||
Kaikki workflowt:
|
Kaikki workflowt:
|
||||||
- Käyttävät `concurrency:`-ryhmää estämään saman branchin rinnakkaiset ajot
|
- Käyttävät `concurrency:`-ryhmää estämään saman branchin rinnakkaiset ajot (vastaa Jenkins `disableConcurrentBuilds()`)
|
||||||
- Provider-workflowt lukevat konfiguraation inputtina (`env_json`)
|
- Lukevat konfiguraation `ci-flow-values.yaml`:sta
|
||||||
- Statusraportointi: tool-jobit natiivilla, test-jobit API:lla raporttilinkin takia (ADR 0007)
|
- Raportoivat jokaisen vaiheen Gitea-commitin statukseen `report-status.sh`:lla
|
||||||
- Exit-koodi aina ylös, ei pipeä (ADR 0008)
|
- Käyttävät projektilta saatuja `with:`-parametreja konttien määrittelyyn (kirjasto ei pakota konttiversioita)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Provider-workflowt
|
## `quality-gate.yml` — Merge-portti
|
||||||
|
|
||||||
### `config-provider.yml` — Konfiguraation lataus ja validointi
|
**Trigger:** `workflow_call` — consumer kutsuu `uses:`-direktiivillä
|
||||||
|
|
||||||
**Trigger:** `workflow_call`
|
**Rooli:** Laatuportti, joka ajetaan branch protection -sääntönä ennen PR:n
|
||||||
|
sulkemista mainiin. Pipeline on ajettava (`run > 1`) eikä yhtään jobia
|
||||||
|
saa failata.
|
||||||
|
|
||||||
**Inputs:**
|
**Provider-Consumer-malli (ADR 0005):** Provider tarjoaa orkestroinnin
|
||||||
|
(validointi, raporttien julkaisu, commit-status). Consumer omistaa
|
||||||
|
pipeline-stepit — valitsee testityökalunsa, mahdolliset laatu- ja
|
||||||
|
tietoturva-analyy sit sekä niiden järjestyksen. Alla oleva esimerkki
|
||||||
|
kuvaa tyypillistä Java-mikropalvelua Mavenilla; consumer korvaa nämä
|
||||||
|
omalla tekniikkapinollaan.
|
||||||
|
|
||||||
| Parametri | Pakollinen | Kuvaus |
|
### Inputs (providerin rajapinta)
|
||||||
|-----------|------------|--------|
|
|
||||||
| `config_path` | Kyllä | Polku `.conf`-tiedostoon |
|
|
||||||
|
|
||||||
**Secrets:**
|
| Parametri | Pakollinen | Tyyppi | Kuvaus |
|
||||||
|
|-----------|------------|--------|--------|
|
||||||
|
| `env_json` | Kyllä | string | JSON-muotoiset ympäristömuuttujat (`GITEA_API_URL`, `GIT_PAGES_URL`) |
|
||||||
|
| `*` | — | — | Consumer lisää omat parametrinsa (`maven-image`, `docker-image`, jne.) |
|
||||||
|
|
||||||
|
### Secrets
|
||||||
|
|
||||||
| Secret | Pakollinen | Kuvaus |
|
| Secret | Pakollinen | Kuvaus |
|
||||||
|--------|------------|--------|
|
|--------|------------|--------|
|
||||||
| `GITEA_TOKEN` | Kyllä | Validointia varten |
|
| `GITEA_TOKEN` | Kyllä | Gitea API-kutsuihin (commit-status) |
|
||||||
| `GIT_PAGES_PUBLISH_TOKEN` | Kyllä | Validointia varten |
|
| `GIT_PAGES_PUBLISH_TOKEN` | Kyllä | Raporttien julkaisuun git-pagesiin |
|
||||||
|
|
||||||
**Outputs:**
|
### Steppi-kaavio (Java-esimerkki)
|
||||||
|
|
||||||
| Output | Kuvaus |
|
```mermaid
|
||||||
|--------|--------|
|
%%{init: {'theme': 'base', 'flowchart': {'arrowheadScale': 2}}}%%
|
||||||
| `env_json` | JSON-muotoiset ympäristömuuttujat |
|
flowchart TD
|
||||||
| `config_path` | Sama polku takaisin (DRY downstream-käyttöön) |
|
VAL["validate
|
||||||
|
provider: tarkista
|
||||||
|
CI-konfiguraatio"] --> TEST["test
|
||||||
|
consumer: mvn test
|
||||||
|
→ testiraportit + coverage"]
|
||||||
|
|
||||||
**Steppi-kaavio:**
|
VAL --> AI_SCAN["ai-scan \[optional\]
|
||||||
```
|
consumer: tietoturva-
|
||||||
checkout → validate CI config → parse conf to JSON
|
tai laatu-skannaus"]
|
||||||
|
|
||||||
|
TEST --> SONAR["sonarqube \[optional\]
|
||||||
|
consumer: mvn sonar:sonar
|
||||||
|
→ laatupoikkeamat"]
|
||||||
|
TEST --> PUB["publish-reports
|
||||||
|
provider: vie raportit
|
||||||
|
git-pagesiin"]
|
||||||
|
|
||||||
|
SONAR --> PUB
|
||||||
|
AI_SCAN --> PUB
|
||||||
|
|
||||||
|
PUB --> STATUS["commit-status
|
||||||
|
provider: aseta status
|
||||||
|
linkillä raporttiin"]
|
||||||
|
|
||||||
|
FAIL("fail") -. "if: always()" .-> PUB
|
||||||
|
|
||||||
|
style VAL fill:#2563eb,color:#ffffff
|
||||||
|
style TEST fill:#059669,color:#ffffff
|
||||||
|
style SONAR fill:#7c3aed,color:#ffffff
|
||||||
|
style AI_SCAN fill:#7c3aed,color:#ffffff
|
||||||
|
style PUB fill:#0891b2,color:#ffffff
|
||||||
|
style STATUS fill:#f59e0b,color:#111827
|
||||||
|
style FAIL fill:#dc2626,color:#ffffff
|
||||||
|
linkStyle default stroke:#9ca3af,stroke-width:3px
|
||||||
```
|
```
|
||||||
|
|
||||||
### `check-version.yml` — Version ja artifactin tarkistus
|
Consumerin omat stepit (test, sonarqube, ai-scan) ovat esimerkki.
|
||||||
|
Vastaava rakenne toimii millä tahansa kielellä tai työkalulla.
|
||||||
|
|
||||||
**Trigger:** `workflow_call` — käytetään vain main-haarassa
|
### Optionaaliset laatu- ja tietoturvaskannaukset
|
||||||
|
|
||||||
**Inputs:** `env_json`
|
Consumer voi lisätä pipelineen omia skannaussteppejä testien rinnalle.
|
||||||
|
Nämä ajetaan rinnakkain `validate`-vaiheen jälkeen ja syöttävät
|
||||||
|
raporttinsa providerin `publish-reports`-palveluun. Jokainen skannaus
|
||||||
|
on oma Gitea Actions -jobinsa.
|
||||||
|
|
||||||
**Outputs:** `artifact_exists` (true/false), `version` (string)
|
```mermaid
|
||||||
|
%%{init: {'theme': 'base', 'flowchart': {'arrowheadScale': 2}}}%%
|
||||||
|
flowchart LR
|
||||||
|
VAL["validate"] --> SAST["sast
|
||||||
|
semgrep / codeql"]
|
||||||
|
VAL --> SCA["sca
|
||||||
|
snyk / owasp dc"]
|
||||||
|
VAL --> SECRETS["secret-scan
|
||||||
|
gitleaks"]
|
||||||
|
VAL --> LICENSE["license
|
||||||
|
fossa / scancode"]
|
||||||
|
VAL --> AI_REVIEW["ai-review
|
||||||
|
code quality"]
|
||||||
|
|
||||||
**Steppi-kaavio:**
|
SAST --> PUB
|
||||||
```
|
SCA --> PUB
|
||||||
checkout → laske versio package.json + git-tageista → output
|
SECRETS --> PUB
|
||||||
|
LICENSE --> PUB
|
||||||
|
AI_REVIEW --> PUB
|
||||||
|
|
||||||
|
PUB["publish-reports + commit-status"]
|
||||||
|
|
||||||
|
style VAL fill:#2563eb,color:#ffffff
|
||||||
|
style SAST fill:#7c3aed,color:#ffffff
|
||||||
|
style SCA fill:#7c3aed,color:#ffffff
|
||||||
|
style SECRETS fill:#7c3aed,color:#ffffff
|
||||||
|
style LICENSE fill:#7c3aed,color:#ffffff
|
||||||
|
style AI_REVIEW fill:#7c3aed,color:#ffffff
|
||||||
|
style PUB fill:#0891b2,color:#ffffff
|
||||||
|
linkStyle default stroke:#9ca3af,stroke-width:3px
|
||||||
```
|
```
|
||||||
|
|
||||||
### `docker-build-push.yml` — Docker build & push
|
| Kategoria | Esimerkki | Kuvaus |
|
||||||
|
|-----------|-----------|--------|
|
||||||
|
| **SAST** | Semgrep, CodeQL | Staattinen analyysi — bugit ja haavoittuvuudet koodista |
|
||||||
|
| **SCA** | Snyk, OWASP Dependency-Check | Riippuvuuksien tunnetut haavoittuvuudet |
|
||||||
|
| **Secret scan** | Gitleaks, TruffleHog | API-avaimet, tokenit ja salasanat repossa |
|
||||||
|
| **Lisenssit** | FOSSA, ScanCode | Riippuvuuksien lisenssien yhteensopivuus |
|
||||||
|
| **AI review** | — | Automaattinen koodikatselmointi |
|
||||||
|
|
||||||
**Trigger:** `workflow_call`
|
### Error handling
|
||||||
|
|
||||||
**Inputs:** `env_json`, `version`
|
Providerin julkaisu- ja status-stepit käyttävät `if: always()`-ehtoa,
|
||||||
|
jotta raportit ja commit-status päivittyvät myös failaavista ajoista.
|
||||||
|
Consumerin omat stepit voivat vapaasti päättää `continue-on-error`- tai
|
||||||
|
`if: failure()`-logiikastaan. Provider ei määrittele virheidenkäsittelyä
|
||||||
|
consumerin pipelineen.
|
||||||
|
|
||||||
**Secrets:** `GITEA_TOKEN`, `DOCKER_USERNAME`, `DOCKER_PASSWORD`
|
### Merge-portti
|
||||||
|
|
||||||
**Steppi-kaavio:**
|
Branch protection -säännössä Giteassa vaaditaan ennen PR:n sulkemista:
|
||||||
|
- **Pipeline on ajettu** (`run > 1`, ei "never run" -tila)
|
||||||
|
- **Kaikki commit-statukset vihreitä** — validate, testit, laatuportit
|
||||||
|
- Jos joku steppi failaa, status asettuu `failure`-tilaan ja PR:n
|
||||||
|
sulkeminen estyy
|
||||||
|
|
||||||
|
### Optionaalinen PR-ympäristö (preview app)
|
||||||
|
|
||||||
|
Consumer voi halutessaan buildata kontin ja deployata sen väliaikaiseen
|
||||||
|
PR-ympäristöön. Tämä on optionaalinen continuation-haara, joka
|
||||||
|
aktivoituu ehdolla:
|
||||||
|
|
||||||
|
- PR:ssä on tietty label (esim. `preview`)
|
||||||
|
- Commit message sisältää triggerisanan (esim. `[preview]`)
|
||||||
|
|
||||||
|
**Elinkaari:**
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
%%{init: {'theme': 'base', 'flowchart': {'arrowheadScale': 2}}}%%
|
||||||
|
flowchart LR
|
||||||
|
QG["quality-gate
|
||||||
|
testit + skannaukset
|
||||||
|
ok"] --> BUILD["build-container
|
||||||
|
tag: pr-42"]
|
||||||
|
BUILD --> DEPLOY["deploy-pr-env
|
||||||
|
väliaikainen ympäristö"]
|
||||||
|
|
||||||
|
DEPLOY --> STATUS["commit-status
|
||||||
|
linkki PR-ympäristöön"]
|
||||||
|
|
||||||
|
PR_CLOSE["PR merged / closed"] --> CLEANUP["cleanup-pr-env
|
||||||
|
tuhoa ympäristö"]
|
||||||
|
|
||||||
|
style QG fill:#059669,color:#ffffff
|
||||||
|
style BUILD fill:#0891b2,color:#ffffff
|
||||||
|
style DEPLOY fill:#7c3aed,color:#ffffff
|
||||||
|
style STATUS fill:#f59e0b,color:#111827
|
||||||
|
style PR_CLOSE fill:#dc2626,color:#ffffff
|
||||||
|
style CLEANUP fill:#dc2626,color:#ffffff
|
||||||
|
linkStyle default stroke:#9ca3af,stroke-width:3px
|
||||||
```
|
```
|
||||||
build-push (build + push samassa jobissa, ei levyn kautta) → tag-commit
|
|
||||||
|
1. Quality-gate läpäisty (testit + skannaukset ok)
|
||||||
|
2. Buildaa kontti, tagi sisältää PR-numeron (`pr-42`)
|
||||||
|
3. Deployaa PR-ympäristöön (preview/review app)
|
||||||
|
4. Asettaa commit-statuksen linkillä ympäristöön
|
||||||
|
5. **PR:n sulkeutuessa** (merge/close): cleanup-job tuhoaa ympäristön
|
||||||
|
|
||||||
|
Tämä on **consumerin vastuulla** — provider tarjoaa tarvittavat
|
||||||
|
skriptit (`publish-git-pages.sh`, `report-status.sh`), mutta
|
||||||
|
trigger-ehto, kontin buildaus ja ympäristön hallinta kuuluvat
|
||||||
|
consumerin pipelineen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## `ci-master.yml` — Main-branch build
|
||||||
|
|
||||||
|
**Trigger:** `workflow_call` — kutsutaan main-branchiin pushattaessa
|
||||||
|
|
||||||
|
**Rooli:** Buildaa artifaktin (kontti, JAR, npm-paketti tms.) ja julkaisee
|
||||||
|
sen rekisteriin. Jos sama commit on jo buildattu (version tag on olemassa),
|
||||||
|
build skipataan ja siirrytään suoraan test flow'hun.
|
||||||
|
|
||||||
|
**Provider-Consumer-malli (ADR 0005):** Provider orkestroi idempotent
|
||||||
|
build-logiikan (`isArtifactBuilt`-tarkistus), mutta consumer omistaa
|
||||||
|
build-stepit — valitsee työkalut ja artifaktityypin.
|
||||||
|
|
||||||
|
### isArtifactBuilt-check
|
||||||
|
|
||||||
|
Ennen buildia tarkistetaan, onko tälle commitille jo olemassa versiotagi:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
TAG=$(git tag --points-at HEAD | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
|
||||||
|
if [ -n "$TAG" ]; then
|
||||||
|
echo "artifact_already_built=true" >> $GITHUB_ENV
|
||||||
|
echo "artifact_version=$TAG" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Jos tagi löytyy, build- ja push-stepit skipataan. Committia vastaan on
|
||||||
|
jo olemassa artifakti rekisterissä — uudelleenbuildaus aiheuttaisi
|
||||||
|
versiokonflikteja ja tuhlaisi CI-aikaa.
|
||||||
|
|
||||||
|
### Steppi-kaavio
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
%%{init: {'theme': 'base', 'flowchart': {'arrowheadScale': 2}}}%%
|
||||||
|
flowchart TD
|
||||||
|
CHECK{"isArtifactBuilt?
|
||||||
|
git tag --points-at HEAD"}
|
||||||
|
|
||||||
|
CHECK -- "ei" --> QG["quality-gate
|
||||||
|
testit + skannaukset"]
|
||||||
|
QG --> BUILD["build-artifact
|
||||||
|
consumer: docker build /
|
||||||
|
mvn package / npm build"]
|
||||||
|
BUILD --> PUSH["push registry
|
||||||
|
gitea packages /
|
||||||
|
docker registry"]
|
||||||
|
PUSH --> TAG["tag-commit
|
||||||
|
tagittaa commitin
|
||||||
|
versiolla (esim. 1.2.3.${RUN})"]
|
||||||
|
|
||||||
|
CHECK -- "kyllä" --> K8S["continueToTestFlow
|
||||||
|
(future: K8s-testit
|
||||||
|
test plan -mukaan)"]
|
||||||
|
TAG --> K8S
|
||||||
|
|
||||||
|
FAIL("fail") -. "quality-gate
|
||||||
|
ei läpäisty" .-> END
|
||||||
|
|
||||||
|
K8S --> END(["end
|
||||||
|
commit-status"])
|
||||||
|
|
||||||
|
style CHECK fill:#f59e0b,color:#111827
|
||||||
|
style QG fill:#059669,color:#ffffff
|
||||||
|
style BUILD fill:#0891b2,color:#ffffff
|
||||||
|
style PUSH fill:#dc2626,color:#ffffff
|
||||||
|
style TAG fill:#f59e0b,color:#111827
|
||||||
|
style K8S fill:#7c3aed,color:#ffffff
|
||||||
|
style FAIL fill:#dc2626,color:#ffffff
|
||||||
|
style END fill:#2563eb,color:#ffffff
|
||||||
|
linkStyle default stroke:#9ca3af,stroke-width:3px
|
||||||
|
```
|
||||||
|
|
||||||
|
### Elinkaari
|
||||||
|
|
||||||
|
1. **isArtifactBuilt?** — tarkista onko tagi olemassa
|
||||||
|
2. **quality-gate** — jos ei tagia, aja `quality-gate.yml` (testit, skannaukset)
|
||||||
|
3. **build-artifact** — jos quality-gate läpäisty, buildaa artifakti
|
||||||
|
4. **push registry** — julkaise rekisteriin (Gitea Packages, Docker registry, jne.)
|
||||||
|
5. **tag-commit** — tagittaa commitin versiolla (esim. `1.2.3.<run_number>`)
|
||||||
|
6. **continueToTestFlow** — *(future)* aja K8s-testit test plan -mukaan
|
||||||
|
7. **commit-status** — aseta lopullinen status
|
||||||
|
|
||||||
|
### Concurrency
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
concurrency:
|
||||||
|
group: master-${{ github.repository }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
```
|
||||||
|
|
||||||
|
Vain yksi master-build kerrallaan per repo. Ei cancel-in-progress —
|
||||||
|
käynnissä olevan buildin annetaan valmistua.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## `deploy.yml` — GitOps-deployment
|
||||||
|
|
||||||
|
**Trigger:** `workflow_dispatch` (aina dispatchataan toisesta workflow'sta)
|
||||||
|
|
||||||
|
**Elinkaari:**
|
||||||
|
|
||||||
|
```
|
||||||
|
start → read-yaml → update-value → commit → push → report-cross-repo → end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Inputs (dispatch-parametrit)
|
||||||
|
|
||||||
|
| Parametri | Kuvaus |
|
||||||
|
|-----------|--------|
|
||||||
|
| `environment` | Ympäristön nimi (korvaa `{.environment}`) |
|
||||||
|
| `version` | Uusi konttiversio |
|
||||||
|
| `root_commit` | Mikropalvelun commit josta deploy käynnistyi |
|
||||||
|
| `root_repo` | Mikropalvelun repo |
|
||||||
|
| `root_build_url` | URL mikropalvelun buildiin |
|
||||||
|
|
||||||
|
### Mitä deploy tekee
|
||||||
|
|
||||||
|
1. Lukee `{projectFolder}/{fileName}` YAML-tiedoston (korvaa `{.environment}` → `environment`)
|
||||||
|
2. Päivittää `{property}`-avaimen arvoksi `{version}`
|
||||||
|
3. `git add`, `git commit -m "deploy {version} to {environment}"`
|
||||||
|
4. `git push origin HEAD:master`
|
||||||
|
5. Raportoi statuksen:
|
||||||
|
- Helm-repon committiin: **"from {root_commit}"**, URL → root-build
|
||||||
|
- Mikropalvelun committiin (`root_commit`): **"deployed to {environment}"**, URL → Helm-commit
|
||||||
|
6. Palauttaa Helm-commitin hashin (`outputs.commit`)
|
||||||
|
|
||||||
|
### Concurrency
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
concurrency:
|
||||||
|
group: deploy-${{ github.repository }}-${{ inputs.environment }}
|
||||||
|
cancel-in-progress: false
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Consumer-esimerkki (`example-*`)
|
## `test.yml` — Test flow -steppi
|
||||||
|
|
||||||
### `example-feature.yml` — Feature-haaran CI
|
**Trigger:** `workflow_dispatch` (dispatchataan deploy-workflow'n jälkeen)
|
||||||
|
|
||||||
**Trigger:** `push` [branches-ignore: main]
|
**Elinkaari:**
|
||||||
|
|
||||||
```
|
```
|
||||||
load-config → bats + cucumber → report-summary (always)
|
start → version-check → run-tests → push-reports → report-cross-repo → end
|
||||||
```
|
```
|
||||||
|
|
||||||
### `example-main.yml` — Main-haaran CI
|
### Inputs (dispatch-parametrit)
|
||||||
|
|
||||||
**Trigger:** `push` [branches: main]
|
| Parametri | Kuvaus |
|
||||||
|
|-----------|--------|
|
||||||
|
| `environment` | Testiympäristö |
|
||||||
|
| `version` | Testattava konttiversio |
|
||||||
|
| `tags` | Cucumber-tagit |
|
||||||
|
| `versionApiUrl` | URL version tarkistukseen |
|
||||||
|
| `versionCheckScript` | Polku version check -skriptiin |
|
||||||
|
| `root_commit` | Mikropalvelun commit |
|
||||||
|
| `root_repo` | Mikropalvelun repo |
|
||||||
|
| `deploy_commit` | Helm-repon commit (deployattu versio) |
|
||||||
|
| `deploy_repo` | Helm-repo |
|
||||||
|
|
||||||
```
|
### Version check
|
||||||
load-config → check-version →
|
|
||||||
[artifact exists] → done
|
Ennen testejä varmistetaan, että ympäristössä pyörii oikea versio:
|
||||||
[no artifact] → bats + cucumber → report-summary (always) → docker-build-push
|
|
||||||
|
```yaml
|
||||||
|
- name: Check deployed version
|
||||||
|
if: inputs.versionCheckScript || inputs.versionApiUrl
|
||||||
|
run: |
|
||||||
|
if [ -n "${{ inputs.versionCheckScript }}" ]; then
|
||||||
|
bash "${{ inputs.versionCheckScript }}" "${{ inputs.versionApiUrl }}" "${{ inputs.version }}"
|
||||||
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
### `example-bats-tests.yml` — Bats unit-testit
|
Version check -skripti pollaa Fibonacci-backoffilla — ks. [config-model.md](config-model.md).
|
||||||
|
|
||||||
**Trigger:** `workflow_call`
|
### Cross-repo-raportointi
|
||||||
|
|
||||||
Ajaa Bats-testit Docker-kontissa, generoi coveragen (`bashcov`), julkaisee
|
Testien jälkeen raportoidaan kolmeen committiin:
|
||||||
raportit git-pagesiin, asettaa commit-statuksen linkillä raporttiin.
|
|
||||||
|
|
||||||
### `example-cucumber-tests.yml` — Cucumber hyväksymätestit
|
1. Testi-repon oma commit: testin status
|
||||||
|
2. Mikropalvelun commit (`root_commit`): "testit OK/epäonnistui"
|
||||||
|
3. Helm-repon commit (`deploy_commit`): "testattu v{version}"
|
||||||
|
|
||||||
**Trigger:** `workflow_call`
|
### Concurrency
|
||||||
|
|
||||||
Ajaa Cucumber-testit Node-kontissa, julkaisee raportit git-pagesiin, asettaa
|
```yaml
|
||||||
commit-statuksen linkillä raporttiin.
|
concurrency:
|
||||||
|
group: test-${{ inputs.environment }}
|
||||||
### `example-report-summary.yml` — Raporttien koontinäkymä
|
cancel-in-progress: false
|
||||||
|
```
|
||||||
**Trigger:** `workflow_call` — ajetaan `if: always()` testien jälkeen
|
|
||||||
|
|
||||||
**Inputs:** `env_json`, `suites` (space-separated lista suite-nimistä)
|
|
||||||
|
|
||||||
Generoi Markdown-taulukon `GITHUB_STEP_SUMMARY`:yn kaikista julkaistuista
|
|
||||||
raporteista. Renderöityy HTML:ksi Gitea 1.27+ Summary-välilehdellä.
|
|
||||||
Forward-compatibeli — ei haittaa vanhemmilla Gitea-versioilla.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Suunnitteilla
|
|
||||||
|
|
||||||
- `deploy.yml` — GitOps-deployment (dispatch-workflow.sh-pohjainen)
|
|
||||||
- `test.yml` — Klusteritason test flow
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-ci-library",
|
"name": "gitea-ci-library",
|
||||||
"version": "0.2.0",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "cucumber.js",
|
"main": "cucumber.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|||||||
Reference in New Issue
Block a user