chore(go): wire coverage-badge action inputs
Some checks failed
Push Validation / validate (push) Failing after 10s
Some checks failed
Push Validation / validate (push) Failing after 10s
This commit is contained in:
@@ -55,7 +55,7 @@ jobs:
|
|||||||
run: aws --version
|
run: aws --version
|
||||||
|
|
||||||
- name: Run full unit test suite with coverage
|
- name: Run full unit test suite with coverage
|
||||||
id: coverage
|
id: coverage-tests
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -121,81 +121,26 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Publish coverage artefacts
|
||||||
|
id: coverage-badge
|
||||||
|
uses: git.hrafn.xyz/aether/vociferate/coverage-badge@v1.0.1
|
||||||
|
with:
|
||||||
|
coverage-profile: coverage.out
|
||||||
|
coverage-html: coverage.html
|
||||||
|
coverage-badge: coverage-badge.svg
|
||||||
|
coverage-summary: coverage-summary.json
|
||||||
|
artefact-bucket-name: ${{ vars.ARTEFACT_BUCKET_NAME }}
|
||||||
|
artefact-bucket-endpoint: ${{ vars.ARTEFACT_BUCKET_ENDPONT }}
|
||||||
|
branch-name: ${{ github.ref_name }}
|
||||||
|
repository-name: ${{ github.repository }}
|
||||||
|
summary-file: ${{ env.SUMMARY_FILE }}
|
||||||
|
|
||||||
- name: Run security analysis
|
- name: Run security analysis
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
"$(go env GOPATH)/bin/gosec" ./...
|
"$(go env GOPATH)/bin/gosec" ./...
|
||||||
"$(go env GOPATH)/bin/govulncheck" ./...
|
"$(go env GOPATH)/bin/govulncheck" ./...
|
||||||
|
|
||||||
- name: Generate coverage badge
|
|
||||||
env:
|
|
||||||
COVERAGE_TOTAL: ${{ steps.coverage.outputs.total }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
color="$(awk -v total="$COVERAGE_TOTAL" 'BEGIN {
|
|
||||||
if (total >= 80) print "brightgreen";
|
|
||||||
else if (total >= 70) print "green";
|
|
||||||
else if (total >= 60) print "yellowgreen";
|
|
||||||
else if (total >= 50) print "yellow";
|
|
||||||
else print "red";
|
|
||||||
}')"
|
|
||||||
|
|
||||||
cat > coverage-badge.svg <<EOF
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="126" height="20" role="img" aria-label="coverage: ${COVERAGE_TOTAL}%">
|
|
||||||
<linearGradient id="smooth" x2="0" y2="100%">
|
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
|
||||||
</linearGradient>
|
|
||||||
<clipPath id="round">
|
|
||||||
<rect width="126" height="20" rx="3" fill="#fff"/>
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#round)">
|
|
||||||
<rect width="63" height="20" fill="#555"/>
|
|
||||||
<rect x="63" width="63" height="20" fill="${color}"/>
|
|
||||||
<rect width="126" height="20" fill="url(#smooth)"/>
|
|
||||||
</g>
|
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
|
||||||
<text x="32.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
|
||||||
<text x="32.5" y="14">coverage</text>
|
|
||||||
<text x="93.5" y="15" fill="#010101" fill-opacity=".3">${COVERAGE_TOTAL}%</text>
|
|
||||||
<text x="93.5" y="14">${COVERAGE_TOTAL}%</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Upload branch coverage artefacts
|
|
||||||
id: upload
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
aws configure set default.s3.addressing_style path
|
|
||||||
|
|
||||||
repo_name="${GITHUB_REPOSITORY##*/}"
|
|
||||||
prefix="${repo_name}/branch/${GITHUB_REF_NAME}"
|
|
||||||
report_url="${ARTEFACT_BUCKET_ENDPONT%/}/${ARTEFACT_BUCKET_NAME}/${prefix}/coverage.html"
|
|
||||||
badge_url="${ARTEFACT_BUCKET_ENDPONT%/}/${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-badge.svg"
|
|
||||||
|
|
||||||
aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage.html "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage.html" --content-type text/html
|
|
||||||
aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage-badge.svg "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-badge.svg" --content-type image/svg+xml
|
|
||||||
aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage-summary.json "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-summary.json" --content-type application/json
|
|
||||||
|
|
||||||
printf 'report_url=%s\n' "$report_url" >> "$GITHUB_OUTPUT"
|
|
||||||
printf 'badge_url=%s\n' "$badge_url" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Add coverage summary
|
|
||||||
run: |
|
|
||||||
{
|
|
||||||
echo '## Coverage'
|
|
||||||
echo
|
|
||||||
echo '- Total: `${{ steps.coverage.outputs.total }}%`'
|
|
||||||
echo '- Report: ${{ steps.upload.outputs.report_url }}'
|
|
||||||
echo '- Badge: ${{ steps.upload.outputs.badge_url }}'
|
|
||||||
echo
|
|
||||||
echo '### Package Coverage'
|
|
||||||
cat coverage-packages.md
|
|
||||||
} >> "$SUMMARY_FILE"
|
|
||||||
|
|
||||||
- name: Run behavior suite on main pushes
|
- name: Run behavior suite on main pushes
|
||||||
if: ${{ github.ref == 'refs/heads/main' }}
|
if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
run: ./script/run-behavior-suite-docker.sh
|
run: ./script/run-behavior-suite-docker.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user