chore: windows error before other imports for nicer error message #67
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and converage with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Run tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
name: Cache pip directory | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-3.9 | |
- uses: actions/cache@v4 | |
name: Cache poetry deps | |
with: | |
path: .venv | |
key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.9 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- 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 sh.py tests/*.py | |
poetry run black --check --diff sh.py tests/*.py | |
poetry run rstcheck README.rst | |
poetry run mypy sh.py | |
test: | |
name: Run tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
use-select: [0, 1] | |
lang: [C, en_US.UTF-8] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
name: Cache pip directory | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-3.9 | |
- uses: actions/cache@v4 | |
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@v5 | |
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: | | |
SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run --data-file=coverage.data -a -m pytest | |
- name: Store coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage.${{ matrix.use-select }}.${{ matrix.lang }}.${{ matrix.python-version }} | |
path: coverage.data | |
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@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
pip install coverage coveralls | |
- name: Download coverage artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: coverage-artifacts | |
- name: Combine coverage | |
run: | | |
find coverage-artifacts -name coverage.data | xargs coverage combine -a | |
- name: Report coverage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
coverage report | |
coveralls --service=github | |
deploy: | |
name: Deploy | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.ref_name == 'master' | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get current version | |
id: get_version | |
run: echo "version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)" >> $GITHUB_ENV | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: pip install build | |
- name: Build | |
run: python -m build | |
- name: Tag commit | |
run: | | |
git tag "${{steps.get_version.outputs.version}}" "${{github.ref_name}}" | |
git push -f origin "${{steps.get_version.outputs.version}}" | |
- name: Get changes | |
id: changelog | |
run: | | |
python dev_scripts/changelog_extract.py ${{ steps.get_version.outputs.version }} \ | |
> release_changes.md | |
- name: Create Release | |
id: create-release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
name: Release ${{ steps.get_version.outputs.version }} | |
body_path: release_changes.md | |
draft: false | |
prerelease: false | |
files: dist/* | |
- name: Publish | |
uses: pypa/gh-action-pypi-publish@release/v1 |