Skip to content

Commit

Permalink
Add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jayqi committed Aug 12, 2023
1 parent 453038f commit 39b63ff
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 1 deletion.
123 changes: 123 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: tests

on:
push:
branches: [main]
pull_request:
schedule:
# Run every Sunday
- cron: "0 0 * * 0"
workflow_dispatch:

jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
pyproject.toml
- name: Install hatch
run: |
pip install hatch
- name: Lint package
run: |
hatch run lint
hatch run typecheck
tests:
name: "Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})"
needs: code-quality
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
pyproject.toml
- name: Install hatch
run: |
pip install hatch
- name: Run tests
run: |
hatch run tests.py${{ matrix.python-version }}:run
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: true
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Build distribution and test installation
shell: bash
run: |
hatch build
if [[ ${{ matrix.os }} == "windows-latest" ]]; then
PYTHON_BIN=Scripts/python
else
PYTHON_BIN=bin/python
fi
echo "=== Testing wheel installation ==="
python -m venv .venv-whl
.venv-whl/$PYTHON_BIN -m pip install --upgrade pip
.venv-whl/$PYTHON_BIN -m pip install dist/repro-zipfile-*.whl
.venv-whl/$PYTHON_BIN -c "from repro_zipfile import ReproducibleZipFile"
echo "=== Testing source installation ==="
python -m venv .venv-sdist
.venv-sdist/$PYTHON_BIN -m pip install --upgrade pip
.venv-sdist/$PYTHON_BIN -m pip install dist/repro-zipfile-*.tar.gz --force-reinstall
.venv-sdist/$PYTHON_BIN -c "from repro_zipfile import ReproducibleZipFile"
# - name: Test building documentation
# run: |
# hatch run docs:build
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'

# - name: Deploy site preview to Netlify
# if: |
# matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
# && github.event.pull_request != null
# uses: nwtgck/actions-netlify@v1.1
# with:
# publish-dir: "./site"
# production-deploy: false
# github-token: ${{ secrets.GITHUB_TOKEN }}
# deploy-message: "Deploy from GitHub Actions"
# enable-pull-request-comment: true
# enable-commit-comment: false
# overwrites-pull-request-comment: true
# alias: deploy-preview-${{ github.event.number }}
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# timeout-minutes: 1

# notify:
# name: Notify failed build
# needs: [code-quality, tests]
# if: failure() && github.event.pull_request == null
# runs-on: ubuntu-latest
# steps:
# - uses: jayqi/failed-build-issue-action@v1
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down

0 comments on commit 39b63ff

Please sign in to comment.