Skip to content

Set up test configs and GH workflows (#61) #1

Set up test configs and GH workflows (#61)

Set up test configs and GH workflows (#61) #1

Workflow file for this run

name: Run Tests
on:
push:
branches: [master]
defaults:
run:
shell: bash
jobs:
pytest:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Prepare working directory
run: |
mkdir node-config
echo "development_mode: yes" > node-config/sign_node.yml
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v3
- name: Build Image
# https://github.com/marketplace/actions/build-and-push-docker-images
uses: docker/build-push-action@v5
with:
context: .
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Pytest
id: pytest
run: |
docker compose run --rm sign_node bash -c "
pytest -v --cov \
--cov-report=json:pytest-report.json \
--cov-report=term | tee pytest-report.txt"
python -c "
import os, json
coverage = json.load(open('pytest-report.json'))['totals']['percent_covered_display']
print(f'percent_covered={coverage}', file=open(os.environ['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: 30
maxColorRange: 60
namedLogo: pytest
- name: Publish Job Summary
run: |
{
printf "## Test Results\n\n"
printf '<details><summary>Click to expand</summary>\n'
printf '\n```\n'
awk 'NR == 1 {next}; /^-+ coverage:/ {exit}; {print}' pytest-report.txt
printf '\n```\n'
printf '</details>\n\n'
printf "## Code Coverage\n\n"
printf '<details><summary>Click to expand</summary>\n'
printf '\n```\n'
awk '/^-+ coverage:/, /^TOTAL/' pytest-report.txt
printf '\n```\n'
printf '</details>\n\n'
} > $GITHUB_STEP_SUMMARY