Skip to content

Commit

Permalink
Merge pull request #471 from scipp/copier-template
Browse files Browse the repository at this point in the history
Use copier template
  • Loading branch information
jl-wynen authored Nov 30, 2023
2 parents 022555b + df77e44 commit 4916006
Show file tree
Hide file tree
Showing 76 changed files with 2,043 additions and 1,942 deletions.
7 changes: 4 additions & 3 deletions .buildconfig/ci-linux-39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ dependencies:
- nbsphinx==0.9.3
- packaging==23.2
- pandoc==3.1.3
- pydata-sphinx-theme==0.14.4
- requests==2.31.0
- sphinx==4.5.0
- sphinx-autodoc-typehints==1.19.2
- sphinx-book-theme==0.3.3
- sphinx==7.2.6
- sphinx-autodoc-typehints==1.25.2
- sphinx-copybutton==0.5.2
- sphinx-design==0.5.0
- sphinxcontrib-bibtex==2.6.1
8 changes: 5 additions & 3 deletions .buildconfig/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ dependencies:
- tox==4.11.3

# docs
- myst-parser==2.0.0
- nbsphinx==0.9.3
- packaging==23.2
- pandoc==3.1.3
- pydata-sphinx-theme==0.14.4
- requests==2.31.0
- sphinx==4.5.0
- sphinx-autodoc-typehints==1.19.2
- sphinx-book-theme==0.3.3
- sphinx==7.2.6
- sphinx-autodoc-typehints==1.25.2
- sphinx-copybutton==0.5.2
- sphinx-design==0.5.0
- sphinxcontrib-bibtex==2.6.1
13 changes: 13 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: ff7f76b
_src_path: gh:scipp/copier_template
description: Neutron scattering tools for Data Reduction
max_python: '3.11'
min_python: '3.9'
namespace_package: ''
nightly_deps: scipp,scippnexus,plopp
orgname: scipp
prettyname: ScippNeutron
projectname: scippneutron
related_projects: Scipp,ScippNexus,Plopp
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
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: CI

on:
push:
branches:
- main
- release
pull_request:

jobs:
formatting:
name: Formatting and static analysis
runs-on: 'ubuntu-22.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
min_tox_env: ${{ steps.vars.outputs.min_tox_env }}
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
echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v4
with:
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
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply automatic formatting

tests:
name: Tests
needs: formatting
strategy:
matrix:
os: ['ubuntu-22.04']
python:
- version: '${{needs.formatting.outputs.min_python}}'
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
branch: ${{ github.head_ref == '' && github.ref_name || github.head_ref }}
78 changes: 78 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Docs

on:
workflow_dispatch:
inputs:
publish:
default: false
type: boolean
version:
default: ''
required: false
type: string
branch:
description: 'Branch/tag with documentation source. If not set, the current branch will be used.'
default: ''
required: false
type: string
workflow_call:
inputs:
publish:
default: false
type: boolean
version:
default: ''
required: false
type: string
branch:
description: 'Branch/tag with documentation source. If not set, the current branch will be used.'
default: ''
required: false
type: string

env:
VERSION: ${{ inputs.version }}

jobs:
docs:
name: Build documentation
runs-on: 'ubuntu-22.04'
defaults:
run:
shell: bash -l {0} # required for conda env
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: mamba-org/setup-micromamba@v1
with:
environment-file: .buildconfig/ci-linux.yml
cache-environment: true
create-args: >-
python=3.10
conda-build
- run: conda develop src
if: ${{ inputs.version == '' }}
- run: conda install -c scipp 'scippneutron==${{ inputs.version }}'
if: ${{ inputs.version != '' }}
- run: |
python -m sphinx -j2 -v -b html -d doctrees docs html
python -m sphinx -j2 -v -b doctest -d doctrees docs html
find html -type f -name "*.ipynb" -not -path "html/_sources/*" -delete
- uses: actions/upload-artifact@v3
with:
name: docs_html
path: html/

- uses: JamesIves/github-pages-deploy-action@v4.4.3
if: ${{ inputs.publish }}
with:
branch: gh-pages
folder: html
single-commit: true
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 1 * * 1-5'

jobs:
setup:
name: Setup variables
runs-on: 'ubuntu-22.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-22.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 1 * * 1-5'

jobs:
setup:
name: Setup variables
runs-on: 'ubuntu-22.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-22.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 }}
32 changes: 0 additions & 32 deletions .github/workflows/pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,7 @@ concurrency:
cancel-in-progress: true # cancel jobs from previous push

jobs:
formatting:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- 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
- run: tox -e static
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply automatic formatting

tests:
needs: formatting
name: tests ${{ matrix.variant.os }}, py${{ matrix.variant.python-version }}
runs-on: ${{ matrix.variant.os }}
defaults:
Expand Down Expand Up @@ -59,19 +43,3 @@ jobs:
- run: conda develop src
- run: python -m pytest

- run: |
python -m sphinx -j2 -v -b html -d doctrees docs html
python -m sphinx -j2 -v -b doctest -d doctrees docs html
find html -type f -name "*.ipynb" -not -path "html/_sources/*" -delete
if: ${{ contains(matrix.variant.os, 'ubuntu') && matrix.variant.python-version == '3.10' }}
- run: python -m sphinx -j4 -v -b linkcheck -d doctrees docs html
# Linkcheck can be flaky. Avoid randomly breaking PR builds by running only on `main`
if: ${{ contains(matrix.variant.os, 'ubuntu') && matrix.variant.python-version == '3.10' && github.ref == 'refs/heads/main' }}

- uses: actions/upload-artifact@v3
if: ${{ contains(matrix.variant.os, 'ubuntu') && matrix.variant.python-version == '3.10' }}
with:
name: DocumentationHTML
path: html/
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.9
Loading

0 comments on commit 4916006

Please sign in to comment.