Skip to content

Commit 9ea1dc4

Browse files
committed
Added private dirs
1 parent 8e6cdc9 commit 9ea1dc4

11 files changed

Lines changed: 486 additions & 0 deletions

.github/workflows/codeql.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: "0 8 * * 1" # Every Monday at 08:00 UTC
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ "python" ]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v3
32+
with:
33+
languages: ${{ matrix.language }}
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v3
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v3

.github/workflows/daily-build.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main] # Run on every commit to main
6+
schedule:
7+
- cron: "0 8 * * *" # Every day at 08:00 UTC
8+
workflow_dispatch: # Allow manual triggering from GitHub UI
9+
10+
jobs:
11+
daily-test:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.10", "3.11", "3.12", "3.13"]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -e ".[dev]"
32+
33+
- name: Run tests
34+
run: |
35+
pytest
36+
37+
docker-compose:
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 20
40+
env:
41+
COMPOSE_PROJECT_NAME: ci
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Seed demo config for container build
48+
run: |
49+
cp demo/settings/system.json deploy/docker/config/system.json
50+
cp demo/settings/system.json deploy/docker/config/system.json.template
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Build Docker image
56+
run: |
57+
docker compose build --progress plain
58+
59+
- name: Start stack
60+
run: |
61+
docker compose up -d
62+
63+
- name: Wait for API health
64+
run: |
65+
container_id="$(docker compose ps -q pypnm-api)"
66+
if [ -z "$container_id" ]; then
67+
echo "API container was not created"
68+
docker compose ps
69+
exit 1
70+
fi
71+
72+
for attempt in $(seq 1 30); do
73+
status="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$container_id")"
74+
if [ "$status" = "healthy" ]; then
75+
exit 0
76+
fi
77+
echo "Container not healthy yet (status: $status); waiting..."
78+
sleep 5
79+
done
80+
81+
echo "Container failed to become healthy"
82+
docker compose logs
83+
exit 1
84+
85+
- name: Tear down
86+
if: always()
87+
run: |
88+
docker compose down --volumes

.github/workflows/docs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.13"
26+
27+
- name: Install docs dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -r requirements-docs.txt
31+
32+
- name: Build site
33+
run: |
34+
mkdocs build --strict
35+
36+
- uses: actions/upload-pages-artifact@v3
37+
with:
38+
path: site
39+
40+
deploy:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
steps:
47+
- id: deployment
48+
uses: actions/deploy-pages@v4
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Kubernetes (kind)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
kind-smoke:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 25
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install kubectl
18+
run: |
19+
curl -fsSL https://dl.k8s.io/release/$(curl -fsSL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl -o /tmp/kubectl
20+
sudo install -m 0755 /tmp/kubectl /usr/local/bin/kubectl
21+
kubectl version --client=true
22+
23+
- name: Install kind
24+
run: |
25+
curl -fsSL https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 -o /tmp/kind
26+
sudo install -m 0755 /tmp/kind /usr/local/bin/kind
27+
kind version
28+
29+
- name: Create cluster
30+
run: |
31+
kind create cluster --name pypnm-dev
32+
kubectl get nodes
33+
34+
- name: Build image
35+
run: |
36+
docker build -t pypnm:local --build-arg PYTHON_VERSION=3.12 .
37+
38+
- name: Load image into kind
39+
run: |
40+
kind load docker-image pypnm:local --name pypnm-dev
41+
42+
- name: Apply manifests
43+
run: |
44+
kubectl apply -k deploy/kubernetes
45+
kubectl rollout status deploy/pypnm-api --timeout=120s
46+
47+
- name: Health check
48+
run: |
49+
kubectl port-forward deploy/pypnm-api 8000:8000 > /tmp/pf.log 2>&1 &
50+
PF_PID=$!
51+
sleep 3
52+
curl -fsS http://127.0.0.1:8000/health
53+
kill "$PF_PID"
54+
55+
- name: Dump logs on failure
56+
if: failure()
57+
run: |
58+
kubectl get pods -o wide
59+
kubectl describe pod -l app=pypnm-api
60+
kubectl logs -l app=pypnm-api --tail=200

.github/workflows/post-build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Post Build
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types: [completed]
7+
8+
jobs:
9+
downstream:
10+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -e ".[dev,docs]"
26+
27+
- name: Build docs (gated after Build)
28+
run: mkdocs build --strict

.github/workflows/publish-ghcr.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish PyPNM Image To GHCR
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Login to GHCR
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata (tags, labels)
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/${{ github.repository_owner }}/pypnm
34+
tags: |
35+
type=ref,event=tag
36+
type=raw,value=latest
37+
38+
- name: Build and push
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/publish-pypi.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish PyPNM To PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
tag-check:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
is_ga: ${{ steps.check.outputs.is_ga }}
16+
steps:
17+
- name: Validate GA tag
18+
id: check
19+
shell: bash
20+
run: |
21+
if [[ "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
22+
echo "is_ga=true" >> "${GITHUB_OUTPUT}"
23+
else
24+
echo "is_ga=false" >> "${GITHUB_OUTPUT}"
25+
fi
26+
27+
publish:
28+
needs: tag-check
29+
if: ${{ needs.tag-check.outputs.is_ga == 'true' }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.11"
39+
40+
- name: Build package
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install build
44+
python -m build
45+
46+
- name: Publish to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
with:
49+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)