Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4c8e27f
changed version list to list of strings
MichielTukker May 30, 2024
a10374e
changed version list to list of strings
MichielTukker May 30, 2024
3ae69ea
Merge branch 'bugfix/python3.10-in-gh-workflow' of https://github.com…
MichielTukker May 30, 2024
7258a65
Cookiecutter shouldn't prompt for user input
MichielTukker May 30, 2024
b86bf04
Fixed template error in github action, causing template instatntiatio…
MichielTukker May 30, 2024
9b6ff3e
missed one
MichielTukker May 30, 2024
d587c25
Allow pytest suite to be empty.
lfse-slafleur Jun 24, 2024
13095b2
Attempt to move .bat post hook to see if this fixes generation.
lfse-slafleur Jun 24, 2024
cb7672f
Remove spotty git-versioning config parameters.
lfse-slafleur Jun 25, 2024
e3ee2c6
Overwrite default python version with current version in github CI ma…
lfse-slafleur Jun 25, 2024
fb59336
Some debug stuff.
lfse-slafleur Jun 25, 2024
ebfe2e3
Use checked out cookiecutter instead of cloning it from remote.
lfse-slafleur Jun 25, 2024
be160b0
Add some debug stuff.
lfse-slafleur Jun 25, 2024
43b4485
Fix dir name of cookiecutter template output.
lfse-slafleur Jun 25, 2024
1ead206
Update template ci.yml with newest version.
lfse-slafleur Jun 25, 2024
208757e
Update ci.yaml.
lfse-slafleur Jun 25, 2024
252fe81
cd to cookiecutter template output when running commands on cookiecut…
lfse-slafleur Jun 25, 2024
00be244
Fix lint errors by adding newlines to init and main files.
lfse-slafleur Jun 25, 2024
cb7300d
Fix unit tests of template.
lfse-slafleur Jun 25, 2024
6c84fc4
Make type hinting in cookiecutter template python3.8 compatible.
lfse-slafleur Jun 25, 2024
f7c0761
Add missing import for optional.
lfse-slafleur Jun 25, 2024
c742407
Fail unit tests if empty.
lfse-slafleur Jun 25, 2024
a29f3e9
Use github username when deploying container image to GHCR instead of…
lfse-slafleur Dec 10, 2024
e72a76f
Merge branch 'main' into bugfix/python3.10-in-gh-workflow
lfse-slafleur Dec 10, 2024
bb15e37
Add in improvements from other repos.
lfse-slafleur Dec 10, 2024
72ef07f
More improvements from other repos
lfse-slafleur Dec 10, 2024
8941d01
Temp ls on test unit results.
lfse-slafleur Dec 10, 2024
511c79e
Switch over to bash for ci scripts instead of sh.
lfse-slafleur Dec 10, 2024
2acadf4
Drop python 3.8 in favor of 3.9 and turn off fail fast on github acti…
lfse-slafleur Dec 10, 2024
8c551f2
Fix fail fast location.
lfse-slafleur Dec 10, 2024
e276fb3
Update setuptools-git-versioning, add py.typed to package data and on…
lfse-slafleur Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/run_template_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ jobs:
build-lint-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.10, 3.11]
python-version: ['3.9', '3.10', '3.11']

name: Test cookiecutter template
steps:
Expand All @@ -22,16 +23,18 @@ jobs:
- name: Run cookiecutter
run: |
pip install cookiecutter
cookiecutter $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA
cd design_toolkit_application
sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json
cookiecutter --no-input ./
cd design-toolkit-application

- name: flake8 Lint
uses: TrueBrain/actions-flake8@v2
with:
plugins: Flake8-pyproject==1.2.3 flake8-docstrings==1.7.0 flake8-quotes==3.3.2 flake8-bugbear==23.9.16 flake8-mock==0.4 flake8-tuple==0.4.1
- name: Run lint
run: |
cd design-toolkit-application
./ci/linux/lint.sh

- name: Run unit tests
run: |
cd design-toolkit-application
./ci/linux/test_unit.sh

- name: Surface failing tests
Expand All @@ -41,7 +44,7 @@ jobs:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: test-results.xml
path: ./design-toolkit-application/test-results.xml

# Add a summary of the results at the top of the report
# Default: true
Expand All @@ -59,6 +62,7 @@ jobs:
- name: Add mypy annotator
uses: pr-annotators/[email protected]

- name: run typechecker
- name: Run typechecker
run: |
cd design-toolkit-application
./ci/linux/typecheck.sh
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"python_import_name": "{{ cookiecutter.repo_name|replace('-', '') }}",
"project_short_description": "A description on what this application within the Design Toolkit entails.",
"publish_container": true,
"docker_username": "audrey",
"github_username": "project-omotes",
"container_name": "design-toolkit-application",
"python_version": "3.11",
"_copy_without_render": [
Expand Down
File renamed without changes.
177 changes: 104 additions & 73 deletions {{cookiecutter.repo_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,110 +3,141 @@ name: Build-Test-Lint-etc (linux)
on: [push]

jobs:

flake8-lint:
setup:
runs-on: ubuntu-latest
name: Lint
strategy:
fail-fast: false
matrix:
python-version: ["{{cookiecutter.python_version}}"]
name: Setup
steps:
- name: Check out source repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python environment
# {% raw %}
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: {{cookiecutter.python_version}}
- name: flake8 Lint
uses: TrueBrain/actions-flake8@v2
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh
- name: 'Tar venv'
run: tar -cvf venv.tar ./.venv/
- name: Save venv
uses: actions/upload-artifact@v4
with:
plugins: Flake8-pyproject==1.2.3 flake8-docstrings==1.7.0 flake8-quotes==3.3.2 flake8-bugbear==23.9.16 flake8-mock==0.4 flake8-tuple==0.4.1
# only_warn: 1 #causes action to always be succesful, but still provide annotations
path: ./venv.tar
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
# {% endraw %}

test:
lint:
name: Lint
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: ["{{cookiecutter.python_version}}"]
# python-version: [3.8, 3.9, 3.10, 3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %}
uses: actions/setup-python@v4
with:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh

- name: run unit tests
run: |
./ci/linux/test_unit.sh
# {% raw %}
- uses: actions/checkout@v3
- name: Restore venv
uses: actions/download-artifact@v4
with:
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: Run lint
run: |
./ci/linux/lint.sh
# {% endraw %}

- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: test-results.xml
test:
name: Test
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: ["{{cookiecutter.python_version}}"]
steps:
# {% raw %}
- uses: actions/checkout@v3
- name: Restore venv
uses: actions/download-artifact@v4
with:
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: Run unit tests
run: |
./ci/linux/test_unit.sh
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: test-results.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true
# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX
# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
# {% endraw %}

typecheck:
name: Typecheck
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: ["{{cookiecutter.python_version}}"]
# python-version: [3.8, 3.9, 3.10, 3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %}
uses: actions/setup-python@v4
with:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh

- name: Add mypy annotator
uses: pr-annotators/[email protected]

- name: run typechecker
run: |
./ci/linux/typecheck.sh
# {% raw %}
- uses: actions/checkout@v3
- name: Restore venv
uses: actions/download-artifact@v4
with:
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: Add mypy annotator
uses: pr-annotators/[email protected]
- name: Run typechecker
run: |
./ci/linux/typecheck.sh
# {% endraw %}

build:
name: Build the python package
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: [ "{{cookiecutter.python_version}}" ]
steps:
# {% raw %}
- uses: actions/checkout@v3
- name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %}
uses: actions/setup-python@v4
- name: Restore venv
uses: actions/download-artifact@v4
with:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh

- name: build
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: Build
run: |
./ci/linux/build_python_package.sh
# {% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

{% raw %}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: {% raw %}${{ github.actor }}{% endraw %}
password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}

username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
{% endraw %}
- name: Build the container image
run: |
docker build . --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:${{github.ref_name}}
docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest
docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:${{github.ref_name}}
docker build . --tag ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %}
docker push ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:latest
docker push ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %}
{%- else -%}

{% endif %}
Expand Down
5 changes: 5 additions & 0 deletions {{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -a
source $1
set +a
8 changes: 6 additions & 2 deletions {{cookiecutter.repo_name}}/ci/linux/build_python_package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
python -m build
7 changes: 5 additions & 2 deletions {{cookiecutter.repo_name}}/ci/linux/create_venv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

python{{cookiecutter.python_version}} -m venv ./.venv
. .venv/bin/activate
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi
pip3 install pip-tools
8 changes: 6 additions & 2 deletions {{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
pip-sync ./dev-requirements.txt ./requirements.txt
10 changes: 7 additions & 3 deletions {{cookiecutter.repo_name}}/ci/linux/lint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

. .venv/bin/activate
flake8 ./src/{{cookiecutter.python_import_name}}
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

flake8 ./src/{{cookiecutter.python_import_name}} ./unit_test/
8 changes: 6 additions & 2 deletions {{cookiecutter.repo_name}}/ci/linux/test_unit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
PYTHONPATH='$PYTHONPATH:src/' pytest --junit-xml=test-results.xml unit_test/
8 changes: 6 additions & 2 deletions {{cookiecutter.repo_name}}/ci/linux/typecheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
python -m mypy ./src/{{cookiecutter.python_import_name}} ./unit_test/
12 changes: 8 additions & 4 deletions {{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

. .venv/bin/activate
pip-compile --output-file=requirements.txt pyproject.toml
pip-compile --extra=dev --output-file=dev-requirements.txt -c requirements.txt pyproject.toml
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

pip-compile --upgrade --output-file=requirements.txt pyproject.toml
pip-compile --upgrade --extra=dev -c requirements.txt --output-file=dev-requirements.txt pyproject.toml
Loading
Loading