Switch to poetry and use ruff and ruff formatting🎉 (#444) #873
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: Python package | |
on: | |
push: | |
paths: | |
- 'src/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create application default credentials | |
run: | | |
mkdir -p $HOME/.config/gcloud/ | |
echo "$APP_CRED" >> $HOME/.config/gcloud/application_default_credentials.json | |
chmod 600 $HOME/.config/gcloud/application_default_credentials.json | |
shell: bash | |
env: | |
APP_CRED: ${{secrets.APPLICATION_DEFAULT_CREDENTIALS}} | |
- name: Set up wandb api key | |
run: | | |
echo "$WANDB_API_KEY" >> $HOME/.netrc | |
chmod 600 $HOME/.netrc | |
shell: bash | |
env: | |
WANDB_API_KEY: ${{secrets.WANDB_API_KEY}} | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Set up Python and install dependencies | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'poetry' | |
- name: install poetry | |
run: poetry install | |
- name: Test with pytest | |
run: | | |
poetry run pytest --cov=src tests/ --doctest-modules --junitxml=cover/xunit-result.xml --cov-report xml:cover/coverage.xml | |
poetry run coverage json -o cover/coverage.json | |
- name: "Extract numbers from cov report" | |
run: | | |
export TOTAL=$(python -c "import json;print(json.load(open('cover/coverage.json'))['totals']['percent_covered_display'])") | |
echo "total=$TOTAL" >> $GITHUB_ENV | |
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY | |
- name: "Make badge" | |
uses: schneegans/dynamic-badges-action@v1.6.0 | |
with: | |
auth: ${{ secrets.GIST_TOKEN }} | |
gistID: e2578f2f3e6322d299f1cb2e294d6b0b | |
filename: covbadge.json | |
label: Coverage | |
message: ${{ env.total }}% | |
minColorRange: 50 | |
maxColorRange: 90 | |
valColorRange: ${{ env.total }} |