init monorepo
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 22s
unit-tests Link to Bats reports
CI Feature / Bats tests (push) Successful in 1m38s
acc-tests Link to Cucumber reports
CI Feature / Cucumber tests (push) Successful in 1m2s
CI Feature / Report Summary (push) Successful in 5s
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 22s
unit-tests Link to Bats reports
CI Feature / Bats tests (push) Successful in 1m38s
acc-tests Link to Cucumber reports
CI Feature / Cucumber tests (push) Successful in 1m2s
CI Feature / Report Summary (push) Successful in 5s
This commit is contained in:
+123
-1
@@ -40,7 +40,7 @@ Jos buildaat Docker-kontteja, lisää:
|
||||
```ini
|
||||
DOCKER_REGISTRY=gitea.example.com/myorg
|
||||
DOCKER_IMAGE_NAME=my-service
|
||||
DOCKER_UI_URL=https://gitea.example.com/myorg/-/packages/container/my-service
|
||||
DOCKER_UI_URL=https://gitea.example.com/myorg/-/packages/container
|
||||
#DOCKERFILE=Dockerfile.platform # valinnainen, oletus Dockerfile
|
||||
```
|
||||
|
||||
@@ -361,6 +361,128 @@ Gitean Settings → Branches → Add Rule:
|
||||
|
||||
---
|
||||
|
||||
## Monorepo
|
||||
|
||||
Monorepossa yhdestä repossa asuu useampi julkaistava komponentti (esim.
|
||||
`api/`, `frontend/`). Ratkaisu on yksinkertainen: jokaiselle komponentille
|
||||
oma conf-tiedosto, jossa on kaikki komponenttikohtainen tieto. Ei
|
||||
ylöslyöntejä pipelinessa — pelkkä `config_path:` riittää.
|
||||
|
||||
### Ongelmat ja ratkaisut
|
||||
|
||||
| Ongelma | Ratkaisu |
|
||||
|---|---|
|
||||
| Monta komponenttia, yksi repo — mikä triggeröi? | `paths:`-filtteri consumer-workflowssa: `push: { paths: ['api/**'] }` |
|
||||
| Jokaisella komponentilla oma versio | `VERSION_FILE=api/package.json` conf-tiedostossa, `check-version.yml` lukee tämän |
|
||||
| Git-tägit sekaisin ellei nimiavaruutta | `GIT_TAG_PREFIX=api/` confissa → tägi `api/1.2.3` |
|
||||
| Eri julkaisutahdit — api voi mennä 3.1 samalla kun frontend on 1.5 | Riippumattomat CI-triggerit, omat versiopolut |
|
||||
|
||||
Kaikki komponenttikohtainen tieto on conf-tiedostossa. `config-provider.yml`
|
||||
lukee confin sellaisenaan → `GIT_TAG_PREFIX`, `VERSION_FILE`, `DOCKER_IMAGE_NAME`
|
||||
menevät `env_json`:ään automaattisesti. `check-version.yml` ja
|
||||
`docker-build-push.yml` lukevat ne sieltä.
|
||||
|
||||
### Komponenttikohtainen conf-tiedosto
|
||||
|
||||
Kaikki conf-tiedostot ovat `.gitea/workflows/`-kansiossa, komponenttikohtaisesti
|
||||
nimettynä:
|
||||
|
||||
```
|
||||
.gitea/workflows/api.gitea-env.conf:
|
||||
GITEA_API_URL=https://gitea.example.com
|
||||
GIT_PAGES_URL=https://reports.example.com
|
||||
DOCKER_REGISTRY=gitea.example.com/myorg
|
||||
DOCKER_IMAGE_NAME=agent-platform-api
|
||||
DOCKER_UI_URL=https://gitea.example.com/myorg/-/packages/container
|
||||
GIT_TAG_PREFIX=api/
|
||||
VERSION_FILE=api/package.json
|
||||
|
||||
.gitea/workflows/frontend.gitea-env.conf:
|
||||
GITEA_API_URL=https://gitea.example.com
|
||||
GIT_PAGES_URL=https://reports.example.com
|
||||
DOCKER_REGISTRY=gitea.example.com/myorg
|
||||
DOCKER_IMAGE_NAME=agent-platform-frontend
|
||||
DOCKER_UI_URL=https://gitea.example.com/myorg/-/packages/container
|
||||
GIT_TAG_PREFIX=frontend/
|
||||
VERSION_FILE=frontend/package.json
|
||||
```
|
||||
|
||||
### Consumer-workflow monorepolle
|
||||
|
||||
Jokainen komponentti saa oman CI-tiedoston. Ainoa parametri on `config_path`:
|
||||
|
||||
`ci-api-main.yml`:
|
||||
```yaml
|
||||
name: CI API Main
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'api/**'
|
||||
|
||||
jobs:
|
||||
load-config:
|
||||
uses: org/gitea-ci-library/.gitea/workflows/config-provider.yml@v1
|
||||
secrets: inherit
|
||||
with:
|
||||
config_path: .gitea/workflows/api.gitea-env.conf
|
||||
|
||||
check-version:
|
||||
needs: [load-config]
|
||||
uses: org/gitea-ci-library/.gitea/workflows/check-version.yml@v1
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
|
||||
unit-tests:
|
||||
needs: [load-config, check-version]
|
||||
if: needs.check-version.outputs.artifact_exists != 'true'
|
||||
uses: ./.gitea/workflows/ci-api-tests.yml@main
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
|
||||
build-push:
|
||||
needs: [load-config, check-version, unit-tests]
|
||||
if: needs.check-version.outputs.artifact_exists != 'true'
|
||||
uses: org/gitea-ci-library/.gitea/workflows/docker-build-push.yml@v1
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
version: ${{ needs.check-version.outputs.version }}
|
||||
```
|
||||
|
||||
### Version elinkaari per komponentti
|
||||
|
||||
`GIT_TAG_PREFIX` takaa että eri komponenttien versiohistoria pysyy erillään.
|
||||
Git-tägi `api/0.2.3` ei sekoitu frontendin tägiin `frontend/1.5.0` —
|
||||
vaikka molemmat asuvat samassa repossa.
|
||||
|
||||
`check-version.yml` suodattaa ja laskee seuraavan patchin vain kyseisen
|
||||
komponentin etuliitteellä. Kun `api/`:n `package.json` on `0.2` ja tägit
|
||||
ovat `api/0.2.0`, `api/0.2.1` → seuraava on `api/0.2.2`. Frontendin
|
||||
`1.5.0` jätetään huomiotta tässä laskennassa — eri komponentti, täysin
|
||||
itsenäinen.
|
||||
|
||||
### Artifaktin tallennus ja idempotenttius
|
||||
|
||||
Idempotenttius toimii komponenttikohtaisesti: jos commitilla on jo
|
||||
`api/0.2.3`-tägi, api:n pipeline skipataan `if: artifact_exists != 'true'`.
|
||||
Frontendin tägit eivät vaikuta api:n idempotenttiuteen — jokainen
|
||||
komponentti tarkistaa vain omat täginsä.
|
||||
|
||||
### Mitä EI kannata tehdä
|
||||
|
||||
- Älä aja kaikkia komponentteja samasta triggeristä — `paths:` pitää
|
||||
CI:t erillisinä ja julkaisutahdit itsenäisinä
|
||||
- Älä käytä samaa versionhallintatiedostoa usealle komponentille — jokaisella
|
||||
oma `package.json` / `VERSION`
|
||||
- Älä sekoita `DOCKER_UI_URL`:ään image-nimeä confissa — URL on puhdas
|
||||
container-registryn osoite, image-nimi lisätään automaattisesti
|
||||
- Älä anna monorepo-parametreja `config-provider.yml`:n kautta — kaikki
|
||||
kuuluu komponentin omaan conf-tiedostoon
|
||||
|
||||
## Raporttien koonti (Gitea 1.27+)
|
||||
|
||||
Kun Gitea päivittyy versioon 1.27, `GITHUB_STEP_SUMMARY`-tuki mahdollistaa
|
||||
|
||||
Reference in New Issue
Block a user