Skip to content

Commit e57be64

Browse files
committed
feat: create the release workflow
- pushing a calver formatted tag kicks off a release - run tests, build app container image, push to GHCR - for a release tag, make a GitHub release
1 parent c556975 commit e57be64

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

.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": "mobile"
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: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
# pre-release tag
10+
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
11+
# release tags
12+
- "202[3-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: Docker Login to GitHub Container Registry
55+
uses: docker/login-action@v3
56+
with:
57+
registry: ghcr.io
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Set up QEMU
62+
uses: docker/setup-qemu-action@v3
63+
64+
- name: Set up Docker Buildx
65+
id: buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Build, tag, and push image to GitHub Container Registry
69+
uses: docker/build-push-action@v6
70+
with:
71+
platforms: linux/amd64,linux/arm64
72+
builder: ${{ steps.buildx.outputs.name }}
73+
build-args: GIT-SHA=${{ github.sha }}
74+
cache-from: type=gha,scope=compilerla
75+
cache-to: type=gha,scope=compilerla,mode=max
76+
context: .
77+
file: appcontainer/Dockerfile
78+
push: true
79+
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
80+
81+
release:
82+
needs: deploy
83+
if: ${{ github.ref_type == 'tag' && !contains(github.ref, '-rc') }}
84+
runs-on: ubuntu-latest
85+
permissions:
86+
# https://github.com/softprops/action-gh-release#permissions
87+
contents: write
88+
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
with:
93+
fetch-depth: 0
94+
95+
- name: Release
96+
uses: softprops/action-gh-release@v2
97+
with:
98+
prerelease: false
99+
generate_release_notes: true

.github/workflows/tests-ui.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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: |
29+
http://localhost:8000
30+
http://localhost:8000/help
31+
configPath: ".github/lighthouserc.json"
32+
temporaryPublicStorage: true
33+
uploadArtifacts: true

0 commit comments

Comments
 (0)