Skip to content

Commit

Permalink
Update CI (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Mar 7, 2022
1 parent 11c4007 commit f89b38f
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 92 deletions.
45 changes: 21 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,42 @@ name: CI
on:
push:
branches:
- '*'
- main
pull_request:
branches:
- '*'
- main
# schedule:
# - cron: '0 0 * * *' # Daily “At 00:00”
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: '["pull_request", "workflow_dispatch", "schedule"]'
paths_ignore: '["**/docs/**"]'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: python-${{ matrix.python-version }}
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
if: github.repository == 'NCAR/ncar-jobqueue'
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create conda environment
uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
micromamba-version: 'latest'
environment-file: ci/environment.yml
extra-specs: |
python=${{ matrix.python-version }}
- uses: conda-incubator/setup-miniconda@v2
with:
channels: conda-forge
Expand All @@ -51,13 +47,14 @@ jobs:
python-version: ${{ matrix.python-version }}
environment-file: ci/environment.yml

- name: List conda packages
- name: Install NCAR-jobqeueue
run: |
python -m pip install -e . --no-deps --force-reinstall
conda list
- name: Run Tests
run: |
python -m pytest --cov=./ --cov-report=xml --verbose
python -m pytest
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v2.1.0
Expand Down
82 changes: 47 additions & 35 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,74 @@ on:
types:
- published
workflow_dispatch:
push:
branches:
- main
jobs:
test-deploy:
if: github.repository == 'NCAR/ncar-jobqueue'
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'NCAR/ncar-jobqueue'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
fetch-depth: 0
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.8

- 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
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .
- name: Check built artifacts
run: |
python -m twine check dist/*
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@v1.5.0
pwd
if [ -f dist/ncar-jobqueue-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- uses: actions/upload-artifact@v2
with:
user: __token__
password: ${{ secrets.TESTPYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
verbose: true
name: releases
path: dist

deploy:
needs: test-deploy
if: startsWith(github.ref, 'refs/tags')
test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- uses: actions/setup-python@v3
name: Install Python
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
python-version: 3.8
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: List contents of built dist
run: |
python -m twine check dist/*
ls -ltrh
ls -ltrh dist
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: ${{ secrets.PYPI_USERNAME }}
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
skip_existing: true
verbose: true
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ repos:
- id: check-json
- id: check-yaml
- id: double-quote-string-fixer
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args:
- '--py38-plus'

- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/keewis/blackdoc
rev: v0.3.4
Expand All @@ -38,13 +48,3 @@ repos:
rev: v2.5.1
hooks:
- id: prettier

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.0
hooks:
- id: nbqa-black
additional_dependencies: [black==21.7b0]
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==2.7.3]
- id: nbqa-isort
additional_dependencies: [isort==v5.9.2]
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
| CI | [![GitHub Workflow Status][github-ci-badge]][github-ci-link] [![Code Coverage Status][codecov-badge]][codecov-link] [![pre-commit.ci status][pre-commit.ci-badge]][pre-commit.ci-link] |
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| **Docs** | [![Documentation Status][rtd-badge]][rtd-link] |
| **Package** | [![Conda][conda-badge]][conda-link] [![PyPI][pypi-badge]][pypi-link] |
| **License** | [![License][license-badge]][repo-link] |

# ncar-jobqueue

- [ncar-jobqueue](#ncar-jobqueue)
- [Badges](#badges)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
Expand All @@ -20,12 +25,7 @@ The following compute servers are supported:
- Hobart (hobart.cgd.ucar.edu)
- Izumi (izumi.unified.ucar.edu)

## Badges

| CI | [![GitHub Workflow Status][github-ci-badge]][github-ci-link] [![Code Coverage Status][codecov-badge]][codecov-link] |
| :---------- | :-----------------------------------------------------------------------------------------------------------------: |
| **Package** | [![Conda][conda-badge]][conda-link] [![PyPI][pypi-badge]][pypi-link] |
| **License** | [![License][license-badge]][repo-link] |
|

## Installation

Expand Down Expand Up @@ -190,15 +190,17 @@ warn(message)
LocalCluster(3a7dd0f6, 'tcp://127.0.0.1:64184', workers=4, threads=8, memory=17.18 GB)
```

[github-ci-badge]: https://img.shields.io/github/workflow/status/NCAR/ncar-jobqueue/CI?label=CI&logo=github&style=for-the-badge
[github-ci-badge]: https://img.shields.io/github/workflow/status/NCAR/ncar-jobqueue/CI?label=CI&logo=github
[github-ci-link]: https://github.com/NCAR/ncar-jobqueue/actions?query=workflow%3ACI
[codecov-badge]: https://img.shields.io/codecov/c/github/NCAR/ncar-jobqueue.svg?logo=codecov&style=for-the-badge
[codecov-badge]: https://img.shields.io/codecov/c/github/NCAR/ncar-jobqueue.svg?logo=codecov
[codecov-link]: https://codecov.io/gh/NCAR/ncar-jobqueue
[rtd-badge]: https://img.shields.io/readthedocs/dask-jobqueue/latest.svg?style=for-the-badge
[rtd-link]: https://jobqueue.dask.org/en/latest/?badge=latest
[pypi-badge]: https://img.shields.io/pypi/v/ncar-jobqueue?logo=pypi&style=for-the-badge
[rtd-badge]: https://img.shields.io/readthedocs/ncar-jobqueue/latest.svg
[rtd-link]: https://ncar-jobqueue.readthedocs.io/en/latest/?badge=latest
[pypi-badge]: https://img.shields.io/pypi/v/ncar-jobqueue?logo=pypi
[pypi-link]: https://pypi.org/project/ncar-jobqueue
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/ncar-jobqueue?logo=anaconda&style=for-the-badge
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/ncar-jobqueue?logo=anaconda
[conda-link]: https://anaconda.org/conda-forge/ncar-jobqueue
[license-badge]: https://img.shields.io/github/license/NCAR/ncar-jobqueue?style=for-the-badge
[license-badge]: https://img.shields.io/github/license/NCAR/ncar-jobqueue
[repo-link]: https://github.com/NCAR/ncar-jobqueue
[pre-commit.ci-badge]: https://results.pre-commit.ci/badge/github/NCAR/ncar-jobqueue/main.svg
[pre-commit.ci-link]: https://results.pre-commit.ci/latest/github/NCAR/ncar-jobqueue/main
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ line-length = 100
target-version = ['py38']
skip-string-normalization = true

[tool.nbqa.mutate]
isort = 1
black = 1
pyupgrade = 1

[tool.nbqa.addopts]
pyupgrade = ["--py36-plus"]
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
line_length=100

[tool:pytest]
console_output_style = count
addopts = --cov=./ --cov-report=xml --verbose -s -rx
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""The setup script."""

Expand All @@ -19,7 +18,7 @@
description="Utilities for expanding dask-jobqueue with appropriate settings for NCAR's clusters",
install_requires=requirements,
license='Apache License 2.0',
python_requires='>=3.6',
python_requires='>=3.7',
long_description_content_type='text/markdown',
long_description=long_description,
include_package_data=True,
Expand All @@ -32,6 +31,5 @@
'Tracker': 'https://github.com/NCAR/ncar-jobqueue',
},
use_scm_version={'version_scheme': 'post-release', 'local_scheme': 'dirty-tag'},
setup_requires=['setuptools_scm', 'setuptools>=30.3.0'],
zip_safe=False,
)

0 comments on commit f89b38f

Please sign in to comment.