Skip to content

Reinstated caching and changed publish to on push to main. #5

Reinstated caching and changed publish to on push to main.

Reinstated caching and changed publish to on push to main. #5

Workflow file for this run

---
name: Test
on:
push:
paths:
- rasterioxyz/**
- .github/**
- tests/**
branches: [develop]
jobs:
lint:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set-up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Poetry and dependencies
run: |
pip install poetry
poetry install
- name: Run pre-commit
run: poetry run pre-commit run --all-files
- name: Run mypy
run: poetry run mypy rasterioxyz tests
test:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.image }}
if: github.ref == 'refs/heads/develop'
strategy:
matrix:
os:
- Ubuntu
- macOS
- Windows
python-version:
- '3.10'
include:
- os: Ubuntu
image: ubuntu-latest
- os: Windows
image: windows-latest
- os: macOS
image: macos-latest
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set-up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH for Ubuntu and MacOS
if: ${{ matrix.os != 'Windows' }}
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Update Path for Windows
if: ${{ matrix.os == 'Windows' }}
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
- name: Configure Poetry
run: |
poetry config virtualenvs.in-project true
- name: Set-up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check Poetry lock
run: poetry check --lock
- name: Install dependencies
run: poetry install
- name: Run pytest
run: |
poetry run coverage run -m pytest -s
poetry run coverage xml
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml