Skip to content

Commit 420fb4c

Browse files
authored
Merge branch 'main' into feat/add-missing-workflows
2 parents e73cad3 + 498fbc4 commit 420fb4c

16 files changed

+106
-83
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1818

1919
- name: Set up uv
20-
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba
20+
uses: astral-sh/setup-uv@4959332f0f014c5280e7eac8b70c90cb574c9f9b
2121
with:
2222
enable-cache: true
2323

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ repos:
2525
# sub-packages, which confuses pre-commit when it tries to find the latest
2626
# version
2727
- repo: https://github.com/adhtruong/mirrors-typos
28-
rev: v1.35.4
28+
rev: v1.35.5
2929
hooks:
3030
- id: typos

copier.yaml

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,31 @@ _tasks:
99
# Message to show after generating or regenerating the project successfully
1010
_message_after_copy: |
1111
12-
Your project "{{ package_name }}" has been created successfully!
12+
Your project "{{ github_repo }}" has been created successfully!
1313
14-
Next steps:
14+
See the [guide](https://template-python-package.seedcase-project.org/docs/guide) for more detail
15+
on the next steps. Briefly:
1516
1617
1. Change directory to the project root:
1718
18-
$ cd {{ _copier_conf.dst_path }}
19+
``` bash
20+
cd {{ _copier_conf.dst_path | realpath }}
21+
```
1922
20-
2. Install the pre-commit hooks:
23+
2. Install the pre-commit hooks, add (called "update" here) the Quarto extension,
24+
and build the README:
2125
22-
$ just install-precommit
26+
``` bash
27+
just install-precommit update-quarto-theme build-readme
28+
```
2329
24-
3. Install [`spaid`](https://github.com/seedcase-project/spaid) and run these commands to upload and configure your project on GitHub:
30+
3. Install [`spaid`](https://github.com/seedcase-project/spaid) and run these setup steps:
2531
26-
$ spaid_gh_create_repo_from_local -h
27-
$ spaid_gh_set_repo_settings -h
28-
$ spaid_gh_ruleset_basic_protect_main -h
32+
``` bash
33+
spaid_gh_create_repo_from_local -h
34+
spaid_gh_set_repo_settings -h
35+
spaid_gh_ruleset_basic_protect_main -h
36+
```
2937
3038
4. Configure GitHub following this
3139
[guide](https://guidebook.seedcase-project.org/operations/security#using-github-apps-to-generate-tokens):
@@ -37,46 +45,37 @@ _message_after_copy: |
3745
3846
5. List and complete all TODO items in the repository:
3947
40-
$ just list-todos
48+
``` bash
49+
just list-todos
50+
```
4151
4252
# Questions:
43-
package_github_repo:
44-
type: str
45-
help: "What is or will be the GitHub repository spec for the project?"
46-
placeholder: "user/repo"
47-
validator: |
48-
{% if package_github_repo and not (package_github_repo | regex_search('^[\w.-]+\/[\w.-]+$')) %}
49-
Must be in the format `user/repo` and contain only alphanumeric characters and `_`, `-`, or `.`.
50-
{% endif %}
53+
is_seedcase_project:
54+
type: bool
55+
help: "Is this package part of the Seedcase Project?"
56+
default: true
5157

52-
github_user:
58+
github_repo:
5359
type: str
54-
default: "{{ package_github_repo.split('/')[0] if package_github_repo else '' }}"
60+
default: "{{ _copier_conf.dst_path | realpath | basename }}"
5561
when: false
5662

57-
package_name:
63+
github_user:
5864
type: str
59-
help: "What is the name of the package?"
60-
default: "{{ _copier_conf.dst_path | basename }}"
61-
validator: |
62-
{% if package_name and not (package_name | regex_search('^[\w.-]+$')) %}
63-
Must contain only alphanumeric characters and `_`, `-`, or `.`.
64-
{% endif %}
65+
help: "What is the name of the GitHub user or organisation where the repository will be or is stored?"
66+
default: "{{ 'seedcase-project' if is_seedcase_project else '' }}"
6567

66-
package_name_snake_case:
68+
hosting_provider:
6769
type: str
68-
default: "{{package_name | replace('-', '_') | replace('.', '_')}}"
69-
when: false
70-
71-
is_seedcase_project:
72-
type: bool
73-
help: "Is this package part of the Seedcase Project?"
74-
default: "{{ github_user == 'seedcase-project' }}"
70+
help: "What hosting provider will you use for the documentation website?"
71+
choices:
72+
- netlify
73+
- gh-pages
7574

7675
homepage:
7776
type: str
7877
help: "What is the homepage of your project?"
79-
default: "{{ 'https://%s.seedcase-project.org' % package_name if is_seedcase_project else '' }}"
78+
default: "{{ 'https://%s.seedcase-project.org' % github_repo if is_seedcase_project else '' }}"
8079

8180
author_given_name:
8281
type: str
@@ -103,6 +102,16 @@ github_board_number:
103102
The board number must be an integer.
104103
{% endif %}
105104
105+
github_repo_snake_case:
106+
type: str
107+
default: "{{github_repo | replace('-', '_') | replace('.', '_')}}"
108+
when: false
109+
110+
github_repo_spec:
111+
type: str
112+
default: "{{ github_user }}/{{ github_repo }}"
113+
when: false
114+
106115
copyright_year:
107116
type: str
108117
default: "{{ copyright_year | default('%Y' | strftime) }}"

justfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@_checks: check-spelling check-commits
55
# Test Seedcase and non-Seedcase projects
6-
@_tests: (test "true") (test "false")
6+
@_tests: (test "true" "netlify") (test "false" "netlify") (test "true" "gh-pages") (test "false" "gh-pages")
77
@_builds: build-contributors build-website build-readme
88

99
# Run all build-related recipes in the justfile
@@ -47,10 +47,10 @@ check-commits:
4747
check-spelling:
4848
uvx typos
4949

50-
# Test and check that a Python package can be created from the template
51-
test is_seedcase_project:
50+
# Test that a Python package can be created from the template, with parameters for: `is_seedcase_project` (true or false) and `hosting_provider` (either "gh-pages" or "netlify")
51+
test is_seedcase_project="true" hosting_provider="netlify":
5252
#!/usr/bin/env bash
53-
test_name="test-python-package"
53+
test_name="test-package-{{ hosting_provider }}"
5454
test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name"
5555
template_dir="$(pwd)"
5656
commit=$(git rev-parse HEAD)
@@ -60,8 +60,9 @@ test is_seedcase_project:
6060
--vcs-ref=$commit \
6161
--defaults \
6262
--trust \
63-
--data package_github_repo="first-last/repo" \
6463
--data is_seedcase_project={{ is_seedcase_project }} \
64+
--data hosting_provider={{ hosting_provider }} \
65+
--data github_user="first-last" \
6566
--data author_given_name="First" \
6667
--data author_family_name="Last" \
6768
--data author_email="[email protected]" \
@@ -94,8 +95,9 @@ test is_seedcase_project:
9495
--defaults \
9596
--trust \
9697
--overwrite \
97-
--data package_github_repo="first-last/repo" \
9898
--data is_seedcase_project={{ is_seedcase_project }} \
99+
--data hosting_provider={{ hosting_provider }} \
100+
--data github_user="first-last" \
99101
--data author_given_name="First" \
100102
--data author_family_name="Last" \
101103
--data author_email="[email protected]" \

template/.github/workflows/build-website.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build website
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Limit token permissions for security
9+
permissions: read-all
10+
11+
jobs:
12+
build-website:
13+
uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main
14+
{%- if hosting_provider == 'gh-pages' %}
15+
with:
16+
hosting-provider: gh-pages
17+
permissions:
18+
contents: write
19+
pages: write
20+
{%- endif %}
21+
secrets:
22+
{% if hosting_provider == 'gh-pages' -%}
23+
github-token: {{ '${{ secrets.GITHUB_TOKEN }}' }}
24+
{%- elif hosting_provider == 'netlify' -%}
25+
netlify-token: {{ '${{ secrets.NETLIFY_AUTH_TOKEN }}' }}
26+
{%- endif %}

template/CITATION.cff.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ keywords:
2020
- ""
2121
license: MIT
2222
message: "If you use this Python package, please cite it using these metadata."
23-
repository-code: "https://github.com/{{ package_github_repo }}"
23+
repository-code: "https://github.com/{{ github_repo_spec }}"
2424
url: "{{ homepage }}"

template/LICENSE.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) {{ copyright_year }} {{ package_name }} authors
3+
Copyright (c) {{ copyright_year }} {{ github_repo }} authors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

template/_publish.yml

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

template/_quarto.yml.jinja

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@ project:
1111
website:
1212
# TODO: Fill in the title of the website.
1313
title: ""
14+
{% if hosting_provider == "gh-pages" -%}
15+
site-url: "https://{{ github_user }}.github.io/{{ github_repo }}/"
16+
{%- elif hosting_provider == "netlify" -%}
17+
# TODO: Set the Netlify custom domain URL
1418
site-url: "{{ homepage }}"
15-
repo-url: "https://github.com/{{ package_github_repo }}"
19+
{%- endif %}
20+
repo-url: "https://github.com/{{ github_repo_spec }}"
1621
page-navigation: true
1722
navbar:
1823
pinned: true
1924
title: false
2025
{%- if is_seedcase_project %}
21-
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ package_name }}.svg"
22-
logo-alt: "{{ package_name }} logo: Main page"
26+
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ github_repo }}.svg"
27+
logo-alt: "{{ github_repo }} logo: Main page"
2328
{%- else %}
2429
# TODO: add logo
2530
logo: ""
26-
logo-alt: "{{ package_name }} logo: Main page"
31+
logo-alt: "{{ github_repo }} logo: Main page"
2732
{%- endif %}
2833
left:
2934
- text: "Guide"
@@ -32,7 +37,7 @@ website:
3237
href: docs/design/index.qmd
3338
tools:
3439
- icon: github
35-
href: "https://github.com/{{ package_github_repo }}"
40+
href: "https://github.com/{{ github_repo_spec }}"
3641
aria-label: "GitHub icon: Source code"
3742
{%- if is_seedcase_project %}
3843
- icon: house
@@ -55,7 +60,7 @@ quartodoc:
5560
sidebar: "docs/reference/_sidebar.yml"
5661
style: "pkgdown"
5762
dir: "docs/reference"
58-
package: "{{ package_name_snake_case }}"
63+
package: "{{ github_repo_snake_case }}"
5964
parser: google
6065
dynamic: true
6166
renderer:

0 commit comments

Comments
 (0)