Skip to content

Resolving Dependabot suggestions #133

Resolving Dependabot suggestions

Resolving Dependabot suggestions #133

Workflow file for this run

name: Tests
on:
push:
paths-ignore:
- "docs/**"
- "**.md"
- "**.ipynb"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
- "**.ipynb"
env:
COVERAGE_ALERT: 90
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
- uses: actions/cache@v2
name: Cache poetry deps
with:
path: .venv
key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.10
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install poetry
run: |
pip install poetry
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Lint
run: |
poetry run python -m flake8 heimdallm/
poetry run black --check --diff heimdallm/
poetry run mypy heimdallm
poetry run sphinx-build docs/source docs/build -a -W
test:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
- uses: actions/cache@v2
name: Cache poetry deps
env:
cache-name: poetry-deps
with:
path: .venv
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run tests
run: |
poetry run coverage run -m pytest heimdallm
- name: Store coverage
uses: actions/upload-artifact@v2
with:
name: coverage.${{ matrix.python-version }}
path: .coverage
report:
name: Report Coverage
needs: test
runs-on: ubuntu-latest
steps:
# required because coveralls complains if we're not in a git dir
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install coverage coveralls
- name: Download coverage artifacts
uses: actions/download-artifact@v2
with:
path: coverage-artifacts
- name: Combine coverage
run: |
find coverage-artifacts -name .coverage | xargs coverage combine -a
- name: Report coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coverage report --fail-under ${{ env.COVERAGE_ALERT }}
coveralls --service=github
deploy:
name: Deploy
environment: prod
runs-on: ubuntu-latest
needs:
- lint
- test
permissions:
contents: write
id-token: write
if: github.ref_name == 'main'
steps:
- uses: actions/checkout@v2
- name: Tag commit
id: tag-commit
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
git tag "$version" "${{github.ref_name}}"
git push origin "$version" || true
- name: Get changes
id: changelog
run: |
python dev_scripts/changelog_extract.py ${{ steps.tag-commit.outputs.VERSION }} \
> release_changes.md
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install poetry
run: |
pip install poetry
- name: Build
run: poetry build
- name: Store packages
uses: actions/upload-artifact@v2
with:
name: packages
path: dist/*
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag-commit.outputs.VERSION }}
name: Release ${{ steps.tag-commit.outputs.VERSION }}
body_path: release_changes.md
draft: false
prerelease: false
files: dist/*
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1