Feature/yksinkertaistetaan raportointi logiikkaa (#22)
unit-tests Bats test report
CI Main / Bats tests (push) Successful in 1m21s
ci-docker-build-push Docker build & push 0.2.9 OK
CI Main / Build & Push Docker (push) Successful in 40s
CI Main / Report Summary (push) Successful in 5s
CI Main / Move provider version tag (push) Successful in 12s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 18s
CI Main / Check existing artifact (push) Successful in 12s
acc-tests Cucumber test report
CI Main / Cucumber tests (push) Successful in 2m3s
unit-tests Bats test report
CI Main / Bats tests (push) Successful in 1m21s
ci-docker-build-push Docker build & push 0.2.9 OK
CI Main / Build & Push Docker (push) Successful in 40s
CI Main / Report Summary (push) Successful in 5s
CI Main / Move provider version tag (push) Successful in 12s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 18s
CI Main / Check existing artifact (push) Successful in 12s
acc-tests Cucumber test report
CI Main / Cucumber tests (push) Successful in 2m3s
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
@@ -1,37 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
WORKSPACE_VOLUME="${1:-}"
|
||||
REPORT_DIR="${2:-}"
|
||||
REPORT_DIR="${1:-}"
|
||||
COVERAGE_DIR="${REPORT_DIR}/coverage"
|
||||
|
||||
[ -n "$WORKSPACE_VOLUME" ] || { echo "ERROR: workspace volume name required" >&2; exit 1; }
|
||||
[ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; }
|
||||
|
||||
HAS_COVERAGE=false
|
||||
COVERAGE_SRC=""
|
||||
if docker run --rm -v "$WORKSPACE_VOLUME":/data alpine sh -c '[ -d /data/coverage ] && ls -A /data/coverage | grep -q .' 2>/dev/null; then
|
||||
COVERAGE_SRC="/data/coverage"
|
||||
if [ -d coverage ]; then
|
||||
mkdir -p "$COVERAGE_DIR"
|
||||
cp -a coverage/. "$COVERAGE_DIR/"
|
||||
fi
|
||||
|
||||
if [ -n "$COVERAGE_SRC" ]; then
|
||||
mkdir -p "$REPORT_DIR/coverage"
|
||||
docker run --rm -v "$WORKSPACE_VOLUME":/data alpine tar c -C "$COVERAGE_SRC" . | tar x -C "$REPORT_DIR/coverage"
|
||||
HAS_COVERAGE=true
|
||||
if [ -d "$COVERAGE_DIR" ] && [ ! -f "$COVERAGE_DIR/index.html" ]; then
|
||||
SHA8="${GITHUB_SHA:0:8}"
|
||||
{
|
||||
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
|
||||
echo "<title>Coverage report ${SHA8}</title>"
|
||||
echo '<style>body{font-family:sans-serif;margin:2em}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0}a{color:#2563eb}</style>'
|
||||
echo "</head><body><h1>Coverage report <code>${SHA8}</code></h1><ul>"
|
||||
while IFS= read -r -d '' f; do
|
||||
base=$(basename "$f")
|
||||
name="${base%.*}"
|
||||
name="${name//-/ }"
|
||||
echo "<li><a href=\"${base}\">${name^}</a></li>"
|
||||
done < <(find "$COVERAGE_DIR" -maxdepth 1 -type f \( -name '*.html' -o -name '*.txt' \) ! -name index.html -print0 2>/dev/null || true)
|
||||
echo '</ul></body></html>'
|
||||
} > "$COVERAGE_DIR/index.html"
|
||||
fi
|
||||
|
||||
cat > "$REPORT_DIR/index.html" << EOF
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">
|
||||
<title>Bats report ${GITHUB_SHA:0:8}</title>
|
||||
<style>body{font-family:sans-serif;margin:2em;max-width:960px}
|
||||
h1{color:#1e293b}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}
|
||||
</style></head><body>
|
||||
<h1>Bats report <code>${GITHUB_SHA:0:8}</code></h1>
|
||||
<ul>
|
||||
<li><a href="test-report.html">Test results</a></li>
|
||||
EOF
|
||||
|
||||
if [ "$HAS_COVERAGE" = true ]; then
|
||||
echo '<li><a href="coverage/index.html">Coverage report</a></li>' >> "$REPORT_DIR/index.html"
|
||||
fi
|
||||
|
||||
echo '</ul></body></html>' >> "$REPORT_DIR/index.html"
|
||||
|
||||
@@ -6,8 +6,9 @@ on:
|
||||
required: true
|
||||
type: string
|
||||
bats-image:
|
||||
required: true
|
||||
required: false
|
||||
type: string
|
||||
default: gitea.app.keskikuja.site/niko/ci-bats:latest
|
||||
secrets:
|
||||
GITEA_TOKEN:
|
||||
required: true
|
||||
@@ -23,6 +24,8 @@ env:
|
||||
jobs:
|
||||
bats:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ inputs.bats-image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
@@ -31,34 +34,18 @@ jobs:
|
||||
path: .ci
|
||||
|
||||
- name: Run bats tests
|
||||
id: bats-tests
|
||||
shell: bash
|
||||
run: |
|
||||
docker volume create bats-workspace
|
||||
tar c . | docker run --rm -i -v bats-workspace:/data alpine tar x -C /data
|
||||
mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
|
||||
set +e
|
||||
docker run --rm \
|
||||
-v bats-workspace:/data \
|
||||
--entrypoint bash ${{ inputs.bats-image }} \
|
||||
-c 'cd /data && bashcov -- bats tests/' \
|
||||
> "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
|
||||
BATS_EXIT=$?
|
||||
bash .ci/.gitea/scripts/bats-coverage.sh bats-workspace "reports/${GITHUB_SHA:0:8}/bats"
|
||||
docker volume rm bats-workspace > /dev/null 2>&1
|
||||
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats"
|
||||
echo "BATS_EXIT=${BATS_EXIT}" >> "${GITHUB_ENV}"
|
||||
exit ${BATS_EXIT}
|
||||
mkdir -p reports/bats
|
||||
bashcov -- bats tests/ > reports/bats/results.txt 2>&1
|
||||
|
||||
- name: Publish bats reports
|
||||
- name: Post-process coverage
|
||||
if: always()
|
||||
run: bash .ci/scripts/publish-git-pages.sh bats
|
||||
run: bash .ci/.gitea/scripts/bats-coverage.sh reports/bats
|
||||
|
||||
- name: Report status
|
||||
- name: Post-process test report
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${BATS_EXIT}" = "0" ]; then
|
||||
bash .ci/scripts/report-status.sh success "Link to Bats reports" unit-tests bats
|
||||
else
|
||||
bash .ci/scripts/report-status.sh failure "Link to Bats reports" unit-tests bats
|
||||
fi
|
||||
run: bash .ci/.gitea/scripts/bats-report.sh reports/bats
|
||||
|
||||
- name: Report
|
||||
if: always()
|
||||
run: bash .ci/scripts/ci-report.sh "Bats test report" unit-tests bats
|
||||
|
||||
@@ -25,14 +25,14 @@ on:
|
||||
|
||||
jobs:
|
||||
load-config:
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@v1
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@main
|
||||
secrets: inherit
|
||||
with:
|
||||
config_path: ${{ inputs.config_path }}
|
||||
|
||||
build-push:
|
||||
needs: [load-config]
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/ci-container-build-push.yml@v1
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/ci-container-build-push.yml@main
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
|
||||
@@ -6,8 +6,9 @@ on:
|
||||
required: true
|
||||
type: string
|
||||
cucumber-node-image:
|
||||
required: true
|
||||
required: false
|
||||
type: string
|
||||
default: gitea.app.keskikuja.site/niko/ci-cucumber:latest
|
||||
secrets:
|
||||
GITEA_TOKEN:
|
||||
required: true
|
||||
@@ -33,36 +34,14 @@ jobs:
|
||||
path: .ci
|
||||
|
||||
- name: Run cucumber tests
|
||||
id: cucumber-tests
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "reports/${GITHUB_SHA:0:8}/cucumber"
|
||||
set +e
|
||||
mkdir -p reports/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
|
||||
CUCUMBER_EXIT=$?
|
||||
echo "CUCUMBER_EXIT=${CUCUMBER_EXIT}" >> "${GITHUB_ENV}"
|
||||
exit ${CUCUMBER_EXIT}
|
||||
--format json:reports/cucumber/report.json \
|
||||
--format html:reports/cucumber/report.html 2>&1
|
||||
|
||||
- name: Publish cucumber reports
|
||||
if: always()
|
||||
run: bash .ci/scripts/publish-git-pages.sh cucumber
|
||||
|
||||
- name: Report status
|
||||
- name: Report
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${CUCUMBER_EXIT}" = "0" ]; then
|
||||
if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then
|
||||
bash .ci/scripts/report-status.sh success "Link to Cucumber reports" acc-tests cucumber
|
||||
else
|
||||
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 "Link to Cucumber reports" acc-tests cucumber
|
||||
else
|
||||
bash .ci/scripts/report-status.sh failure "Link to Cucumber reports" acc-tests
|
||||
fi
|
||||
fi
|
||||
run: bash .ci/scripts/ci-report.sh "Cucumber test report" acc-tests cucumber
|
||||
|
||||
@@ -20,7 +20,6 @@ jobs:
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
bats-image: gitea.app.keskikuja.site/niko/ci-bats:latest
|
||||
|
||||
cucumber:
|
||||
name: Cucumber tests
|
||||
@@ -29,7 +28,6 @@ jobs:
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
cucumber-node-image: gitea.app.keskikuja.site/niko/ci-cucumber:latest
|
||||
|
||||
report-summary:
|
||||
name: Report Summary
|
||||
|
||||
@@ -29,7 +29,6 @@ jobs:
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
bats-image: gitea.app.keskikuja.site/niko/ci-bats:latest
|
||||
|
||||
cucumber:
|
||||
name: Cucumber tests
|
||||
@@ -39,7 +38,6 @@ jobs:
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
cucumber-node-image: gitea.app.keskikuja.site/niko/ci-cucumber:latest
|
||||
|
||||
build-push:
|
||||
name: Build & Push Docker
|
||||
|
||||
Reference in New Issue
Block a user