Merge pull request #118 from AlmaLinux/dependabot/pip/pylint-3.2.6 #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests | |
on: | |
push: | |
branches: [master] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
pytest: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
env: | |
REPORTS_DIR: .reports | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
# https://github.com/marketplace/actions/build-and-push-docker-images | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
target: sign-node-tests | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Prepare working directory | |
run: mkdir -p $REPORTS_DIR | |
- name: Run pytest | |
id: pytest | |
run: | | |
docker compose run --rm sign_node_tests bash -o pipefail -c " | |
pytest -v --cov \ | |
--cov-report=json:$REPORTS_DIR/pytest-report.json \ | |
--cov-report=term | tee $REPORTS_DIR/pytest-output.txt" | |
python -c " | |
import json | |
coverage = json.load(open('$REPORTS_DIR/pytest-report.json'))['totals']['percent_covered_display'] | |
print(f'percent_covered={coverage}', file=open('$GITHUB_OUTPUT', 'a'))" | |
- name: Create Coverage Badge | |
# https://github.com/marketplace/actions/dynamic-badges | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_TOKEN }} | |
gistID: fd471834348bb248a0881bc9ccfd45dd | |
filename: coverage-badge.json | |
label: Test Coverage | |
message: ${{ steps.pytest.outputs.percent_covered }}% | |
valColorRange: ${{ steps.pytest.outputs.percent_covered }} | |
minColorRange: 25 | |
maxColorRange: 60 | |
namedLogo: pytest | |
- name: Generate .md reports | |
if: success() || failure() | |
run: | | |
awk 'NR == 1 {next}; /^-+ coverage:/ {exit}; {print}' $REPORTS_DIR/pytest-output.txt \ | |
> $REPORTS_DIR/pytest-report.txt | |
awk '/^-+ coverage:/, /^TOTAL/' $REPORTS_DIR/pytest-output.txt \ | |
> $REPORTS_DIR/coverage-report.txt | |
for tool in coverage pytest; do | |
if [[ -s $REPORTS_DIR/${tool}-report.txt ]]; then | |
{ | |
printf "<details><summary>${tool^} report</summary>\n" | |
printf '\n```\n' | |
cat $REPORTS_DIR/${tool}-report.txt | |
printf '\n```\n' | |
printf '\n</details>\n\n' | |
} > $REPORTS_DIR/${tool}-report.md | |
fi | |
done | |
- name: Publish Job Summary | |
if: success() || failure() | |
run: | | |
cat $REPORTS_DIR/{coverage,pytest}-report.md \ | |
> $GITHUB_STEP_SUMMARY 2>/dev/null || true |