diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 601b0f4..6b40c0a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: config_path: .gitea/workflows/gitea-env.conf feature: + name: Quality Gate if: github.ref != 'refs/heads/main' needs: [load-config] uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@feture/docker-kyky diff --git a/.gitea/workflows/quality-gate.yml b/.gitea/workflows/quality-gate.yml index 4017334..6ae0114 100644 --- a/.gitea/workflows/quality-gate.yml +++ b/.gitea/workflows/quality-gate.yml @@ -52,7 +52,7 @@ jobs: set +e mkdir -p "reports/${GITHUB_SHA:0:8}/bats" docker run --rm \ - -v "$(pwd):/repo:ro" \ + -v "$(pwd):/repo" \ -v "$(pwd)/reports/${GITHUB_SHA:0:8}/bats:/reports" \ -w /repo \ --entrypoint bash ${{ inputs.bats-image }} \ @@ -95,17 +95,7 @@ jobs: --format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json" \ --format html:"reports/${GITHUB_SHA:0:8}/cucumber/index.html" 2>&1 CUCUMBER_EXIT=$? - echo "CUCUMBER_EXIT=${CUCUMBER_EXIT}" >> "${GITHUB_ENV}" - exit ${CUCUMBER_EXIT} - - name: Publish cucumber reports - if: always() - run: bash .ci/scripts/publish-git-pages.sh cucumber - - - name: Set cucumber commit status - if: always() - shell: bash - run: | STATE="success" [ "${CUCUMBER_EXIT}" != "0" ] && STATE="failure" if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then @@ -114,6 +104,12 @@ jobs: bash .ci/scripts/report-status.sh "${STATE}" "Cucumber tests" ci-cucumber fi + exit ${CUCUMBER_EXIT} + + - name: Publish cucumber reports + if: always() + run: bash .ci/scripts/publish-git-pages.sh cucumber + build: runs-on: ubuntu-latest needs: [bats, cucumber] diff --git a/docs/ci-pipeline-practices.md b/docs/ci-pipeline-practices.md index 0115681..4f9ebd3 100644 --- a/docs/ci-pipeline-practices.md +++ b/docs/ci-pipeline-practices.md @@ -111,7 +111,43 @@ Avainkomponentit: - Jokainen testisetti omassa jobissaan - Finalize/build voi kerätä yhteenvedon (ei julkaista summarya jos kenelläkään ei ole linkkiä) -## 7. Inline Logic Threshold +## 7. Commit Status Before Exit + +Commit status (`ci-bats`, `ci-cucumber`) on asetettava **ennen** stepin +`exit`-komentoa, samassa shell-prosessissa. Ei `GITHUB_ENV`-propagointiin +luottamista stepien välillä — Gitea Actions ei välttämättä prosessoi +`GITHUB_ENV`-tiedostoa epäonnistuneen stepin jälkeen. + +Käytäntö testi-stepissä: + +``` +testit_ajoon +EXIT=$? + +STATE="success" +[ "${EXIT}" != "0" ] && STATE="failure" + +# Jos raportti on kirjoitettu levylle → linkki git-pagesiin +if [ -f "reports/${SHA8}/sute/index.html" ]; then + bash .ci/scripts/report-status.sh "${STATE}" "Kuvaus" ci-{suite} {suite} +else + # Muuten linkki Gitea Actions logiin + bash .ci/scripts/report-status.sh "${STATE}" "Kuvaus" ci-{suite} +fi + +exit ${EXIT} +``` + +Tämä takaa: + +- Aina commit status riippumatta siitä, onko kyseessä tool- vai test error +- Oikea URL: raportti git-pagesissa (jos tiedosto on kirjoitettu) tai Gitea Actions logeissa +- PR merge-esto toimii luotettavasti: branch protection näkee statuksen + aina, koska se kirjoitetaan ennen stepin failaamista + +Julkaisu (`publish-git-pages.sh`) jää edelleen omaksi stepikseen `if: always()`:lla. + +## 8. Inline Logic Threshold Logiikka workflow YAML:ssa on hauras: YAML:n sisennys, heredocit ja kenoviivat tuottavat helposti toimimattomia steppejä.