Skip to content

Commit 1e43b27

Browse files
authored
Merge branch 'main' into feat/add-missing-workflows
2 parents 420fb4c + f5cfa42 commit 1e43b27

File tree

5 files changed

+107
-72
lines changed

5 files changed

+107
-72
lines changed

docs/guide.qmd

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ First, open a Terminal and move into the directory where you want to
4242
create the new Python package. Then run the following command:
4343

4444
``` bash
45-
# Copy into the current directory, which is the "."
46-
uvx copier copy --trust gh:seedcase-project/template-python-package .
45+
uvx copier copy --trust gh:seedcase-project/template-python-package new-package
4746
```
4847

48+
Here, `new-package` is the name of the new folder you will create from
49+
the template. The template assumes that the name of your new folder will
50+
also be the name of the GitHub repository for the Python package. So the
51+
new folder name should be a short, lowercase name without spaces or
52+
special characters.
53+
4954
::: callout-caution
5055
This template runs some post-copy commands using your terminal. In order
5156
to run them, you need to use the `--trust` option. Review the
@@ -64,12 +69,13 @@ to the existing package. This will add all the template's files and
6469
configurations to the existing package.
6570

6671
``` bash
67-
uvx copier copy --trust gh:seedcase-project/template-python-package .
72+
uvx copier copy --trust gh:seedcase-project/template-python-package new-package
6873
```
6974

70-
It will go through a series of prompts, as in the case of creating a new
71-
Python package, including asking if you want to overwrite existing
72-
files.
75+
See the comment above in the "Creating a new Python package" section
76+
about naming the new folder. It will go through a series of prompts, as
77+
in the case of creating a new Python package, including asking if you
78+
want to overwrite existing files.
7379

7480
::: callout-note
7581
To use the `copy` command, the Python package needs to be tracked by Git
@@ -129,8 +135,8 @@ just install-precommit
129135
This sets up the pre-commit hooks to run standard checks on your
130136
repository whenever you commit files to the history.
131137

132-
If you are using the template to create a Python package for the Seedcase
133-
Project, run:
138+
If you are using the template to create a Python package for the
139+
Seedcase Project, run:
134140

135141
``` bash
136142
just update-quarto-theme
@@ -140,9 +146,9 @@ Then set `seedcase-theme` as your project `type` in `_quarto.yml`.
140146

141147
This adds the `seedcase-theme` Quarto theme to the website, which
142148
provides a consistent look and feel across all Seedcase Project
143-
websites, including for Python package websites.
144-
It's called `update-quarto-theme` here since you can use this
145-
command to keep the theme updated.
149+
websites, including for Python package websites. It's called
150+
`update-quarto-theme` here since you can use this command to keep the
151+
theme updated.
146152

147153
Next, install [`spaid`](https://github.com/seedcase-project/spaid) and
148154
use the following commands to run the next setup steps:
@@ -175,5 +181,5 @@ additional setup are:
175181
GitHub App, along with the `ADD_TO_BOARD_TOKEN` secret and the
176182
`ADD_TO_BOARD_APP_ID` variable of the GitHub App's ID.
177183

178-
If you use Netlify, you will also need to add a `NETLIFY_AUTH_TOKEN` secret
179-
of your Netlify Token.
184+
If you use Netlify, you will also need to add a `NETLIFY_AUTH_TOKEN`
185+
secret of your Netlify Token.

docs/includes/_badges.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- [![DOI]()]() -->
2-
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-teal.json?raw=true)](https://github.com/copier-org/copier)
2+
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-teal.json?raw=true.svg)](https://github.com/copier-org/copier)
33
[![GitHub License](https://img.shields.io/github/license/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/blob/main/LICENSE.md)
44
[![GitHub Release](https://img.shields.io/github/v/release/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/releases/latest)
55
[![Build website](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml/badge.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml)

justfile

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,60 +49,7 @@ check-spelling:
4949

5050
# 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")
5151
test is_seedcase_project="true" hosting_provider="netlify":
52-
#!/usr/bin/env bash
53-
test_name="test-package-{{ hosting_provider }}"
54-
test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name"
55-
template_dir="$(pwd)"
56-
commit=$(git rev-parse HEAD)
57-
rm -rf $test_dir
58-
# vcs-ref means the current commit/head, not a tag.
59-
uvx copier copy $template_dir $test_dir \
60-
--vcs-ref=$commit \
61-
--defaults \
62-
--trust \
63-
--data is_seedcase_project={{ is_seedcase_project }} \
64-
--data hosting_provider={{ hosting_provider }} \
65-
--data github_user="first-last" \
66-
--data author_given_name="First" \
67-
--data author_family_name="Last" \
68-
--data author_email="[email protected]" \
69-
--data review_team="@first-last/developers" \
70-
--data github_board_number=22
71-
# Run checks in the generated test Python package
72-
cd $test_dir
73-
git add .
74-
git commit -m "test: initial copy"
75-
just check-python check-spelling
76-
# TODO: Find some way to test the `update` command
77-
# Check that recopy works
78-
echo "Testing recopy command -----------"
79-
rm .cz.toml
80-
git add .
81-
git commit -m "test: preparing to recopy from the template"
82-
uvx copier recopy \
83-
--vcs-ref=$commit \
84-
--defaults \
85-
--overwrite \
86-
--trust
87-
# Check that copying onto an existing Python package works
88-
echo "Using the template in an existing package command -----------"
89-
rm .cz.toml .copier-answers.yml LICENSE.md
90-
git add .
91-
git commit -m "test: preparing to copy onto an existing package"
92-
uvx copier copy \
93-
$template_dir $test_dir \
94-
--vcs-ref=$commit \
95-
--defaults \
96-
--trust \
97-
--overwrite \
98-
--data is_seedcase_project={{ is_seedcase_project }} \
99-
--data hosting_provider={{ hosting_provider }} \
100-
--data github_user="first-last" \
101-
--data author_given_name="First" \
102-
--data author_family_name="Last" \
103-
--data author_email="[email protected]" \
104-
--data review_team="@first-last/developers" \
105-
--data github_board_number=22
52+
sh ./test-template.sh {{ is_seedcase_project }} {{ hosting_provider }}
10653

10754
# Clean up any leftover and temporary build files
10855
cleanup:

template/docs/includes/_badges.qmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!-- TODO: Include DOI after uploading -->
2-
<!-- [![PyPI Version](https://img.shields.io/pypi/v/{{< meta gh.repo >}})](https://pypi.org/project/{{< meta gh.repo >}}/) -->
3-
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-teal.json?raw=true)](https://github.com/copier-org/copier)
4-
[![Supported Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https://raw.githubusercontent.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/refs/heads/main/pyproject.toml)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/blob/main/pyproject.toml)
2+
<!-- [![PyPI Version](https://img.shields.io/pypi/v/{{< meta gh.repo >}}.svg)](https://pypi.org/project/{{< meta gh.repo >}}/) -->
3+
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-teal.json?raw=true.svg)](https://github.com/copier-org/copier)
4+
[![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2F{{< meta gh.org >}}%2F{{< meta gh.repo >}}%2Frefs%2Fheads%2Fmain%2Fpyproject.toml)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/blob/main/pyproject.toml)
55
[![GitHub License](https://img.shields.io/github/license/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/blob/main/LICENSE.md)
66
[![GitHub Release](https://img.shields.io/github/v/release/{{< meta gh.org >}}/{{< meta gh.repo >}}.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/releases/latest)
77
[![Build documentation](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml/badge.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-website.yml)
88
[![Build package](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-package.yml/badge.svg)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/build-package.yml)
9-
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/badge?raw=true)](https://scorecard.dev/viewer/?uri=github.com/{{< meta gh.org >}}/{{< meta gh.repo >}})
9+
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/badge?raw=true.svg)](https://scorecard.dev/viewer/?uri=github.com/{{< meta gh.org >}}/{{< meta gh.repo >}})
1010
[![CodeQL](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/actions/workflows/github-code-scanning/codeql)
1111
[![code coverage](https://raw.githubusercontent.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/coverage/coverage.svg?raw=true)](https://htmlpreview.github.io/?https://raw.githubusercontent.com/{{< meta gh.org >}}/{{< meta gh.repo >}}/coverage/index.html)
1212
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/{{< meta gh.org >}}/{{< meta gh.repo >}}/main.svg)](https://results.pre-commit.ci/latest/github/{{< meta gh.org >}}/{{< meta gh.repo >}}/main)

test-template.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
# Needs two arguments:
4+
#
5+
# 1. is_seedcase_project: true or false
6+
# 2. hosting_provider: e.g., "github", "gitlab", etc.
7+
8+
# Argument naming -----
9+
is_seedcase_project="${1}"
10+
hosting_provider="${2}"
11+
12+
if [ -z "$is_seedcase_project" ] || [ -z "$hosting_provider" ]; then
13+
echo "Usage: sh $0 <is_seedcase_project> <hosting_provider>"
14+
echo "Example: sh $0 true netlify"
15+
exit 1
16+
fi
17+
18+
# Set up variables and functions for the test -----
19+
test_name="test-package-$hosting_provider"
20+
test_dir="$(pwd)/_temp/$is_seedcase_project/$test_name"
21+
template_dir="$(pwd)"
22+
# Use the latest commit for the template
23+
commit=$(git rev-parse HEAD)
24+
25+
# Needs three arguments:
26+
#
27+
# 1. Template directory
28+
# 2. Destination directory
29+
# 3. VCS ref (commit, branch, tag, etc.)
30+
copy () {
31+
# vcs-ref means the current commit/head, not a tag.
32+
uvx copier copy $1 $2 \
33+
--vcs-ref=$3 \
34+
--defaults \
35+
--data is_seedcase_project=$is_seedcase_project \
36+
--data github_user="first-last" \
37+
--data hosting_provider=$hosting_provider \
38+
--data author_given_name="First" \
39+
--data author_family_name="Last" \
40+
--data author_email="[email protected]" \
41+
--data review_team="@first-last/developers" \
42+
--data github_board_number=22 \
43+
--overwrite \
44+
--skip-tasks \
45+
--trust
46+
}
47+
48+
# Pre-test setup -----
49+
# Remove the leftover directory from previous runs
50+
rm -rf $test_dir
51+
mkdir -p $test_dir
52+
53+
# Check initial creation -----
54+
# TODO: Find some way to test the `update` command
55+
# Any step that fails will exit the script with an error and not continue
56+
echo "Testing copy for new projects when: 'is_seedcase_project'='$is_seedcase_project', 'hosting_provider'='$hosting_provider' -----------"
57+
(
58+
cd $test_dir &&
59+
copy $template_dir $test_dir $commit &&
60+
git init -b main &&
61+
git add . &&
62+
git commit --quiet -m "test: initial copy" &&
63+
# Check that recopy works -----
64+
echo "Testing recopy when: 'is_seedcase_project'='$$is_seedcase_project', 'hosting_provider'='$hosting_provider' -----------" &&
65+
rm .cz.toml &&
66+
git add . &&
67+
git commit --quiet -m "test: preparing to recopy from the template" &&
68+
uvx copier recopy \
69+
--vcs-ref=$commit \
70+
--defaults \
71+
--overwrite \
72+
--skip-tasks \
73+
--trust &&
74+
# Check that copying onto an existing package works -----
75+
echo "Testing copy in existing projects when: 'is_seedcase_project'='$is_seedcase_project', 'hosting_provider'='$hosting_provider' -----------" &&
76+
rm .cz.toml .copier-answers.yml &&
77+
git add . &&
78+
git commit --quiet -m "test: preparing to copy onto an existing package" &&
79+
copy $template_dir $test_dir $commit #&&
80+
# Checks and builds -----
81+
# just run-all
82+
)

0 commit comments

Comments
 (0)