Skip to content

Commit ccfc498

Browse files
authored
CI: create release workflow (#45)
2 parents 2174318 + 7a71e6f commit ccfc498

File tree

5 files changed

+150
-4
lines changed

5 files changed

+150
-4
lines changed

.env.sample

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ DJANGO_DB_RESET=true
88
DJANGO_STORAGE_DIR=.
99
DJANGO_DB_FILE=django.db
1010

11-
# Other Django config
12-
DJANGO_DEBUG=true
13-
1411
# uncomment to start the elasticstack services with compose
1512
# COMPOSE_PROFILES=elasticstack
1613

.github/lighthouserc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"ci": {
3+
"numberOfRuns": 3,
4+
"settings": {
5+
"preset": "desktop"
6+
},
7+
"assert": {
8+
"assertions": {
9+
"categories:accessibility": ["error", { "minScore": 1 }],
10+
"categories:best-practices": ["warn", { "minScore": 0.9 }]
11+
}
12+
}
13+
}
14+
}

.github/workflows/deploy.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
# pre-release tag
10+
- "202[4-9].[0-9][0-9].[0-9]+-rc[0-9]+"
11+
# release tags
12+
- "202[4-9].[0-9][0-9].[0-9]+"
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
tests-ui:
20+
uses: ./.github/workflows/tests-ui.yml
21+
if: github.ref_type == 'tag'
22+
23+
tests-pytest:
24+
uses: ./.github/workflows/tests-pytest.yml
25+
if: github.ref_type == 'tag'
26+
27+
deploy:
28+
runs-on: ubuntu-latest
29+
needs: [tests-ui, tests-pytest]
30+
if: (!cancelled())
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- uses: actions/setup-python@v5
37+
with:
38+
python-version-file: .github/workflows/.python-version
39+
cache: pip
40+
cache-dependency-path: "**/pyproject.toml"
41+
42+
- name: Write python packages to file
43+
run: |
44+
python -m venv .venv
45+
source .venv/bin/activate
46+
pip install pipdeptree
47+
pip install -e .
48+
pipdeptree
49+
pipdeptree >> pems/static/requirements.txt
50+
51+
- name: Write commit SHA to file
52+
run: echo "${{ github.sha }}" >> pems/static/sha.txt
53+
54+
- name: Write tag to file
55+
run: echo "${{ github.ref_name }}" >> pems/static/version.txt
56+
57+
- name: Docker Login to GitHub Container Registry
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Set up QEMU
65+
uses: docker/setup-qemu-action@v3
66+
67+
- name: Set up Docker Buildx
68+
id: buildx
69+
uses: docker/setup-buildx-action@v3
70+
71+
- name: Build, tag, and push image to GitHub Container Registry
72+
uses: docker/build-push-action@v6
73+
with:
74+
platforms: linux/amd64,linux/arm64
75+
builder: ${{ steps.buildx.outputs.name }}
76+
build-args: GIT-SHA=${{ github.sha }}
77+
cache-from: type=gha,scope=compilerla
78+
cache-to: type=gha,scope=compilerla,mode=max
79+
context: .
80+
file: appcontainer/Dockerfile
81+
push: true
82+
tags: |
83+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
84+
ghcr.io/${{ github.repository }}:${{ github.sha }}
85+
86+
release:
87+
needs: deploy
88+
if: ${{ github.ref_type == 'tag' && !contains(github.ref, '-rc') }}
89+
runs-on: ubuntu-latest
90+
permissions:
91+
# https://github.com/softprops/action-gh-release#permissions
92+
contents: write
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v4
97+
with:
98+
fetch-depth: 0
99+
100+
- name: Release
101+
uses: softprops/action-gh-release@v2
102+
with:
103+
prerelease: false
104+
generate_release_notes: true

.github/workflows/tests-ui.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: UI & a11y tests
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
branches: [main]
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
tests-ui:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v4
19+
20+
- name: Start app
21+
run: |
22+
cp .env.sample .env
23+
docker compose up --detach app
24+
25+
- name: Run Lighthouse tests for a11y
26+
uses: treosh/lighthouse-ci-action@12.1.0
27+
with:
28+
urls: http://localhost:8000/admin
29+
configPath: ".github/lighthouserc.json"
30+
temporaryPublicStorage: true
31+
uploadArtifacts: true

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
image: caltrans/pems:app
99
env_file: .env
1010
ports:
11-
- "8000"
11+
- "${DJANGO_LOCAL_PORT:-8000}:8000"
1212

1313
dev:
1414
build:

0 commit comments

Comments
 (0)