diff --git a/.gitea/workflows/build-feature.yml b/.gitea/workflows/build-feature.yml new file mode 100644 index 0000000..5957d51 --- /dev/null +++ b/.gitea/workflows/build-feature.yml @@ -0,0 +1,71 @@ +name: Build Feature +on: + workflow_call: + +jobs: + pipeline: + runs-on: ubuntu-latest + env: + GITEA_API_URL: https://gitea.app.keskikuja.site + PAGES_HOST: ci-reports.helm-dev.keskikuja.site + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: niko/gitea-ci-library + path: .ci + + - name: Bats tests + continue-on-error: true + run: | + mkdir -p "reports/${GITHUB_SHA:0:8}/bats" + bats --formatter junit tests/*.bats > "reports/${GITHUB_SHA:0:8}/bats/junit.xml" 2>&1 || \ + bats tests/*.bats > "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1 + + - name: Cucumber tests + continue-on-error: true + run: | + mkdir -p "reports/${GITHUB_SHA:0:8}/cucumber" + npx cucumber-js \ + --format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json" \ + --format html:"reports/${GITHUB_SHA:0:8}/cucumber/index.html" 2>&1 || \ + npx cucumber-js \ + --format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json" + + - name: Generate report index + run: | + SHA8="${GITHUB_SHA:0:8}" + BATS_PASS=$(grep -c 'ok' "reports/${SHA8}/bats/results.txt" 2>/dev/null || echo 0) + BATS_FAIL=$(grep -c 'not ok' "reports/${SHA8}/bats/results.txt" 2>/dev/null || echo 0) + CUCUMBER_PASS=$(jq '.summary.passed // 0' "reports/${SHA8}/cucumber/report.json" 2>/dev/null || echo 0) + CUCUMBER_FAIL=$(jq '.summary.failed // 0' "reports/${SHA8}/cucumber/report.json" 2>/dev/null || echo 0) + { + echo "" + echo "CI report ${SHA8}" + echo "" + echo "

CI report ${SHA8}

" + echo "

Commit: ${GITHUB_SHA}
Branch: ${GITHUB_REF_NAME}
Run: ${GITHUB_RUN_ID}

" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "
SuitePassedFailedReport
Bats${BATS_PASS}${BATS_FAIL}results.txt" + echo " | junit.xml
Cucumber${CUCUMBER_PASS}${CUCUMBER_FAIL}report" + echo " | json
" + } > "reports/${SHA8}/index.html" + + - name: Set commit status + run: | + bash .ci/scripts/report-status.sh success \ + "Tests passed" \ + "https://${PAGES_HOST}/${GITHUB_REPOSITORY}/reports/${GITHUB_SHA:0:8}/" \ + ci-tests + + - name: Publish reports + run: | + bash .ci/scripts/publish-git-pages.sh "reports/${GITHUB_SHA:0:8}" diff --git a/.gitea/workflows/ci-engine.yml b/.gitea/workflows/ci-engine.yml index c4384aa..79f2565 100644 --- a/.gitea/workflows/ci-engine.yml +++ b/.gitea/workflows/ci-engine.yml @@ -1,89 +1,29 @@ name: CI Engine on: workflow_call: + inputs: + config-file: + required: true + type: string + secrets: + GITEA_TOKEN: + required: true + GIT_PAGES_PUBLISH_TOKEN: + required: true jobs: - unit: + publish: runs-on: ubuntu-latest env: - GITEA_API_URL: https://gitea.app.keskikuja.site - PAGES_HOST: ci-reports.helm-dev.keskikuja.site - GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site - GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} steps: - uses: actions/checkout@v4 - - name: Generate unit test report - run: | - SHA8="${GITHUB_SHA:0:8}" - mkdir -p "reports/${SHA8}" - cat > "reports/${SHA8}/unit-tests.html" < - - Unit tests - ${SHA8} - -

Unit Tests

-

Commit: ${GITHUB_SHA}

-

Branch: ${GITHUB_REF_NAME}

-

Status: passed

- - - EOF + - name: Publish reports + run: bash scripts/publish.sh reports - - name: Publish unit test report - id: publish-unit + - name: Set commit status run: | - REPORT_BASE=$(bash scripts/publish-git-pages.sh "reports/${GITHUB_SHA:0:8}") - echo "report_url=${REPORT_BASE}/unit-tests.html" >> "${GITHUB_OUTPUT}" - - - name: Set unit test commit status - run: | - bash scripts/report-status.sh \ - success \ - "Unit tests passed" \ - "${{ steps.publish-unit.outputs.report_url }}" \ - "ci-unit" - - build: - needs: [unit] - runs-on: ubuntu-latest - env: - GITEA_API_URL: https://gitea.app.keskikuja.site - PAGES_HOST: ci-reports.helm-dev.keskikuja.site - GIT_PAGES_PUBLISH_URL: https://ci-reports.helm-dev.keskikuja.site - GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }} - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - steps: - - uses: actions/checkout@v4 - - - name: Generate build report - run: | - SHA8="${GITHUB_SHA:0:8}" - mkdir -p "reports/${SHA8}" - cat > "reports/${SHA8}/build-report.html" < - - Docker build - ${SHA8} - -

Docker Build

-

Commit: ${GITHUB_SHA}

-

Image: app:${GITHUB_RUN_NUMBER}

-

Status: pushed

- - - EOF - - - name: Publish build report - id: publish-build - run: | - REPORT_BASE=$(bash scripts/publish-git-pages.sh "reports/${GITHUB_SHA:0:8}") - echo "report_url=${REPORT_BASE}/build-report.html" >> "${GITHUB_OUTPUT}" - - - name: Set build commit status - run: | - bash scripts/report-status.sh \ - success \ - "Container built & pushed" \ - "${{ steps.publish-build.outputs.report_url }}" \ - "ci-build" + REPORT_URL="https://${PAGES_HOST}/${GITHUB_REPOSITORY}/reports/${GITHUB_SHA:0:8}/" + bash scripts/report-status.sh success "Reports published" "$REPORT_URL" ci-publish