Files
gitea-ci-library/docs/tickets/0009-ci-master-yml.md
T
moilanik 9a59cbc185
CI — gitea-ci-library / feature (push) Failing after 1s
CI — gitea-ci-library / master (push) Has been skipped
tiketit ja featuret vaihe 1
2026-06-08 09:34:47 +03:00

145 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Ticket 0009: `ci-master.yml` (reusable workflow)
**Vaihe:** 9/12
**Status:** pending
**Feature branch:** `feature/0009-ci-master-yml`
**TDD required:** Yes
**Feature file required:** Yes
**Required context:**
- `docs/test-plan/tdd-guide.md`
- `tests/features/0009-ci-master.feature`
- Skills: `tdd`, `implementation`, `clean-code`
---
## TDD — Red-Green-Refactor + Dogfood
### Red
Validointitesti (`tests/workflows.bats`):
- Kaikki `workflow_call`-inputit: `config-file`, `maven-image`, `docker-image`
- `isContainerBuilt`-check: git-tagin mukaan
- Docker-labelien injektointi
- Test flow -ketjutus: `dispatch-workflow.sh` kutsutaan jokaiselle `test-flow`-stepille
- `continueToTestFlow`-steppi skip-vaihtoehdolla
```bash
bats tests/workflows.bats
# FAIL
```
### Green
Toteuta `gitea/workflows/ci-master.yml`.
```bash
bats tests/workflows.bats
# PASS
```
### Dogfood
Kirjaston oma `ci.yml` kutsuu `ci-master.yml`:ä master-branchille.
## DoD
- [ ] Cucumber: `@ticket-0009 and @mock` → kaikki skenaariot GREEN
- [ ] `tests/workflows.bats` — workflow-validointi läpi
- [ ] `isContainerBuilt`-check toimii: `git tag --points-at HEAD`
- [ ] Docker-labelit injektoitu: `git.commit`, `build.date`, `version`
- [ ] Test flow -ketju dispatchaa jokaisen stepin järjestyksessä
- [ ] Dogfood: kirjaston oma master-build käyttää tätä
- [ ] Kaikki skriptit (00010004) integroitu workflow'hun
---
## Toiminto
Master-branchin CI-workflow. Orkestroi koko build-test-deploy -ketjun: buildaa kontin, tagittaa commitin, ketjuttaa test flow'n `ci-flow-values.yaml`-konfiguraation mukaan.
## Trigger
`workflow_call` (reusable workflow)
## Inputs
| Parametri | Pakollinen | Kuvaus |
|-----------|------------|--------|
| `config-file` | Kyllä | Polku `ci-flow-values.yaml`:aan |
| `maven-image` | Ei | Maven-kontti |
| `docker-image` | Ei | Docker-in-Docker image |
## Steppit
```
start
→ isContainerBuilt? ──kyllä──→ skip build, continueToTestFlow
→ ei
→ unit-test → quality-gate → build-jar → build-docker → push-docker
→ tag-commit → continueToTestFlow → publish-html → end
```
| Steppi | Skripti / Toiminto |
|--------|-------------------|
| `start` | `report-status.sh pending "Building..."` |
| `isContainerBuilt` | `git tag --points-at HEAD` — onko jo buildattu? |
| `unit-test` | Projektin oma testiajo |
| `quality-gate` | SonarQube quality gate -pollaus |
| `build-jar` | `mvn package` / `gradle build` |
| `build-docker` | `docker build` + Docker-labelit |
| `push-docker` | `docker push` → Gitea Packages |
| `tag-commit` | `tag-commit.sh {version}` |
| `continueToTestFlow` | `dispatch-workflow.sh` jokaiselle test-flow -stepille |
| `publish-html` | `push-reports.sh` — Maven Site + muut |
| `end` | `report-status.sh success/failure` |
## Test flow -ketjutus
```yaml
# ci-flow-values.yaml — test-flow-taulu
test-flow:
- deploy: development
wait: true
- test:
name: "integration fast"
repo: tests/integration
workflow: test.yml
ref: main
tags: "@temperature and not @slow"
- deploy: staging
wait: true
- test:
name: e2e
repo: tests/e2e
workflow: test.yml
ref: main
```
Workflow iteroi `test-flow`-taulun ja kutsuu `dispatch-workflow.sh` jokaiselle stepille:
```bash
for step in test-flow; do
dispatch-workflow.sh {step.repo} {step.workflow} {step.ref} '{...inputs...}'
done
```
## Concurrency
```yaml
concurrency:
group: master-${{ github.repository }}
cancel-in-progress: false
```
## Verifiointi
Simuloi koko master flow paikallisesti:
1. `isContainerBuilt` = false → build kontti
2. `tag-commit.sh` → tagi ilmestyy commitille
3. `isContainerBuilt` = true uusinta-ajossa → build skipataan
4. `dispatch-workflow.sh` kutsuu deploy → test → e2e ketjun
5. Kaikki statusviestit näkyvät oikeissa commiteissa
## Viitteet
- `docs/workflows.md``ci-master.yml` — Master / release-branch
- `docs/config-model.md``isContainerBuild()`, Docker-labelit, test-flow-taulukko
- `docs/design-rationale.md` — Periaate 7: Cross-repo commit traceability