Skip to content

Commit 1361bf9

Browse files
authored
Initial commit
0 parents  commit 1361bf9

30 files changed

+3356
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "template-python",
3+
// https://mcr.microsoft.com/en-us/product/devcontainers/python/tags
4+
"image": "mcr.microsoft.com/devcontainers/python:dev-3.13-bookworm",
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"ms-python.python",
9+
"charliermarsh.ruff",
10+
"GitHub.copilot-chat"
11+
]
12+
}
13+
},
14+
"postCreateCommand": "pipx install uv && make install-deps-dev",
15+
"remoteUser": "vscode"
16+
}

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.git
2+
.github
3+
.venv
4+
*.pyc
5+
*.env
6+
.coverage
7+
.devcontainer
8+
.gitignore
9+
.pre-commit-config.yaml
10+
.pytest_cache
11+
.ruff_cache
12+
__pycache__
13+
tests

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Project environment variables
2+
PROJECT_NAME=template-python

.github/dependabot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://docs.github.com/en/code-security/dependabot/ecosystems-supported-by-dependabot/supported-ecosystems-and-repositories#supported-ecosystems-and-repositories
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: "uv"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: azure-static-web-apps
2+
on:
3+
workflow_dispatch:
4+
# Uncomment the following lines to enable automatic deployment on push to main branch
5+
# push:
6+
# branches:
7+
# - main
8+
permissions:
9+
contents: write
10+
jobs:
11+
deploy:
12+
strategy:
13+
matrix:
14+
platform:
15+
- "ubuntu-latest"
16+
python-version:
17+
- "3.13"
18+
runs-on: ${{ matrix.platform }}
19+
timeout-minutes: 5
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up uv
23+
shell: bash
24+
run: pipx install uv
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Generate documentation
30+
shell: bash
31+
run: |
32+
make install-deps-docs
33+
make docs
34+
- name: Deploy
35+
uses: Azure/static-web-apps-deploy@v1
36+
with:
37+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
38+
repo_token: ${{ secrets.GITHUB_TOKEN }}
39+
action: "upload"
40+
app_location: "./site"
41+
skip_app_build: true
42+
skip_api_build: true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: docker-release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
jobs:
7+
release:
8+
runs-on: "ubuntu-latest"
9+
timeout-minutes: 5
10+
steps:
11+
- name: Check out the repo
12+
uses: actions/checkout@v4
13+
- name: Log in to Docker Hub
14+
uses: docker/login-action@v3
15+
with:
16+
username: ${{ secrets.DOCKERHUB_USERNAME }}
17+
password: ${{ secrets.DOCKERHUB_TOKEN }}
18+
# https://github.com/docker/build-push-action/issues/42#issuecomment-915323168
19+
- name: Set Versions
20+
uses: actions/github-script@v7
21+
id: set_version
22+
with:
23+
script: |
24+
const tag = context.ref.substring(10)
25+
const no_v = tag.replace('v', '')
26+
const dash_index = no_v.lastIndexOf('-')
27+
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
28+
core.setOutput('tag', tag)
29+
core.setOutput('no-v', no_v)
30+
core.setOutput('no-dash', no_dash)
31+
- name: Build and push tag ${{steps.set_version.outputs.no-dash}}
32+
uses: docker/build-push-action@v6
33+
with:
34+
context: .
35+
push: true
36+
build-args: |
37+
GIT_REVISION=${{ github.sha }}
38+
GIT_TAG=${{steps.set_version.outputs.no-dash}}
39+
tags: |
40+
${{ secrets.DOCKERHUB_USERNAME }}/template-python:${{steps.set_version.outputs.no-dash}}
41+
${{ secrets.DOCKERHUB_USERNAME }}/template-python:latest

.github/workflows/docker.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "feature/**"
8+
pull_request:
9+
branches:
10+
- "main"
11+
12+
jobs:
13+
docker:
14+
runs-on: "ubuntu-latest"
15+
timeout-minutes: 5
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # to retrieve git tags
20+
# How to set system path variable in github action workflow: https://stackoverflow.com/a/68214331
21+
- name: Add to PATH
22+
shell: bash
23+
run: |
24+
echo "/home/runner/bin" >> $GITHUB_PATH
25+
- name: Run CI tests for Docker
26+
shell: bash
27+
run: |
28+
make ci-test-docker TOOLS_DIR="/home/runner/bin"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: ghcr
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
env:
7+
IMAGE_NAME: template-python
8+
jobs:
9+
ghcr:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 5
12+
permissions:
13+
packages: write
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Set Versions
23+
uses: actions/github-script@v7
24+
id: set_version
25+
with:
26+
script: |
27+
const tag = context.ref.substring(10)
28+
const no_v = tag.replace('v', '')
29+
const dash_index = no_v.lastIndexOf('-')
30+
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
31+
core.setOutput('tag', tag)
32+
core.setOutput('no-v', no_v)
33+
core.setOutput('no-dash', no_dash)
34+
- name: Set meta data tag = ${{steps.set_version.outputs.no-dash}}
35+
uses: docker/metadata-action@v5
36+
id: meta
37+
with:
38+
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=semver,pattern={{version}},value=v${{steps.set_version.outputs.no-dash}}
41+
type=raw,value=latest
42+
- uses: docker/build-push-action@v6
43+
with:
44+
push: true
45+
context: .
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: github-pages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
permissions:
7+
contents: write
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Configure Git Credentials
14+
run: |
15+
git config user.name github-actions[bot]
16+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.x
20+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
21+
- uses: actions/cache@v4
22+
with:
23+
key: mkdocs-material-${{ env.cache_id }}
24+
path: .cache
25+
restore-keys: |
26+
mkdocs-material-
27+
- run: pip install mkdocs-material
28+
- run: mkdocs gh-deploy --force

.github/workflows/test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "feature/**"
8+
- "copilot/**"
9+
pull_request:
10+
branches:
11+
- "main"
12+
13+
jobs:
14+
test:
15+
strategy:
16+
matrix:
17+
platform:
18+
- "ubuntu-latest"
19+
python-version:
20+
- "3.13"
21+
runs-on: ${{ matrix.platform }}
22+
timeout-minutes: 5
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up uv
26+
shell: bash
27+
run: pipx install uv
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- name: Run CI tests
33+
shell: bash
34+
run: |
35+
make ci-test
36+
make ci-test-docs

0 commit comments

Comments
 (0)