Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to copier #170

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 542e56b
_src_path: gh:scipp/copier_template
description: An h5py-like utility for NeXus files with seamless Scipp integration
max_python: '3.12'
min_python: '3.8'
namespace_package: ''
nightly_deps: scipp
orgname: scipp
projectname: scippnexus
related_projects: Scipp,ScippNeutron
year: 2023
12 changes: 4 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
ignore:
# Optional: Official actions have moving tags like v1;
# if you use those, you don't need updates.
- dependency-name: "actions/*"
# Note: We are not listing package-ecosystem: "github-actions". This causes
# noise in all template instances. Instead dependabot.yml in scipp/copier_template
# triggers updates of github-actions in the *template*. We then use `copier update`
# in template instances.
- package-ecosystem: "pip"
directory: "/requirements"
schedule:
Expand Down
44 changes: 25 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: CI

on:
Expand All @@ -10,12 +13,20 @@ on:
jobs:
formatting:
name: Formatting and static analysis
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
min_tox_env: ${{ steps.vars.outputs.min_tox_env }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Get Python version for other CI jobs
id: vars
run: |
echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT
echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version-file: '.github/workflows/python-version-ci'
- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/ci.txt
- run: tox -e static
Expand All @@ -24,28 +35,23 @@ jobs:
commit_message: Apply automatic formatting

tests:
name: Tests ${{ matrix.name }}
name: Tests
needs: formatting
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- {name: '3.10', python: '3.10', os: ubuntu-20.04, tox: py310}
- {name: '3.9', python: '3.9', os: ubuntu-20.04, tox: py39}
- {name: '3.8', python: '3.8', os: ubuntu-20.04, tox: py38}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/ci.txt
- run: tox -e ${{ matrix.tox }}
os: ['ubuntu-20.04']
python:
- version: '${{needs.formatting.outputs.min_python}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now this only runs with a single python version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I considered keeping multiple versions, but felt there was little benefit at this point.

tox-env: '${{needs.formatting.outputs.min_tox_env}}'
uses: ./.github/workflows/test.yml
with:
os-variant: ${{ matrix.os }}
python-version: ${{ matrix.python.version }}
tox-env: ${{ matrix.python.tox-env }}

docs:
needs: tests
uses: ./.github/workflows/docs.yml
with:
publish: false
version: ${{ github.ref_name }}
branch: ${{ github.head_ref == '' && github.ref_name || github.head_ref }}
21 changes: 10 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Docs

on:
Expand Down Expand Up @@ -36,35 +39,31 @@ env:
jobs:
docs:
name: Build documentation
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'
steps:
- run: sudo apt install --yes graphviz pandoc
- uses: actions/checkout@v3
with:
ref: ${{ inputs.branch == '' && github.ref_name || inputs.branch }}
fetch-depth: 0 # history required so cmake can determine version
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version-file: '.github/workflows/python-version-ci'
- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/ci.txt
- run: |
tox --skip-pkg-install -e docs -- scippnexus==${VERSION}
echo "target=$(python docs/version.py --version=${VERSION} --action=get-target)" >> $GITHUB_ENV
if: ${{ inputs.publish }}
- run: tox -e releasedocs -- ${VERSION}
if: ${{ inputs.version != '' }}
- run: tox -e docs
if: ${{ !inputs.publish }}
if: ${{ inputs.version == '' }}
- uses: actions/upload-artifact@v3
with:
name: html
name: docs_html
path: html/

- uses: JamesIves/[email protected]
if: ${{ inputs.publish }}
with:
branch: gh-pages
folder: html
target-folder: ${{ env.target }}
single-commit: true
clean-exclude: release
ssh-key: ${{ secrets.GH_PAGES_DEPLOY_KEY }}
36 changes: 36 additions & 0 deletions .github/workflows/nightly_at_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Nightly test at main branch

on:
workflow_dispatch:
schedule:
- cron: '30 23 * * *'

jobs:
setup:
name: Setup variables
runs-on: 'ubuntu-20.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
steps:
- uses: actions/checkout@v4
- name: Get Python version for other CI jobs
id: vars
run: echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT

tests:
name: Tests
needs: setup
strategy:
matrix:
os: ['ubuntu-20.04']
python:
- version: '${{needs.setup.outputs.min_python}}'
tox-env: 'nightly'
uses: ./.github/workflows/test.yml
with:
os-variant: ${{ matrix.os }}
python-version: ${{ matrix.python.version }}
tox-env: ${{ matrix.python.tox-env }}
43 changes: 43 additions & 0 deletions .github/workflows/nightly_at_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Nightly tests at latest release

on:
workflow_dispatch:
schedule:
- cron: '0 23 * * *'

jobs:
setup:
name: Setup variables
runs-on: 'ubuntu-20.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
release_tag: ${{ steps.release.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # history required so we can determine latest release tag
- name: Get last release tag from git
id: release
run: echo "release_tag=$(git describe --tags --abbrev=0 --match '[0-9]*.[0-9]*.[0-9]*')" >> $GITHUB_OUTPUT
- name: Get Python version for other CI jobs
id: vars
run: echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT

tests:
name: Tests
needs: setup
strategy:
matrix:
os: ['ubuntu-20.04']
python:
- version: '${{needs.setup.outputs.min_python}}'
tox-env: 'nightly'
uses: ./.github/workflows/test.yml
with:
os-variant: ${{ matrix.os }}
python-version: ${{ matrix.python.version }}
tox-env: ${{ matrix.python.tox-env }}
checkout_ref: ${{ needs.setup.outputs.release_tag }}
1 change: 1 addition & 0 deletions .github/workflows/python-version-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
101 changes: 48 additions & 53 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Release

on:
Expand All @@ -12,35 +15,39 @@ defaults:
jobs:
build_conda:
name: Conda build
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0 # history required so cmake can determine version
fetch-depth: 0 # history required so setuptools_scm can determine version

- uses: conda-incubator/setup-miniconda@v2
- run: conda install --yes conda-build
- run: conda build --channel conda-forge --channel scipp --python=3.8 --no-anaconda-upload --override-channels --output-folder conda/package conda
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: build-env
create-args: >-
conda-build
boa
- run: conda mambabuild --channel conda-forge --channel scipp --no-anaconda-upload --override-channels --output-folder conda/package conda

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: conda-package-noarch
path: conda/package/*/scippnexus*.tar.bz2
path: conda/package/noarch/*.tar.bz2

build_wheels:
name: Wheels
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # history required so setuptools_scm can determine version

- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version-file: '.github/workflows/python-version-ci'

- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/wheels.txt
Expand All @@ -57,65 +64,53 @@ jobs:
upload_pypi:
name: Deploy PyPI
needs: [build_wheels, build_conda]
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'
environment: release
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
- uses: actions/setup-python@v3
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

upload_conda:
name: Deploy Conda Forge
name: Deploy Conda
needs: [build_wheels, build_conda]
runs-on: ubuntu-20.04
runs-on: 'ubuntu-20.04'
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: mamba-org/setup-micromamba@v1
with:
python-version: '3.10'
- run: conda install -c conda-forge --yes anaconda-client
- run: anaconda --token ${{ secrets.ANACONDATOKEN }} upload --user scipp --label main $(ls conda-package-*/*/*.tar.bz2)

manage-versions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to manually clean up the gh-pages branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the settings in the deploy action in docs.yml might wipe that automatically?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it. Let's keep an eye on it in the next release.

name: Manage Versions
runs-on: ubuntu-20.04
outputs:
version-new: ${{ steps.version.outputs.new }}
version-replaced: ${{ steps.version.outputs.replaced }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # history required so cmake can determine version
- uses: actions/setup-python@v3
with:
python-version: '3.8'
- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/ci.txt
- name: Set outputs
id: version
run: |
echo "new=$(python docs/version.py --version=${GITHUB_REF_NAME} --action=is-new)" >> $GITHUB_OUTPUT
echo "replaced=$(python docs/version.py --version=${GITHUB_REF_NAME} --action=get-replaced)" >> $GITHUB_OUTPUT
environment-name: upload-env
# frozen python due to breaking removal of 'imp' in 3.12
create-args: >-
anaconda-client
python=3.11
- run: anaconda --token ${{ secrets.ANACONDATOKEN }} upload --user scipp --label main $(ls conda-package-noarch/*.tar.bz2)

docs:
needs: [upload_conda, upload_pypi, manage-versions]
needs: [upload_conda, upload_pypi]
uses: ./.github/workflows/docs.yml
with:
publish: ${{ github.event_name == 'release' && github.event.action == 'published' }}
version: ${{ github.ref_name }}
secrets: inherit

replaced-docs:
assets:
name: Upload docs
needs: docs
if: github.event_name == 'release' && github.event.action == 'published' && needs.manage-versions.outputs.version-new == 'True'
uses: ./.github/workflows/docs.yml
with:
publish: true
version: ${{ needs.manage-versions.outputs.version-replaced }}
secrets: inherit
runs-on: 'ubuntu-20.04'
permissions:
contents: write # This is needed so that the action can upload the asset
steps:
- uses: actions/download-artifact@v3
- name: Zip documentation
run: |
mv docs_html documentation-${{ github.ref_name }}
zip -r documentation-${{ github.ref_name }}.zip documentation-${{ github.ref_name }}
- name: Upload release assets
uses: svenstaro/upload-release-action@v2
with:
file: ./documentation-${{ github.ref_name }}.zip
overwrite: false
Loading