remyroy is testing and measuring code quality #587
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: ci-runner | |
run-name: ${{ github.actor }} is testing and measuring code quality | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
types: [opened, synchronize, labeled, unlabeled] | |
branches: [main] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt -r requirements_test.txt | |
- name: Run type checker | |
run: python -m mypy --config-file mypy.ini -p ethstaker_deposit | |
- name: Run linter | |
run: flake8 --config=flake8.ini ./ethstaker_deposit ./tests | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
- name: Install jsonlint | |
run: npm install -g @prantlf/[email protected] | |
- name: Validate JSON files | |
run: | | |
find ./ethstaker_deposit/intl -name "*.json" -exec jsonlint --no-duplicate-keys --quiet --compact {} \; | |
ci-runner: | |
needs: lint | |
if: | | |
contains(github.event.pull_request.labels.*.name, 'run-tests') || | |
github.event_name == 'push' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, ubuntu-24.04-arm64, macos-13, macos-latest, windows-latest] | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt -r requirements_test.txt | |
- name: Run tests | |
run: | | |
coverage run --data-file=.coverage.${{ matrix.os }}.${{ matrix.python-version }} -m pytest tests | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.os }}-${{ matrix.python-version }} | |
path: .coverage.${{ matrix.os }}.${{ matrix.python-version }} | |
retention-days: 1 | |
if-no-files-found: error | |
include-hidden-files: true | |
coverage-combine: | |
needs: ci-runner | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: 'pip' | |
- name: Download coverage data | |
uses: actions/download-artifact@v4 | |
- name: Merge coverage data | |
id: merge | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt -r requirements_test.txt | |
coverage combine coverage* | |
coverage html | |
- name: Upload final coverage html report | |
uses: actions/upload-artifact@v4 | |
id: upload-html | |
with: | |
name: coverage-html-report | |
path: htmlcov | |
- name: Generate text report | |
run: | | |
mkdir results | |
{ | |
echo "Test Coverage: [Download HTML Report](${{ steps.upload-html.outputs.artifact-url }})" ; | |
echo ; | |
echo \`\`\` ; | |
coverage report ; | |
echo \`\`\` ; | |
} >> results/coverage-text-report | |
echo ${{ github.event.number }} > results/issue_number | |
- name: Upload final coverage text report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: results | |
path: results/ |