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 "${SHA8}Commit: ${GITHUB_SHA}
Branch: ${GITHUB_REF_NAME}
Run: ${GITHUB_RUN_ID}
| Suite | Passed | Failed | Report |
|---|---|---|---|
| Bats | ${BATS_PASS} | ${BATS_FAIL} | " + echo "results.txt" + echo " | junit.xml |
| Cucumber | ${CUCUMBER_PASS} | ${CUCUMBER_FAIL} | " + echo "report" + echo " | json |
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" <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