Skip to content

Commit 755ad4c

Browse files
baijumclaude
andcommitted
ci: add caching, test reliability, deployment notifications, and workflow dedup
- Add .dockerignore to reduce Docker build context - Add pip caching and BuildKit cache mounts for faster builds - Make tests non-optional (must pass if they exist) - Split deploy.yml into test + deploy jobs - Add GitHub Deployment API integration - Simplify validate.yml to use reusable workflow from .github org repo Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ee6cc39 commit 755ad4c

4 files changed

Lines changed: 72 additions & 20 deletions

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.github
3+
.claude
4+
__pycache__
5+
*.pyc
6+
.pytest_cache
7+
.env
8+
.env.*
9+
docs/
10+
plans/
11+
*.md
12+
!requirements.txt

.github/workflows/deploy.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,47 @@ on:
55
branches: [main]
66

77
jobs:
8-
deploy:
8+
test:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
1212

1313
- uses: actions/setup-python@v5
1414
with:
1515
python-version: "3.12"
16+
cache: 'pip'
1617

1718
- name: Run tests
1819
run: |
1920
pip install -r requirements.txt
2021
pip install pytest
21-
pytest --tb=short || echo "No tests found, skipping"
22+
if python -m pytest --collect-only -q 2>/dev/null | grep -q "test"; then
23+
pytest --tb=short
24+
else
25+
echo "No tests found, skipping"
26+
fi
27+
28+
deploy:
29+
needs: test
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Create deployment
35+
id: deployment
36+
uses: actions/github-script@v7
37+
with:
38+
script: |
39+
const deployment = await github.rest.repos.createDeployment({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
ref: context.sha,
43+
environment: 'production',
44+
auto_merge: false,
45+
required_contexts: [],
46+
description: `Deploy ${context.sha.substring(0, 7)} to production`
47+
});
48+
return deployment.data.id;
2249
2350
- name: Deploy to server
2451
uses: appleboy/ssh-action@v1
@@ -79,3 +106,30 @@ jobs:
79106
}
80107
CADDYEOF
81108
docker compose -f /opt/platform/docker-compose.yml exec -T caddy caddy reload --config /etc/caddy/Caddyfile
109+
110+
- name: Update deployment status (success)
111+
if: success()
112+
uses: actions/github-script@v7
113+
with:
114+
script: |
115+
await github.rest.repos.createDeploymentStatus({
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
deployment_id: ${{ steps.deployment.outputs.result }},
119+
state: 'success',
120+
environment_url: `https://${{ secrets.APP_DOMAIN }}`,
121+
description: 'Deployment succeeded'
122+
});
123+
124+
- name: Update deployment status (failure)
125+
if: failure()
126+
uses: actions/github-script@v7
127+
with:
128+
script: |
129+
await github.rest.repos.createDeploymentStatus({
130+
owner: context.repo.owner,
131+
repo: context.repo.repo,
132+
deployment_id: ${{ steps.deployment.outputs.result }},
133+
state: 'failure',
134+
description: 'Deployment failed'
135+
});

.github/workflows/validate.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,4 @@ on:
66

77
jobs:
88
validate:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v4
12-
13-
- uses: actions/setup-python@v5
14-
with:
15-
python-version: "3.12"
16-
17-
- uses: actions/checkout@v4
18-
with:
19-
repository: towlion/platform
20-
path: _platform
21-
continue-on-error: true
22-
23-
- name: Run spec validator
24-
if: success()
25-
run: python _platform/validator/validate.py --tier 2 --dir .
9+
uses: towlion/.github/.github/workflows/validate.yml@main

app/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# syntax=docker/dockerfile:1
12
FROM python:3.11-slim AS base
23

34
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
45

56
WORKDIR /app
67

78
COPY requirements.txt .
8-
RUN pip install --no-cache-dir -r requirements.txt
9+
RUN --mount=type=cache,target=/root/.cache/pip \
10+
pip install -r requirements.txt
911

1012
COPY app/ ./app/
1113

0 commit comments

Comments
 (0)