feat: refactor config flow and directory structure
- Create config-provider.yml (reusable workflow, conf→JSON) - Replace duplicated job env blocks with workflow env + fromJson - Move provider workflows to workflows/ directory - Move consumer scripts to .gitea/scripts/ - Move feature-env.conf to .gitea/workflows/ - Add bats-report.sh for TAP→HTML conversion - Update ci.yml with setup→needs→with pattern - Add ADR 0006 directory ownership - Document cross-job config propagation in ci-pipeline-practices.md - Remove config.yaml, scripts/load-config.sh unused
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPORT_DIR="${1:-reports/bats}"
|
||||
INPUT="$REPORT_DIR/results.txt"
|
||||
OUTPUT="$REPORT_DIR/index.html"
|
||||
|
||||
[ -f "$INPUT" ] || { echo "ERROR: $INPUT not found" >&2; exit 1; }
|
||||
|
||||
TOTAL=$(grep -cE '^(ok|not ok) ' "$INPUT" 2>/dev/null || echo 0)
|
||||
PASS=$(grep -c '^ok ' "$INPUT" 2>/dev/null || echo 0)
|
||||
FAIL=$((TOTAL - PASS))
|
||||
|
||||
{
|
||||
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
|
||||
echo "<title>Bats test report ${GITHUB_SHA:0:8}</title>"
|
||||
echo '<style>body{font-family:sans-serif;margin:2em;max-width:960px}'
|
||||
echo 'h1{color:#1e293b}.pass{color:#059669}.fail{color:#dc2626}'
|
||||
echo 'table{width:100%;border-collapse:collapse;margin-top:1em}'
|
||||
echo 'th,td{border:1px solid #e2e8f0;padding:8px;text-align:left}'
|
||||
echo 'th{background:#f8fafc}</style></head><body>'
|
||||
echo "<h1>Bats test report <code>${GITHUB_SHA:0:8}</code></h1>"
|
||||
echo "<p>Total: ${TOTAL} | Passed: <span class='pass'>${PASS}</span> | Failed: <span class='fail'>${FAIL}</span></p>"
|
||||
echo '<table><tr><th>#</th><th>Status</th><th>Test</th></tr>'
|
||||
|
||||
while IFS=' ' read -r status num rest; do
|
||||
case "$status" in
|
||||
ok) echo "<tr><td>${num}</td><td class='pass'>PASS</td><td>${rest}</td></tr>" ;;
|
||||
not) echo "<tr><td>${num}</td><td class='fail'>FAIL</td><td>${rest}</td></tr>" ;;
|
||||
esac
|
||||
done < <(grep -E '^(ok|not ok) ' "$INPUT")
|
||||
|
||||
echo '</table></body></html>'
|
||||
} > "$OUTPUT"
|
||||
|
||||
echo "$OUTPUT"
|
||||
@@ -45,15 +45,7 @@ jobs:
|
||||
> "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
|
||||
BATS_EXIT=$?
|
||||
docker volume rm bats-workspace > /dev/null 2>&1
|
||||
{
|
||||
echo "<html><body><h1>Bats tests</h1><ul>"
|
||||
for f in reports/${GITHUB_SHA:0:8}/bats/*; do
|
||||
b="$(basename $f)"
|
||||
[ "$b" = "index.html" ] && continue
|
||||
echo "<li><a href=\"$b\">$b</a></li>"
|
||||
done
|
||||
echo "</ul></body></html>"
|
||||
} > "reports/${GITHUB_SHA:0:8}/bats/index.html"
|
||||
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats"
|
||||
echo "BATS_EXIT=${BATS_EXIT}" >> "${GITHUB_ENV}"
|
||||
exit ${BATS_EXIT}
|
||||
|
||||
@@ -137,7 +129,7 @@ jobs:
|
||||
if [ "${TOOL_OK}" != "true" ]; then
|
||||
STATUS="failure"
|
||||
DESC="Cucumber tool unavailable"
|
||||
URL="https://gitea.app.keskikuja.site/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
|
||||
URL="${GITEA_API_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
|
||||
elif [ "${CUCUMBER_EXIT}" = "0" ]; then
|
||||
STATUS="success"
|
||||
DESC="Cucumber tests passed"
|
||||
|
||||
@@ -6,9 +6,9 @@ on:
|
||||
|
||||
jobs:
|
||||
load-config:
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@feature/pipeline-cleanup
|
||||
uses: niko/gitea-ci-library/workflows/config-provider.yml@feature/pipeline-cleanup
|
||||
with:
|
||||
config_path: feature-env.conf
|
||||
config_path: .gitea/workflows/feature-env.conf
|
||||
|
||||
feature:
|
||||
if: github.ref != 'refs/heads/main'
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# 6. Directory ownership — provider vs consumer
|
||||
|
||||
## Päätös
|
||||
|
||||
Provider-repossa (`gitea-ci-library`) on seuraavat kansiot ja tiedostot,
|
||||
joilla on eri omistajuus- ja näkyvyyssäännöt:
|
||||
|
||||
| Kansio | Omistaja | Näkyvyys | Tyyppi |
|
||||
|--------|----------|----------|--------|
|
||||
| `workflows/` | Provider | Consumer kutsuu `uses:` | Reusable workflowt |
|
||||
| `scripts/` | Provider | Vain providerin sisäinen | Bash-skriptit |
|
||||
| `.gitea/workflows/` | Consumer | Consumerin oma pipeline | Pipeline-logiikka |
|
||||
| `.gitea/scripts/` | Consumer | Consumerin oma | Consumer-skriptit |
|
||||
| `.gitea/workflows/feature-env.conf` | Consumer | Consumerin konffi | KEY=VALUE config |
|
||||
|
||||
## Perustelu
|
||||
|
||||
### Providerin `workflows/` (juuressa)
|
||||
|
||||
Providerin reusable workflow -tiedostot, joita consumer kutsuu
|
||||
`uses:`-direktiivillä. Consumerilla on lukunäkyvyys mutta ei
|
||||
muokkausvastuuta. Esimerkki:
|
||||
|
||||
```yaml
|
||||
uses: niko/gitea-ci-library/workflows/config-provider.yml@v1
|
||||
```
|
||||
|
||||
Tämä on providerin julkinen rajapinta. Sijainti `workflows/` (juuressa)
|
||||
eikä `.gitea/workflows/` korostaa, että kyseessä on providerin tarjoama
|
||||
palvelu, ei consumerin oma pipeline.
|
||||
|
||||
### Providerin `scripts/` (juuressa)
|
||||
|
||||
Providerin sisäiset työkalut. Consumer ei koskaan kutsu näitä suoraan —
|
||||
vain providerin workflowt kutsuvat tupla checkoutin kautta:
|
||||
`.ci/scripts/publish-git-pages.sh`.
|
||||
|
||||
Consumerilla ei ole suoraa polkua näihin tiedostoihin — ne saavuttaa
|
||||
vain providerin workflowjen kautta, jotka tupla checkouttaa providerin.
|
||||
|
||||
### Consumerin `.gitea/workflows/`
|
||||
|
||||
Consumerin oma pipeline-logiikka. Consumer omistaa ja muokkaa.
|
||||
Provider ei koskaan ohita tätä kansiota — ADR 0005.
|
||||
|
||||
Tässä repossa (dogfood) consumer on sama repo, joten `.gitea/workflows/`
|
||||
näyttää providerin tiedostojen rinnalla. Arkkitehtuurisesti ne ovat
|
||||
erillisiä: jos consumer olisi eri repo, `.gitea/workflows/` olisi siellä.
|
||||
|
||||
### Consumerin `.gitea/scripts/`
|
||||
|
||||
Consumerin omat skriptit, jotka ovat osa consumerin pipeline-logiikkaa.
|
||||
Provider ei omista eikä ylläpidä näitä.
|
||||
|
||||
Consumer-skriptit kutsutaan consumerin workflowista ilman tupla
|
||||
checkouttia: `.gitea/scripts/bats-report.sh`.
|
||||
|
||||
### Consumerin `.gitea/workflows/feature-env.conf`
|
||||
|
||||
Consumerin konfiguraatiotiedosto consumerin omassa kansiossa.
|
||||
Providerin `config-provider.yml` lukee tämän ja muuntaa JSONiksi, mutta
|
||||
consumer omistaa sisällön.
|
||||
|
||||
## Vaikutukset
|
||||
|
||||
- Provider voi muuttaa `workflows/` ja `scripts/` -kansioiden sisältöä
|
||||
ilman consumerin hyväksyntää (versiovaihdon yhteydessä)
|
||||
- Consumer voi muuttaa `.gitea/workflows/` ja `.gitea/scripts/` -kansioiden
|
||||
sisältöä ilman providerin muutoksia
|
||||
- Providerin workflowt käyttävät `.ci/scripts/...` -polkua (tupla checkout)
|
||||
- Consumerin workflowt käyttävät `.gitea/scripts/...` -polkua (natiivi checkout)
|
||||
- Config-tiedoston muoto on consumerin päätettävissä — provider vain lukee
|
||||
|
||||
## Vertailu vanhaan rakenteeseen
|
||||
|
||||
| Entinen sijainti | Uusi sijainti | Peruste |
|
||||
|------------------|---------------|---------|
|
||||
| `.gitea/workflows/config-provider.yml` | `workflows/config-provider.yml` | Providerin julkinen rajapinta pois consumer-kansiosta |
|
||||
| `.gitea/workflows/ci-engine.yml` | `workflows/ci-engine.yml` | Sama peruste |
|
||||
| `scripts/bats-report.sh` | `.gitea/scripts/bats-report.sh` | Consumerin oma skripti |
|
||||
Reference in New Issue
Block a user