-
Notifications
You must be signed in to change notification settings - Fork 0
build: 🔧 update config for non-template package #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
356275d
7ac1a31
e3f9cc8
af6b8a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Template for Seedcase Python packages | ||
|
|
||
| This repository contains a template for setting up new Python package projects in Seedcase. The first step is to create a new repository using this template. This can easily be done by clicking the "Use this template" button on the repository page or by using the GitHub CLI: | ||
|
|
||
| ``` bash | ||
| # NAME is the name to give the new repository | ||
| gh repo create NAME --template seedcase-project/template-python-project | ||
| ``` | ||
|
|
||
| ## Setting things up after cloning | ||
|
|
||
| Search for `NAME` and `REPO` and replace them with the name of your project and the repository name. Then look for any `TODO` items. | ||
|
|
||
| ## Setting things up | ||
|
|
||
| Use the commands found in [`spaid`](https://github.com/seedcase-project/spaid) repo to run the next setup steps. | ||
|
|
||
| Need to install these packages after: | ||
|
|
||
| ``` bash | ||
| uv add --dev pre-commit ruff typos pytest bandit commitizen \ | ||
| genbadge jupyter pytest-cov quartodoc | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| - source: project | ||
| netlify: | ||
| # TODO: Include correct ID | ||
| - id: "" | ||
| url: "https://NAME-seedcase-project.netlify.app" | ||
| - id: "8775b18b-3a1a-4dfc-b6c7-a1ef7205d30f" | ||
| url: "https://seedcase-template-python-package.netlify.app" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| @_default: | ||
| just --list --unsorted | ||
|
|
||
| @_checks: check-spelling check-commits | ||
| @_builds: build-contributors build-website build-readme | ||
|
|
||
| # Run all build-related recipes in the justfile | ||
| run-all: install-deps format-python check-python check-unused test-python check-security check-spelling check-commits build-website | ||
| run-all: update-quarto-theme update-template _checks test _builds | ||
|
|
||
| # Install the pre-commit hooks | ||
| install-precommit: | ||
|
|
@@ -13,78 +16,52 @@ install-precommit: | |
| # Update versions of pre-commit hooks | ||
| uvx pre-commit autoupdate | ||
|
|
||
| # Install Python package dependencies | ||
| install-deps: | ||
| uv sync --all-extras --dev | ||
|
|
||
| # Run the Python tests | ||
| test-python: | ||
| uv run pytest | ||
| # Make the badge from the coverage report | ||
| uv run genbadge coverage \ | ||
| -i coverage.xml \ | ||
| -o htmlcov/coverage.svg | ||
|
|
||
| # Check Python code for any errors that need manual attention | ||
| check-python: | ||
| # Check formatting | ||
| uv run ruff check . | ||
| # Check types | ||
| uv run mypy . | ||
| # Update the Quarto seedcase-theme extension | ||
| update-quarto-theme: | ||
| quarto add seedcase-project/seedcase-theme --no-prompt | ||
|
|
||
| # Reformat Python code to match coding style and general structure | ||
| format-python: | ||
| uv run ruff check --fix . | ||
| uv run ruff format . | ||
| # Update files in the template from the copier parent folder | ||
| update-template: | ||
| cp .cz.toml .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/build-website.yml .github/workflows/dependency-review.yml template/.github/workflows/ | ||
|
Comment on lines
+24
to
+29
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only bit I changed from the template-website version
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The build website workflow may need to be removed. But we can deal with that later, as you add the |
||
|
|
||
| # Build the documentation website using Quarto | ||
| build-website: | ||
| # To let Quarto know where python is. | ||
| export QUARTO_PYTHON=.venv/bin/python3 | ||
| # Delete any previously built files from quartodoc. | ||
| # -f is to not give an error if the files don't exist yet. | ||
| rm -f docs/reference/*.qmd | ||
| uv run quartodoc build | ||
| uv run quarto render --execute | ||
|
|
||
| # Run checks on commits with non-main branches | ||
| # Check the commit messages on the current branch that are not on the main branch | ||
| check-commits: | ||
| #!/bin/zsh | ||
| 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 | ||
| uv run cz check --rev-range main..HEAD | ||
| uvx --from commitizen cz check --rev-range main..HEAD | ||
| else | ||
| echo "Can't either be on ${branch_name} or have more than ${number_of_commits}." | ||
| echo "On `main` or current branch doesn't have any commits." | ||
| fi | ||
|
|
||
| # Run basic security checks on the package | ||
| check-security: | ||
| uv run bandit -r src/ | ||
|
|
||
| # Check for spelling errors in files | ||
| check-spelling: | ||
| uv run typos | ||
| uvx typos | ||
|
|
||
| # Test and check that a Python package can be created from the template | ||
| # TODO: add test for copier | ||
| test: | ||
| echo "copier test" | ||
|
|
||
| # Clean up any leftover and temporary build files | ||
| cleanup: | ||
| #!/bin/zsh | ||
| rm -rf _temp | ||
|
|
||
| # Build the website using Quarto | ||
| build-website: | ||
| uvx --from quarto quarto render | ||
|
|
||
| # Build the documentation as PDF using Quarto | ||
| build-pdf: | ||
| # To let Quarto know where python is. | ||
| export QUARTO_PYTHON=.venv/bin/python3 | ||
| uv run quarto install tinytex | ||
| # For generating images from Mermaid diagrams | ||
| uv run quarto install chromium | ||
| uv run quarto render --profile pdf --to pdf | ||
| find docs -name "mermaid-figure-*.png" -delete | ||
| # Re-build the README file from the Quarto version | ||
| build-readme: | ||
| uvx --from quarto quarto render README.qmd --to gfm | ||
|
|
||
| # Check for unused code in the package and its tests | ||
| check-unused: | ||
| # exit code=0: No unused code was found | ||
| # exit code=3: Unused code was found | ||
| # Three confidence values: | ||
| # - 100 %: function/method/class argument, unreachable code | ||
| # - 90 %: import | ||
| # - 60 %: attribute, class, function, method, property, variable | ||
| # There are some things should be ignored though, with the allowlist. | ||
| # Create an allowlist with `vulture --make-allowlist` | ||
| uv run vulture src/ tests/ **/vulture-allowlist.py | ||
| # Generate a Quarto include file with the contributors | ||
| build-contributors: | ||
| sh ./tools/get-contributors.sh seedcase-project/template-workshop | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Get a list of contributors to this repository and save it to | ||
| # _contributors.qmd.tmp file. It also: | ||
| # | ||
| # - Formats users into Markdown links to their GitHub profiles. | ||
| # - Removes any usernames with the word "bot" in them. | ||
| # - Removes the trailing comma from the list. | ||
| repo_spec=${1} | ||
| echo "These are the people who have contributed by submitting changes through pull requests :tada:\n\n" > _contributors.qmd.tmp | ||
| gh api \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| /repos/$repo_spec/contributors \ | ||
| --template '{{range .}} [\@{{.login}}]({{.html_url}}){{"\n"}}{{end}}' | \ | ||
| grep -v "\[bot\]" | \ | ||
| tr '\n' ', ' | \ | ||
| sed -e 's/,$//' >> _contributors.qmd.tmp |
Uh oh!
There was an error while loading. Please reload this page.