Skip to content

Commit

Permalink
Replace Azure Pipeline with GitHub actions (#179)
Browse files Browse the repository at this point in the history
* test numpy thing

* add typechecking action

* add codecov to test action

* fix

* refactoring

* grr

* forgot pydantic

* remove tests on windows

* more dependencies

* remove typechecking from Azure pipeline

* get codecov to wait for more results before reporting

* add notebook tests to testing action

* also install docs dependencies...

* fix path

* build dist and publish to PyPI if release

* use py3.9

* remove azure pipeline, everything is handled by GitHub actions now

* change to bitarray, tidying

* remove unused packages

* remove unused packages

* adjust docs

* Revert "refactoring"

This reverts commit 10d624f.
  • Loading branch information
wilko77 authored Mar 22, 2022
1 parent c249188 commit d6caba1
Show file tree
Hide file tree
Showing 8 changed files with 821 additions and 891 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and upload to PyPI

on:
release:
types: [ published ]
pull_request:
branches: [ master ]

jobs:
build_dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Install poetry
shell: bash
run: |
curl -sSL -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Configure poetry
shell: bash
run: |
poetry --version
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v2.1.6
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
poetry install --no-interaction
- name: Build package
run: poetry build --no-interaction

- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: blocklib-dist
path: ./dist

upload_pypi:
needs: [build_dist]
runs-on: ubuntu-latest

# upload to PyPI only on release
if: github.event.release && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: blocklib-dist
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
68 changes: 60 additions & 8 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# This workflow will install Python dependencies, run tests and lint 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: Python Unit Tests
name: Testing

# Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
# Triggers the workflow on push pushed to any branch in a repository
on: push

jobs:
pytest:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
unittests:
name: Unit tests / ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
# Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
continue-on-error: ${{ matrix.experimental }}
Expand All @@ -22,6 +22,7 @@ jobs:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
# How to add an experimental job:
# - "3.10.0-alpha.6"
# include:
Expand All @@ -31,14 +32,12 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install poetry
shell: bash
run: |
Expand All @@ -64,4 +63,57 @@ jobs:
poetry install --no-interaction
- name: Test with pytest
run: |
poetry run pytest -q tests
poetry run pytest --cov=blocklib --cov-report=xml:coverage.xml -q tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests
name: codecov-blocklib

notebooktests:
name: Notebook tests / ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
python: [ "3.10" ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Install poetry
shell: bash
run: |
curl -sSL -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Configure poetry
shell: bash
run: |
poetry --version
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v2.1.6
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
poetry install -E docs --no-interaction
- name: Test notebooks
shell: bash
run: poetry run pytest --nbval docs/tutorial
31 changes: 31 additions & 0 deletions .github/workflows/typechecking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Typechecking

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]


jobs:
typechecking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.x
- name: mypy (pinned)
run: |
pip install --upgrade pip
pip install -U mypy==0.931
pip install -U pydantic
pip install -U types-setuptools
mypy blocklib --ignore-missing-imports --no-implicit-optional --disallow-untyped-calls
- name: mypy (latest)
run: |
pip install --upgrade pip
pip install -U mypy
pip install -U pydantic
pip install -U types-setuptools
mypy blocklib --ignore-missing-imports --no-implicit-optional --disallow-untyped-calls
134 changes: 0 additions & 134 deletions azure-pipelines.yml

This file was deleted.

2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ comment:
# prevent premature reporting
codecov:
notify:
after_n_builds: 2
after_n_builds: 6
Loading

0 comments on commit d6caba1

Please sign in to comment.