Skip to content

Commit

Permalink
👷 CI overhaul (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Apr 15, 2021
1 parent f9115e7 commit b596cca
Show file tree
Hide file tree
Showing 23 changed files with 281 additions and 357 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates once a week
interval: 'weekly'
79 changes: 31 additions & 48 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
name: CI
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch: # allows you to trigger manually

jobs:
pre-job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'false'
do_not_skip: '["workflow_dispatch", "schedule"]'
paths_ignore: '["**/docs/**"]'
build:
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
name: python-${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.6", "3.7", "3.8"]
python-version: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Cache conda
uses: actions/cache@v1
env:
# Increase this value to reset cache if ci/environment.yml has not changed
CACHE_NUMBER: 0
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }}
- uses: goanpeca/setup-miniconda@v1
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: sandbox-devel # Defined in ci/environment.yml
channels: conda-forge,nodefaults
mamba-version: '*'
activate-environment: ecgtools-dev
auto-update-conda: false
python-version: ${{ matrix.python-version }}
environment-file: ci/environment.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!

- name: Set up conda environment
shell: bash -l {0}
run: |
python -m pip install -e .
conda list
- name: Run Tests
shell: bash -l {0}
run: |
pytest --cov=./ --cov-report=xml
python -m pytest --cov=./ --cov-report=xml --verbose
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v1
Expand All @@ -52,29 +61,3 @@ jobs:
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false

docs-build:
name: Documentation build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install package
run: |
sudo apt-get update && sudo apt-get install pandoc -y
python -m pip install --upgrade pip
python -m pip install -e .
- name: Install documentation dependencies
run: |
python -m pip install -r docs/requirements-docs.txt
- name: Build docs
run: |
cd docs
make html
69 changes: 19 additions & 50 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -1,62 +1,31 @@
name: code-style
name: linting

on:
push:
branches: "*"
pull_request:
branches: master


workflow_dispatch:

jobs:

lint-black:
name: black-formatter
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Black
run: |
python -m pip install black
- name: Black Code Formatter
run: |
black --check --line-length 100 --skip-string-normalization .
lint-flake8:
name: flake8
pre-job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
python-version: 3.8
- name: Install Flake8
run: |
python -m pip install flake8
- name: Flake8 check
run: |
flake8 .
lint-isort:
name: isort
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'false'
do_not_skip: '["workflow_dispatch", "schedule"]'
linting:
needs: pre-job
runs-on: ubuntu-latest
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
python-version: 3.8
- name: Install isort
run: |
python -m pip install isort
- name: isort check
run: |
isort --check-only .
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
69 changes: 58 additions & 11 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,73 @@
name: Upload Package to PyPI
name: Upload ecgtools to PyPI

on:
release:
types: [created]

types:
- published
workflow_dispatch:
jobs:
test-deploy:
if: github.repository == 'NCAR/ecgtools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine check-manifest
- name: Build tarball and wheels
run: |
python setup.py sdist bdist_wheel
python -m pip wheel . -w dist --no-deps
- name: Test the artifacts
run: |
python -m twine check dist/*
- name: Publish package to TestPyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TESTPYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
verbose: true

deploy:
needs: test-deploy
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-scm wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python -m pip install setuptools setuptools-scm wheel twine check-manifest
- name: Build tarball and wheels
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
python -m pip wheel . -w dist --no-deps
- name: Test the artifacts
run: |
python -m twine check dist/*
- name: Publish package to PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
skip_existing: true
verbose: true

# - name: Publish package
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# python -m twine upload dist/* --skip-existing
64 changes: 36 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
exclude: schema/generic_schema.yaml
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: double-quote-string-fixer

- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black
args: ["--line-length", "100", "--skip-string-normalization"]

- repo: https://github.com/keewis/blackdoc
rev: v0.3.3
hooks:
- id: blackdoc

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.1.4
hooks:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.8.0
hooks:
- id: isort

- repo: https://github.com/deathbeds/prenotebook
rev: f5bdb72a400f1a56fe88109936c83aa12cc349fa
hooks:
- id: prenotebook
args:
[
"--keep-output",
"--keep-metadata",
"--keep-execution-count",
"--keep-empty",
]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
- id: prettier

- repo: https://github.com/nbQA-dev/nbQA
rev: 0.6.0
hooks:
- id: nbqa-black
additional_dependencies: [black==20.8b1]
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==2.7.3]
- id: nbqa-isort
additional_dependencies: [isort==5.8.0]
3 changes: 3 additions & 0 deletions .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tabWidth = 2
semi = false
singleQuote = true
Empty file added CHANGELOG.md
Empty file.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Contributing to ecgtools
Loading

0 comments on commit b596cca

Please sign in to comment.