Skip to content

Commit 02201d0

Browse files
authored
Added new staging/prod deployment workflow including database testing (#244)
* Added new staging/prod deployment workflow including database testing * Switched template repo name * Removed old workflows * Switched to use pip instead of poetry * Added Pull Request trigger * Fixed path for requirements.txt * Added pytest requirement * Added python version to test report * Refactored test file names to match pytest requirements * Removed Python 3.12 from CI/CD as Sympy has version issues * Changed to build file to point to the dockerfile * Added build file path to production * Added build context * Added build context to prod * Renamed run database tests * Enabled linting * Added flake8 installation step to staging workflow * Updated flake8 paths in staging workflow for app directory linting
1 parent 7372fa9 commit 02201d0

15 files changed

+197
-211
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
blank_issues_enabled: false
2+
contact_links: []
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Release Request"
2+
description: "Request a deployment by specifying the evaluation function, changes, target commit/branch, and test confirmation."
3+
title: "Release Request"
4+
labels:
5+
- release
6+
- deployment
7+
assignees: []
8+
body:
9+
- type: textarea
10+
id: description_of_changes
11+
attributes:
12+
label: Description of changes
13+
description: "Summarize what is changing and why. Include links to PRs, issues, or changelogs."
14+
placeholder: |
15+
- What changed:
16+
- Why:
17+
- Related PRs/Issues: #123, #456
18+
render: markdown
19+
validations:
20+
required: true
21+
22+
- type: input
23+
id: branch_to_deploy
24+
attributes:
25+
label: Branch to deploy
26+
description: |
27+
Specify Branch name to deploy.
28+
placeholder: "e.g., release/2025-09-29"
29+
validations:
30+
required: true
31+
32+
- type: dropdown
33+
id: version-bump
34+
attributes:
35+
label: "🚀 What kind of update is this?"
36+
description: "Tell us how significant this change is. This helps us set the correct new version number."
37+
options:
38+
- "Patch: A small fix for a bug. It won't break anything for existing users. (e.g., 1.2.3 ➔ 1.2.4)"
39+
- "Minor: Adds a new feature, but doesn't change how existing ones work. A safe update. (e.g., 1.2.3 ➔ 1.3.0)"
40+
- "Major: A big change that alters existing features. Users may need to update their work to adapt. (e.g., 1.2.3 ➔ 2.0.0)"
41+
default: 0
42+
validations:
43+
required: true
44+
45+
- type: markdown
46+
attributes:
47+
value: |
48+
---
49+
### ⚡ Click the Link Below to Run the Workflow
50+
51+
Clicking the link will take you to the Actions page. You will need to click the **"Run workflow"** button there to start the process.
52+
53+
## [➡️ Go to Workflow Run Page](../actions/workflows/production-deploy.yml)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy to Production
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version-bump:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: patch
15+
branch:
16+
description: 'Branch to release from'
17+
required: true
18+
type: string
19+
default: 'main'
20+
jobs:
21+
deploy:
22+
uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@deploy-request
23+
with:
24+
template-repository-name: 'lambda-feedback/evaluation-function-boilerplate-python'
25+
build-file: "app/Dockerfile"
26+
build-context: "./app"
27+
environment: "production"
28+
version-bump: ${{ inputs.version-bump }}
29+
branch: ${{ inputs.branch }}
30+
run-database-tests: true
31+
32+
secrets:
33+
aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }}
34+
aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}}
35+
function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY}}
36+
gcp_credentials: ${{ secrets.GCP_DEPLOY }}
37+
TEST_API_ENDPOINT: ${{ secrets.TEST_API_ENDPOINT }}
38+
DB_USER: ${{ secrets.DB_USER }}
39+
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
40+
DB_HOST: ${{ secrets.DB_HOST }}
41+
DB_PORT: ${{ secrets.DB_PORT }}
42+
DB_NAME: ${{ secrets.DB_NAME }}
43+
GCP_DB_CREDS: ${{ secrets.GCP_DB_CREDS }}
44+
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Deploy to Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
actions: read
19+
checks: write
20+
pull-requests: write
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
python-version: ["3.8"]
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Set up Python ${{ matrix.python-version }}
29+
id: python-setup
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m venv .venv
37+
.venv/bin/pip install pytest
38+
.venv/bin/pip install -r app/requirements.txt
39+
40+
41+
- name: Lint with flake8
42+
run: |
43+
source .venv/bin/activate
44+
.venv/bin/pip install flake8
45+
# stop the build if there are Python syntax errors or undefined names
46+
flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics
47+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
48+
flake8 ./app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
49+
50+
- name: Run tests
51+
if: always()
52+
run: |
53+
source .venv/bin/activate
54+
pytest --junit-xml=./reports/pytest.xml --tb=auto -v
55+
56+
- name: Upload test results
57+
uses: actions/upload-artifact@v4
58+
if: always()
59+
with:
60+
name: test-results-${{ matrix.python-version }}
61+
path: ./reports/pytest.xml
62+
if-no-files-found: warn
63+
deploy:
64+
needs: test
65+
uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@deploy-request
66+
with:
67+
template-repository-name: "lambda-feedback/evaluation-function-boilerplate-python"
68+
build-file: "app/Dockerfile"
69+
build-context: "./app"
70+
build-platforms: "aws"
71+
environment: "staging"
72+
lfs: false
73+
secrets:
74+
aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }}
75+
aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}}
76+
function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY}}
77+
gcp_credentials: ${{ secrets.GCP_DEPLOY }}

.github/workflows/test-and-deploy.yml

Lines changed: 0 additions & 194 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ For more information, look at the docs [here](https://lambda-feedback.github.io/
66

77
This version is specifically for python, however the ultimate goal is to make similar boilerplate repositories in any language, allowing tutors the freedom to code in what they feel most comfortable with.
88

9+
## Deployment
10+
[![Create Release Request](https://img.shields.io/badge/Create%20Release%20Request-blue?style=for-the-badge)](https://github.com/lambda-feedback/compareExpressions/issues/new?template=release-request.yml)
11+
12+
913
### Getting Started
1014

1115
1. Clone this repository

0 commit comments

Comments
 (0)