diff --git a/.gitea/workflows/ci-validate.yml b/.gitea/workflows/ci-validate.yml deleted file mode 100644 index bc2e62a..0000000 --- a/.gitea/workflows/ci-validate.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CI Validate -on: - workflow_call: - inputs: - env_json: - required: true - type: string - config_path: - required: true - type: string - secrets: - GITEA_TOKEN: - required: true - GIT_PAGES_PUBLISH_TOKEN: - required: true - -env: - GITEA_API_URL: ${{ fromJson(inputs.env_json).GITEA_API_URL }} - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} - CI_CONF_FILE: ${{ inputs.config_path }} - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 - with: - repository: niko/gitea-ci-library - path: .ci - - - name: Validate CI config - run: bash .ci/scripts/ci-validate.sh diff --git a/.gitea/workflows/config-provider.yml b/.gitea/workflows/config-provider.yml index ebbc750..3a25bd7 100644 --- a/.gitea/workflows/config-provider.yml +++ b/.gitea/workflows/config-provider.yml @@ -1,16 +1,26 @@ -name: Config Provider Library +name: Config Provider on: workflow_call: inputs: config_path: required: true type: string + secrets: + GITEA_TOKEN: + required: true + GIT_PAGES_PUBLISH_TOKEN: + required: true outputs: env_json: value: ${{ jobs.parse-config.outputs.json_data }} config_path: value: ${{ jobs.parse-config.outputs.config_path }} +env: + CI_CONF_FILE: ${{ inputs.config_path }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} + jobs: parse-config: runs-on: ubuntu-latest @@ -19,6 +29,13 @@ jobs: config_path: ${{ steps.set-path.outputs.CONFIG_PATH }} steps: - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: niko/gitea-ci-library + path: .ci + + - name: Validate CI config + run: bash .ci/scripts/ci-validate.sh - id: convert run: | diff --git a/.gitea/workflows/docker-build-push.yml b/.gitea/workflows/docker-build-push.yml index fe117ef..88c4096 100644 --- a/.gitea/workflows/docker-build-push.yml +++ b/.gitea/workflows/docker-build-push.yml @@ -38,11 +38,6 @@ jobs: repository: niko/gitea-ci-library path: .ci - - name: Set Gitea status to PENDING - run: | - echo "===== gitea-ci-library - Docker Build & Push | begin =====" - bash .ci/scripts/report-status.sh pending "Building and pushing Docker image..." ci-docker-build-push - - name: Build and push container env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME || github.actor }} diff --git a/.gitea/workflows/example-bats-tests.yml b/.gitea/workflows/example-bats-tests.yml index 46b5a27..64696b4 100644 --- a/.gitea/workflows/example-bats-tests.yml +++ b/.gitea/workflows/example-bats-tests.yml @@ -30,9 +30,6 @@ jobs: repository: niko/gitea-ci-library path: .ci - - name: Pending - run: bash .ci/scripts/report-status.sh pending "Running Bats tests..." ci-bats - - name: Run bats tests id: bats-tests shell: bash @@ -61,7 +58,7 @@ jobs: if: always() run: | if [ "${BATS_EXIT}" = "0" ]; then - bash .ci/scripts/report-status.sh success "Bats tests OK" ci-bats bats + bash .ci/scripts/report-status.sh success "Link to Bats reports" unit-tests bats else - bash .ci/scripts/report-status.sh failure "Bats tests FAILED" ci-bats bats + bash .ci/scripts/report-status.sh failure "Link to Bats reports" unit-tests bats fi diff --git a/.gitea/workflows/example-cucumber-tests.yml b/.gitea/workflows/example-cucumber-tests.yml index 612a14d..b52e9da 100644 --- a/.gitea/workflows/example-cucumber-tests.yml +++ b/.gitea/workflows/example-cucumber-tests.yml @@ -32,9 +32,6 @@ jobs: repository: niko/gitea-ci-library path: .ci - - name: Pending - run: bash .ci/scripts/report-status.sh pending "Running Cucumber tests..." ci-cucumber - - name: Run cucumber tests id: cucumber-tests shell: bash @@ -60,14 +57,14 @@ jobs: run: | if [ "${CUCUMBER_EXIT}" = "0" ]; then if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then - bash .ci/scripts/report-status.sh success "Cucumber tests OK" ci-cucumber cucumber + bash .ci/scripts/report-status.sh success "Link to Cucumber reports" acc-tests cucumber else - bash .ci/scripts/report-status.sh success "Cucumber tests OK" ci-cucumber + bash .ci/scripts/report-status.sh success "Link to Cucumber reports" acc-tests fi else if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then - bash .ci/scripts/report-status.sh failure "Cucumber tests FAILED" ci-cucumber cucumber + bash .ci/scripts/report-status.sh failure "Link to Cucumber reports" acc-tests cucumber else - bash .ci/scripts/report-status.sh failure "Cucumber tests FAILED" ci-cucumber + bash .ci/scripts/report-status.sh failure "Link to Cucumber reports" acc-tests fi fi diff --git a/.gitea/workflows/example-feature.yml b/.gitea/workflows/example-feature.yml index 8369998..3877496 100644 --- a/.gitea/workflows/example-feature.yml +++ b/.gitea/workflows/example-feature.yml @@ -8,18 +8,10 @@ on: jobs: load-config: name: Load example-gitea-env.conf to pipeline env - uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@main - with: - config_path: .gitea/workflows/example-gitea-env.conf - - validate: - name: Validate CI config - needs: [load-config] - uses: niko/gitea-ci-library/.gitea/workflows/ci-validate.yml@feature/docker-kuntoon + uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@feature/docker-kuntoon secrets: inherit with: - env_json: ${{ needs.load-config.outputs.env_json }} - config_path: ${{ needs.load-config.outputs.config_path }} + config_path: .gitea/workflows/example-gitea-env.conf bats: name: Bats tests diff --git a/.gitea/workflows/example-main.yml b/.gitea/workflows/example-main.yml index 44837bd..e4e73c3 100644 --- a/.gitea/workflows/example-main.yml +++ b/.gitea/workflows/example-main.yml @@ -8,7 +8,8 @@ on: jobs: load-config: 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 with: config_path: .gitea/workflows/example-gitea-env.conf @@ -20,16 +21,6 @@ jobs: with: env_json: ${{ needs.load-config.outputs.env_json }} - validate: - name: Validate CI config - needs: [load-config, check-version] - if: needs.check-version.outputs.artifact_exists != 'true' - uses: niko/gitea-ci-library/.gitea/workflows/ci-validate.yml@feature/docker-kuntoon - secrets: inherit - with: - env_json: ${{ needs.load-config.outputs.env_json }} - config_path: ${{ needs.load-config.outputs.config_path }} - bats: name: Bats tests needs: [load-config, check-version] diff --git a/docs/adr/0007-status-reporting-pattern.md b/docs/adr/0007-status-reporting-pattern.md index 7815f62..ed7df16 100644 --- a/docs/adr/0007-status-reporting-pattern.md +++ b/docs/adr/0007-status-reporting-pattern.md @@ -22,13 +22,10 @@ Ei API-kutsuja. Luotetaan Gitean omaan job-statukseen. API:a käytetään raporttilinkin upottamiseksi commit-näkymään. ``` -PENDING → testit → publish (always) → status (always, exit-koodin mukaan) +testit → publish (always) → status (always, exit-koodin mukaan) ``` ```yaml -- name: Set Gitea status to PENDING - run: bash .ci/scripts/report-status.sh pending "Running tests..." ci-bats - - name: Run tests shell: bash run: | @@ -46,9 +43,9 @@ PENDING → testit → publish (always) → status (always, exit-koodin mukaan) shell: bash run: | if [ "${EXIT}" = "0" ]; then - bash .ci/scripts/report-status.sh success "Bats tests OK" ci-bats bats + bash .ci/scripts/report-status.sh success "Link to Bats reports" unit-tests bats else - bash .ci/scripts/report-status.sh failure "Bats tests FAILED" ci-bats bats + bash .ci/scripts/report-status.sh failure "Link to Bats reports" unit-tests bats fi ``` @@ -57,13 +54,13 @@ PENDING → testit → publish (always) → status (always, exit-koodin mukaan) API:a käytetään Docker registry -linkin upottamiseksi. ``` -PENDING → build → push → SUCCESS (registry-linkillä) / FAILURE +build → push → SUCCESS (registry-linkillä) / FAILURE ``` ## Periaatteet -1. Gitea Actionsin natiivi job-status on ensisijainen. API:a käytetään vain - custom-linkin tarpeeseen (ADR 0004). +1. Gitea Actionsin natiivi job-status on ensisijainen — myös PENDING/Running-tila + tulee natiivisti. API:a käytetään vain custom-linkin tarpeeseen (ADR 0004). 2. `run`-komennon on nostettava virhe ylös — oli kyse tool-callista tai testivirheestä (ADR 0008). 3. Test-jobit käyttävät `if: always()` publish- ja status-stepeissä — raportti