Skip to content

Commit a660c77

Browse files
Update copier CI action and add snakemake linting (#9)
* Ensure the module looks nice in the snakemake catalog * Improve .gitignore file omissions * Use templated github workflows for releases, PRs, and tempalte version checking * Add useful tools to pixi (ipdb, ipykernel) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 26aecae commit a660c77

22 files changed

Lines changed: 195 additions & 53 deletions

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
add-latest-tag:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Run latest-tag
14+
uses: EndBug/latest-tag@v1.6.2
15+
with:
16+
# Name of the tag.
17+
ref: latest
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Adapted from https://github.com/arup-group/actions-city-modelling-lab/blob/main/.github/workflows/template-check.yml
2+
# MIT licensed
3+
4+
name: Reusable workflow for keeping up-to-date with template changes.
5+
on:
6+
workflow_call:
7+
8+
defaults:
9+
run:
10+
shell: bash -l {0}
11+
12+
jobs:
13+
copier-issue:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
issues: write
18+
env:
19+
UPDATE: "false"
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
ref: "latest" # This avoids comparing against development versions.
24+
25+
- name: Setup pixi
26+
uses: prefix-dev/setup-pixi@v0.8.3
27+
28+
- name: Add copier
29+
run: pixi add copier
30+
31+
- name: Add dummy GitHub credentials
32+
run: |
33+
git config --global user.name Copier update
34+
git config --global user.email check@dummy.bot.com
35+
36+
- name: Run copier update
37+
run: pixi run copier update --skip-answered --defaults
38+
39+
- name: Check for template changes
40+
run: test -z "$(git status --porcelain)" || echo "UPDATE=true" >> $GITHUB_ENV
41+
42+
- name: Open issue
43+
if: env.UPDATE == 'true'
44+
run: |
45+
gh issue --repo ${{ github.repository }} \
46+
create --title "Template update" --body "The template has been updated. Please run `copier update` and merge changes."
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Reusable Pull Request CI tests for modules
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, windows-latest, macos-latest]
14+
python-version: ["3.12"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: setup-pixi
18+
uses: prefix-dev/setup-pixi@v0.8.3
19+
- name: Run tests
20+
run: pixi run test
21+
- name: Run linting
22+
run: pixi run snakemake --lint
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Reusable release workflow for modules
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
add-latest-tag:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Run latest-tag
13+
uses: EndBug/latest-tag@v1.6.2
14+
with:
15+
# Name of the tag.
16+
ref: latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ We recommend using [`pixi`](https://pixi.sh/) as your package manager. Once inst
6767
> - **Please be sure to maintain the following files to ensure `clio` compatibility**
6868
> - These are:
6969
> - `INTERFACE.yaml`: a simple description of the module's input/output structure.
70-
> - `config/example.yaml`: a basic functioning example of how to configure this module.
70+
> - `config/config.yaml`: a basic functioning example of how to configure this module.
7171
> - `workflow/internal/config.schema.yaml`: the module's configuration schema, used by `snakemake` for [validation](https://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html).
7272
> - `AUTHORS` / `CITATION.cff` / `LICENSE`: licensing and attribution of this module's code and methods.
7373
> - If the optional auto-generated documentation was selected, `docs/hooks/clio_standard.py` will use these files to automatically generate a basic Read the Docs website.

copier.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
_min_copier_version: '9.4.1'
33
_subdirectory: template
44
_skip_if_exists:
5-
- config/example.yaml
6-
- docs/ # documentation must be present, but we do not enforce its shape
7-
- tests/ # Tests must be present, but we do not enforce their content
8-
- "!tests/clio_test.py" # except for the set of standard tests
9-
- workflow/ # A workflow must be present, but it can have anything within it
10-
- "!workflow/profiles/default/config.yaml" # except that the profile must not change
5+
# Respect user changes, except for a few standard files.
6+
- config/*
7+
- "!config/README.md" # Necessary for the snakemake workflow catalog
8+
- docs/*
9+
- resources/*
10+
- results/*
11+
- tests/*
12+
- "!tests/clio_test.py" # Standard integration tests
13+
- workflow/
14+
- "!workflow/profiles" # Profiles should be equal across projects
1115
- AUTHORS
1216
- CITATION.cff
1317
- INTERFACE.yaml
14-
- pixi.toml
15-
- README.md
1618
_templates_suffix: .jinja
1719
_answers_file: .copier-answers.yml
1820

pixi.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[project]
22
name = "data-module-template"
3-
version = "0.1.0"
43
authors = ["See AUTHORS file"]
54
description = "A template for `clio` data modules."
65
license = "Apache-2.0"

template/.github/issue_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Problem description
2+
3+
<!-- Describe the problem or error here -->
4+
5+
## Steps to reproduce the problem
6+
7+
<!-- Describe the steps needed to reproduce the problem here -->
8+
<!-- We recommend including the configuration and user resources used. -->
9+
10+
## Module version
11+
12+
<!-- Exact module version used -->
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Fixes #
2+
3+
## Summary of changes in this pull request
4+
5+
*
6+
*
7+
*
8+
9+
## Reviewer checklist
10+
11+
* [ ] `INTERFACE.yaml` is up-to-date with all relevant user resources and results.
12+
* [ ] The integration example is up-to-date with a minimal use-case of the module.
13+
* [ ] Module documentation is up-to-date.

template/.github/workflows/check-latest-template-spec.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)