Skip to content

Commit

Permalink
Switching to using centralized packaging infrastructure (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
dfm and pre-commit-ci[bot] committed Aug 9, 2022
1 parent 3f9a871 commit 350ca9d
Show file tree
Hide file tree
Showing 23 changed files with 482 additions and 300 deletions.
28 changes: 28 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
_commit: v0.0.10
_src_path: gh:dfm/copier-python
author_email: foreman.mackey@gmail.com
author_fullname: Dan Foreman-Mackey
author_username: dfm
code_of_conduct_email: foreman.mackey@gmail.com
copyright_holder: Dan Foreman-Mackey
copyright_license: BSD
copyright_year: 2013-2022
documentation_url: https://corner.readthedocs.io
enable_mypy: false
enable_pybind11: false
enable_windows: false
general_nox_sessions: '"lint"'
project_description: Make some beautiful corner plots
project_development_status: stable
project_line_length: 79
project_name: corner.py
python_formal_min_version: 6
python_max_version: 10
python_min_version: 7
python_nox_sessions: '"tests"'
python_package_distribution_name: corner
python_package_import_name: corner
readthedocs_project_name: corner
repository_name: corner.py
repository_namespace: dfm

129 changes: 63 additions & 66 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,82 @@
name: Tests

on:
push:
branches: [main]
branches:
- main
tags:
- "*"
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:
inputs:
prerelease:
description: 'Run a pre-release, testing the build'
required: false
type: boolean
default: false

jobs:
tests:
name: "py${{ matrix.python-version }}; ${{ matrix.arviz-version }}"
runs-on: "ubuntu-latest"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
os: ["ubuntu-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
nox-session: ["tests"]
include:
- os: macos-latest
python-version: "3.10"
nox-session: "tests"
- os: ubuntu-latest
python-version: "3.10"
nox-session: "lint"

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Configure Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install ".[test,arviz]"
env:
ARVIZ: ${{ matrix.arviz-version }}

- name: Run the unit tests
run: python -m pytest -v tests

- uses: actions/upload-artifact@v2
if: ${{ failure() }}
- name: Cache pip packages
uses: actions/cache@v3
with:
name: images-${{ matrix.python-version }}
path: ./result_images

build:
name: Build dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.nox-session }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.nox-session }}-
- name: Cache nox session files
uses: actions/cache@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v2
name: Install Python
path: .nox
key: ${{ runner.os }}-nox-${{ matrix.nox-session }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-nox-${{ matrix.nox-session }}-
- name: Cache pre-commit environments
if: ${{ matrix.nox-session == 'lint' }}
uses: actions/cache@v3
with:
python-version: "3.9"

- name: Build
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- name: Install nox
run: |
python -m pip install -U pip
python -m pip install -U build
python -m build .
- name: Check the artifacts
run: |
python -m pip install -U twine
python -m twine check dist/*
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist/*

upload_pypi:
needs: [tests, build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
python -m pip install -U nox
- name: Run tests
run: python -m nox --non-interactive -s ${{ matrix.nox-session }}

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
release:
if: ${{ inputs.prerelease || startsWith(github.ref, 'refs/tags/') }}
needs: tests
uses: dfm/workflows/.github/workflows/python-release.yml@v0.1.0
with:
wheels: false
enable-windows: false
secrets:
pypi-token: ${{ secrets.pypi_password }}
36 changes: 36 additions & 0 deletions .github/workflows/update-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update template

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 1"

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Configure Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install and run copier update
run: |
python -m pip install -U pip
python -m pip install -U copier
python -m copier --force update
- name: Create a pull request
uses: peter-evans/create-pull-request@v4
with:
commit-message: Updating Copier template
branch: update-template
delete-branch: true
title: Updating Copier template
body: |
Automatically updating the Copier template
**Maintainers should close and then re-open this PR to get the tests to run.**
18 changes: 10 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.DS_Store
/src/*/version.py
*.pyc
*.png
__pycache__
*.egg-info
*.pdf
_skbuild
*.so
.mypy_cache
.tox
.nox
.coverage
.coverage*
dist
result_images
build
test_figures
.coverage
!tests/baseline_images/*/*.png
.pytest_cache
corner_version.py
14 changes: 11 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
repos:
- repo: local
hooks:
- id: forbidden-files
name: forbidden files
entry: found copier update rejection files; review them and remove them
language: fail
files: "\\.rej$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude_types: [json, binary]
exclude: ".copier-answers.yml"
- id: check-yaml
- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
hooks:
- id: isort
additional_dependencies: [toml]
exclude: docs/pages
- repo: https://github.com/psf/black
rev: "22.6.0"
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/kynan/nbstripout
rev: "0.5.0"
rev: "0.6.0"
hooks:
- id: nbstripout
5 changes: 0 additions & 5 deletions .rtd-environment.yml

This file was deleted.

0 comments on commit 350ca9d

Please sign in to comment.