-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Build and CI infrastructure * Apply suggestions from code review Co-authored-by: Brett M. Morris <morrisbrettm@gmail.com> --------- Co-authored-by: Brett M. Morris <morrisbrettm@gmail.com>
- Loading branch information
1 parent
9e7ca8d
commit 41c228f
Showing
5 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- 'v*' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# Github Actions supports ubuntu, windows, and macos virtual environments: | ||
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners | ||
ci_tests: | ||
name: ${{ matrix.name }} | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: ${{ matrix.allow_failure }} | ||
strategy: | ||
matrix: | ||
include: | ||
- name: Code style checks | ||
os: ubuntu-latest | ||
python: 3.x | ||
toxenv: codestyle | ||
allow_failure: false | ||
|
||
- name: PEP 517 | ||
os: ubuntu-latest | ||
python: 3.x | ||
toxenv: pep517 | ||
allow_failure: false | ||
|
||
- name: Security audit | ||
os: ubuntu-latest | ||
python: 3.x | ||
toxenv: securityaudit | ||
allow_failure: false | ||
|
||
- name: macOS - Python 3.10 | ||
os: macos-latest | ||
python: '3.10' | ||
toxenv: py310-test | ||
allow_failure: false | ||
|
||
- name: Windows - Python 3.11 | ||
os: windows-latest | ||
python: 3.11 | ||
toxenv: py311-test | ||
allow_failure: false | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up python ${{ matrix.python }} on ${{ matrix.os }} | ||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
- name: Install base dependencies | ||
run: python -m pip install --upgrade pip tox | ||
- name: Test/run with tox | ||
run: tox -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Release | ||
|
||
on: | ||
# NOTE: PR trigger is to ensure changes do not break packaging. | ||
pull_request: | ||
release: | ||
types: [released] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-n-publish: | ||
name: Build and publish Python 🐍 distributions 📦 to PyPI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
if: github.repository == 'spacetelescope/mast-aladin-lite' | ||
|
||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install python-build and twine | ||
run: python -m pip install build "twine>=3.3" | ||
|
||
- name: Build package | ||
run: python -m build --sdist --wheel . | ||
|
||
- name: List result | ||
run: ls -l dist | ||
|
||
- name: Check dist | ||
run: python -m twine check --strict dist/* | ||
|
||
- name: Test package | ||
run: | | ||
cd .. | ||
python -m venv testenv | ||
testenv/bin/pip install pytest pytest-astropy pytest-tornasync mast-aladin-lite/dist/*.whl | ||
testenv/bin/python -c "import mast_aladin_lite; mast_aladin_lite.test()" | ||
# NOTE: Do not run this part for PR testing. | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
""" | ||
This packages contains package tests. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
[tox] | ||
envlist = py310-test, py311-test, linkcheck, codestyle, pep517, securityaudit | ||
|
||
requires = | ||
setuptools >= 30.3.0 | ||
pip >= 19.3.1 | ||
isolated_build = true | ||
|
||
[testenv] | ||
description = Run tests for mast-aladin-lite | ||
|
||
setenv = | ||
MPLBACKEND=agg | ||
JUPYTER_PLATFORM_DIRS=1 | ||
|
||
# Pass through the following environment variables which may be needed for the CI | ||
passenv = HOME,WINDIR,LC_ALL,LC_CTYPE,CC,CI | ||
|
||
# Run the tests in a temporary directory to make sure that we don't import | ||
# this package from the source tree | ||
changedir = .tmp/{envname} | ||
|
||
# The following provides some specific pinnings for key packages | ||
deps = | ||
pytest | ||
ipyaladin | ||
astroquery | ||
sidecar | ||
|
||
# The following indicates which extras_require from setup.cfg will be installed | ||
extras = | ||
test | ||
|
||
commands = | ||
jupyter --paths | ||
pip freeze | ||
pytest --pyargs mast_aladin_lite {posargs} | ||
|
||
[testenv:linkcheck] | ||
changedir = docs | ||
description = check the links in the HTML docs | ||
extras = docs | ||
commands = | ||
pip freeze | ||
sphinx-build -W -b linkcheck . _build/html | ||
|
||
[testenv:codestyle] | ||
skip_install = true | ||
changedir = . | ||
description = check code style, e.g. with flake8 | ||
deps = flake8 | ||
commands = flake8 mast_aladin_lite --count | ||
|
||
[testenv:securityaudit] | ||
skip_install = true | ||
changedir = . | ||
description = security audit with bandit | ||
deps = bandit | ||
commands = bandit -r mast_aladin_lite | ||
|
||
[testenv:pep517] | ||
skip_install = true | ||
changedir = . | ||
description = PEP 517 | ||
deps = | ||
build | ||
twine | ||
commands = | ||
python -m build --sdist . | ||
twine check dist/* --strict |