Skip to content
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

Fixing variables and new updated differences from the pip-skeleton #9

Merged
merged 17 commits into from
Jan 9, 2024
Merged
3 changes: 3 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ spec:
docker_containers:
title: Are you working with Docker containers?
type: boolean
default: "false"
vscode_option:
title: Are you using vscode?
type: boolean
default: "false"
docs_option:
title: Would you like docs?
type: boolean
default: "false"


# This template is meant to be used on top of an existing template.
Expand Down
14 changes: 5 additions & 9 deletions template/README.rst.jinja
M-Chan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

|code_ci| |docs_ci| |coverage| |pypi_version| |license|

.. note::

This project contains template code.

This is where you should write a short paragraph that describes what your module does,
how it does it, and why people should use it.

Expand Down Expand Up @@ -39,12 +35,12 @@ Or if it is a commandline tool then you might put some example commands here::
:target: {{repo_url}}/actions/workflows/docs.yml
:alt: Docs CI

.. |coverage| image:: https://codecov.io/gh/{{github_org}}/{{package_name}}/branch/main/graph/badge.svg
:target: https://codecov.io/gh/{{github_org}}/{{package_name}}
.. |coverage| image:: https://codecov.io/gh/{{github_org}}/{{repo_name}}/branch/main/graph/badge.svg
:target: https://codecov.io/gh/{{github_org}}/{{repo_name}}
:alt: Test Coverage

.. |pypi_version| image:: https://img.shields.io/pypi/v/template_shell.svg
:target: https://pypi.org/project/{{package_name}}
.. |pypi_version| image:: https://img.shields.io/pypi/v/{{pypi_name}}.svg
:target: https://pypi.org/project/{{pypi_name}}
:alt: Latest PyPI version

.. |license| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
Expand All @@ -55,4 +51,4 @@ Or if it is a commandline tool then you might put some example commands here::
Anything below this line is used when viewing README.rst and will be replaced
when included in index.rst

See https://{{github_org}}.github.io/{{package_name}} for more detailed documentation.
See {{docs_url}} for more detailed documentation.
4 changes: 2 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ dev = [
]

[project.scripts]
{{package_name}} = "{{package_name}}.__main__:main"
{{repo_name}} = "{{package_name}}.__main__:main"

[project.urls]
GitHub = "{{url}}"
GitHub = "{{repo_url}}"

[[project.authors]] # Further authors may be added by duplicating this section
email = "{{email}}"
Expand Down
2 changes: 1 addition & 1 deletion template/src/{{package_name}}/__init__.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if sys.version_info < (3, 8):
else:
from importlib.metadata import version # noqa

__version__ = version("{{package_name}}")
__version__ = version("{{pypi_name}}")
del version

__all__ = ["__version__"]
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ COPY --from=build /venv/ /venv/
ENV PATH=/venv/bin:$PATH

# change this entrypoint if it is not the same as the repo
ENTRYPOINT ["{{package_name}}"]
ENTRYPOINT ["{{repo_name}}"]
CMD ["--version"]
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ copybutton_prompt_is_regexp = True
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"
github_repo = {{repo_name}}
github_repo = "{{repo_name}}"
github_user = "{{github_org}}"
switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
switcher_exists = requests.get(switcher_json).ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ from github::
The library should now be installed and the commandline interface on your path.
You can check the version that has been installed by typing::

$ {{package_name}} --version
$ {{repo_name}} --version
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ The `Developer Guide`_ contains information on setting up a development
environment, running the tests and what standards the code and documentation
should follow.

.. _Developer Guide: {{docs_url}}/developer/how-to/contribute.html
.. _Developer Guide: {{docs_url}}/main/developer/how-to/contribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
install_options:
description: Parameters to pass to pip install
required: true
artifact_name:
description: A user friendly name to give the produced artifacts
required: true
python_version:
description: Python version to install
default: "3.x"
Expand All @@ -16,7 +19,7 @@ runs:

steps:
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}

Expand All @@ -36,9 +39,9 @@ runs:
shell: bash

- name: Upload lockfiles
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.0.0
with:
name: lockfiles
name: lockfiles-${{ inputs.python_version }}-${{ inputs.artifact_name }}-${{ github.sha }}
path: lockfiles

# This eliminates the class of problems where the requirements being given no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ updates:
directory: "/"
schedule:
interval: "weekly"

groups:
github-artifacts:
patterns:
- actions/*-artifact
- package-ecosystem: "pip"
directory: "/"
schedule:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
env:
# The target python version, which must match the Dockerfile version
CONTAINER_PYTHON: "3.11"
DIST_WHEEL_PATH: dist-${{ github.sha }}

jobs:
lint:
Expand All @@ -22,6 +23,7 @@ jobs:
with:
requirements_file: requirements-dev-3.x.txt
install_options: -e .[dev]
artifact_name: lint

- name: Lint
run: tox -e pre-commit,mypy
Expand Down Expand Up @@ -58,6 +60,7 @@ jobs:
python_version: ${{ matrix.python }}
requirements_file: requirements-test-${{ matrix.os }}-${{ matrix.python }}.txt
install_options: ${{ matrix.install }}
artifact_name: tests

- name: List dependency tree
run: pipdeptree
Expand Down Expand Up @@ -88,9 +91,9 @@ jobs:
pipx run build

- name: Upload sdist and wheel as artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.0.0
with:
name: dist
name: ${{ env.DIST_WHEEL_PATH }}
path: dist

- name: Check for packaging errors
Expand All @@ -102,6 +105,7 @@ jobs:
python_version: ${{env.CONTAINER_PYTHON}}
requirements_file: requirements.txt
install_options: dist/*.whl
artifact_name: dist

- name: Test module --version works using the installed wheel
# If more than one module in src/ replace with module name to test
Expand All @@ -126,10 +130,15 @@ jobs:
- name: Generate image repo name
run: echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV

- name: Set lockfile location in environment
run: |
echo "DIST_LOCKFILE_PATH=lockfiles-${{ env.CONTAINER_PYTHON }}-dist-${{ github.sha }}" >> $GITHUB_ENV

- name: Download wheel and lockfiles
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.0
with:
path: artifacts/
pattern: "*dist*"

- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
Expand All @@ -146,18 +155,18 @@ jobs:
- name: Build and export to Docker local cache
uses: docker/build-push-action@v5
with:
# Note build-args, context, file, and target must all match between this
# step and the later build-push-action, otherwise the second build-push-action
# will attempt to build the image again
# Note build-args, context, file, and target must all match between this
# step and the later build-push-action, otherwise the second build-push-action
# will attempt to build the image again
build-args: |
PIP_OPTIONS=-r lockfiles/requirements.txt dist/*.whl
PIP_OPTIONS=-r ${{ env.DIST_LOCKFILE_PATH }}/requirements.txt ${{ env.DIST_WHEEL_PATH }}/*.whl
context: artifacts/
file: ./Dockerfile
target: runtime
load: true
tags: ${{ env.TEST_TAG }}
# If you have a long docker build (2+ minutes), uncomment the
# following to turn on caching. For short build times this
# If you have a long docker build (2+ minutes), uncomment the
# following to turn on caching. For short build times this
# makes it a little slower
#cache-from: type=gha
#cache-to: type=gha,mode=max
Expand All @@ -180,14 +189,14 @@ jobs:
- name: Push cached image to container registry
if: github.ref_type == 'tag' # || github.ref_name == 'main'
uses: docker/build-push-action@v5
# This does not build the image again, it will find the image in the
# This does not build the image again, it will find the image in the
# Docker cache and publish it
with:
# Note build-args, context, file, and target must all match between this
# step and the previous build-push-action, otherwise this step will
# attempt to build the image again
# Note build-args, context, file, and target must all match between this
# step and the previous build-push-action, otherwise this step will
# attempt to build the image again
build-args: |
PIP_OPTIONS=-r lockfiles/requirements.txt dist/*.whl
PIP_OPTIONS=-r ${{ env.DIST_LOCKFILE_PATH }}/requirements.txt ${{ env.DIST_WHEEL_PATH }}/*.whl
context: artifacts/
file: ./Dockerfile
target: runtime
Expand All @@ -204,11 +213,15 @@ jobs:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}

steps:
- uses: actions/download-artifact@v3
- name: Download wheel and lockfiles
uses: actions/[email protected]
with:
path: artifacts/
pattern: "*dist*"

- name: Fixup blank lockfiles
# Github release artifacts can't be blank
run: for f in lockfiles/*; do [ -s $f ] || echo '# No requirements' >> $f; done
run: for f in ${{ env.DIST_LOCKFILE_PATH }}/*; do [ -s $f ] || echo '# No requirements' >> $f; done

- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
Expand All @@ -217,8 +230,8 @@ jobs:
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: |
dist/*
lockfiles/*
${{ env.DIST_WHEEL_PATH }}/*
${{ env.DIST_LOCKFILE_PATH }}/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
with:
requirements_file: requirements-dev-3.x.txt
install_options: -e .[dev]
artifact_name: docs

- name: Build docs
run: tox -e docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
requirements_file: requirements-dev-3.x.txt
install_options: -e .[dev]
artifact_name: link_check

- name: Check links
run: tox -e docs build -- -b linkcheck
Expand Down