-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
121 lines (109 loc) · 4.18 KB
/
justfile
File metadata and controls
121 lines (109 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@_default:
just --list --unsorted
@_checks: check-spelling check-commits
# Test Seedcase and non-Seedcase projects
@_tests: (test "true" "netlify") (test "false" "netlify") (test "true" "gh-pages") (test "false" "gh-pages")
@_builds: build-contributors build-website build-readme
# Run all build-related recipes in the justfile
run-all: update-quarto-theme update-template _checks _tests _builds
# Install the pre-commit hooks
install-precommit:
# Install pre-commit hooks
uvx pre-commit install
# Run pre-commit hooks on all files
uvx pre-commit run --all-files
# Update versions of pre-commit hooks
uvx pre-commit autoupdate
# Update the Quarto seedcase-theme extension
update-quarto-theme:
quarto add seedcase-project/seedcase-theme --no-prompt
# Update files in the template from the copier parent folder
update-template:
cp .pre-commit-config.yaml .typos.toml .editorconfig template/
mkdir -p template/tools
cp tools/get-contributors.sh template/tools/
cp .github/pull_request_template.md template/.github/
cp .github/workflows/dependency-review.yml template/.github/workflows/
# Check the commit messages on the current branch that are not on the main branch
check-commits:
#!/usr/bin/env bash
branch_name=$(git rev-parse --abbrev-ref HEAD)
number_of_commits=$(git rev-list --count HEAD ^main)
if [[ ${branch_name} != "main" && ${number_of_commits} -gt 0 ]]
then
# If issue happens, try `uv tool update-shell`
uvx --from commitizen cz check --rev-range main..HEAD
else
echo "On 'main' or current branch doesn't have any commits."
fi
# Check for spelling errors in files
check-spelling:
uvx typos
# 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")
test is_seedcase_project="true" hosting_provider="netlify":
#!/usr/bin/env bash
test_name="test-package-{{ hosting_provider }}"
test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name"
template_dir="$(pwd)"
commit=$(git rev-parse HEAD)
rm -rf $test_dir
# vcs-ref means the current commit/head, not a tag.
uvx copier copy $template_dir $test_dir \
--vcs-ref=$commit \
--defaults \
--trust \
--data package_github_repo="first-last/repo" \
--data is_seedcase_project={{ is_seedcase_project }} \
--data hosting_provider={{ hosting_provider }} \
--data author_given_name="First" \
--data author_family_name="Last" \
--data author_email="first.last@example.com" \
--data review_team="@first-last/developers" \
--data github_board_number=22
# Run checks in the generated test Python package
cd $test_dir
git add .
git commit -m "test: initial copy"
just check-python check-spelling
# TODO: Find some way to test the `update` command
# Check that recopy works
echo "Testing recopy command -----------"
rm .cz.toml
git add .
git commit -m "test: preparing to recopy from the template"
uvx copier recopy \
--vcs-ref=$commit \
--defaults \
--overwrite \
--trust
# Check that copying onto an existing Python package works
echo "Using the template in an existing package command -----------"
rm .cz.toml .copier-answers.yml LICENSE.md
git add .
git commit -m "test: preparing to copy onto an existing package"
uvx copier copy \
$template_dir $test_dir \
--vcs-ref=$commit \
--defaults \
--trust \
--overwrite \
--data package_github_repo="first-last/repo" \
--data is_seedcase_project={{ is_seedcase_project }} \
--data hosting_provider={{ hosting_provider }} \
--data author_given_name="First" \
--data author_family_name="Last" \
--data author_email="first.last@example.com" \
--data review_team="@first-last/developers" \
--data github_board_number=22
# Clean up any leftover and temporary build files
cleanup:
rm -rf _temp
# Build the website using Quarto
build-website:
uvx --from quarto quarto render
# Re-build the README file from the Quarto version
build-readme:
uvx --from quarto quarto render README.qmd --to gfm
# Generate a Quarto include file with the contributors
build-contributors:
sh ./tools/get-contributors.sh seedcase-project/template-python-project