Skip to content

Commit de71049

Browse files
committed
Merge remote-tracking branch 'template/main'
2 parents e60a3db + d0f7682 commit de71049

13 files changed

Lines changed: 232 additions & 151 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Release Request"
2+
description: "Request a production deployment by specifying the chat function, changes, target branch, and version bump."
3+
title: "Release Request"
4+
labels:
5+
- release
6+
- deployment
7+
assignees: []
8+
body:
9+
- type: markdown
10+
attributes:
11+
value: |
12+
## How this works
13+
14+
1. **Fill in this form** (description of changes, branch, version bump). Do not submit yet.
15+
2. **Scroll to the bottom and open the *Production deploy* workflow link in a new tab** — it disappears after you submit this form, so you need it open beforehand.
16+
3. **Submit this issue** to record the release request and start the workflow.
17+
4. The workflow redeploys staging, then pauses on the **manual approval gate** — a Lambda Feedback admin reviews this issue and approves the run there.
18+
5. Once approved, a `vX.Y.Z` git tag and GitHub Release are created and the function is deployed to production.
19+
6. Once the release is live, post a comment on this issue with the URL of the new GitHub Release (e.g. `https://github.com/<org>/<repo>/releases/tag/vX.Y.Z`) and then close the issue. This helps us keep track of which releases correspond to which requests.
20+
21+
- type: textarea
22+
id: description_of_changes
23+
attributes:
24+
label: Description of changes
25+
description: "Summarize what is changing and why. Include links to PRs, issues, or changelogs."
26+
placeholder: |
27+
- What changed:
28+
- Why:
29+
- Related PRs/Issues: #123, #456
30+
render: markdown
31+
validations:
32+
required: true
33+
34+
- type: input
35+
id: branch_to_deploy
36+
attributes:
37+
label: Branch to deploy
38+
description: |
39+
Specify the branch to deploy.
40+
placeholder: "e.g., main"
41+
validations:
42+
required: true
43+
44+
- type: dropdown
45+
id: version-bump
46+
attributes:
47+
label: "🚀 What kind of update is this?"
48+
description: "Tell us how significant this change is. This helps us set the correct new version number."
49+
options:
50+
- "Patch: A small fix for a bug. It won't break anything for existing users. (e.g., 1.2.3 ➔ 1.2.4)"
51+
- "Minor: Adds a new feature, but doesn't change how existing ones work. A safe update. (e.g., 1.2.3 ➔ 1.3.0)"
52+
- "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)"
53+
default: 0
54+
validations:
55+
required: true
56+
57+
- type: markdown
58+
attributes:
59+
value: |
60+
---
61+
### ⚡ Click the Link Below to Run the Workflow
62+
63+
⚠️ Open the workflow page in a new tab before submitting the issue, because the link to the workflow run page will disappear after submission.
64+
65+
Clicking the link will take you to the Actions page. You will need to click the **"Run workflow"** button there to start the process.
66+
Select the same branch and version bump type you entered in this form, then click the green **"Run workflow"** button.
67+
68+
69+
## [➡️ Go to Workflow Run Page](../actions/workflows/production-deploy.yml)

.github/workflows/main.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
21+
jobs:
22+
deploy:
23+
name: Deploy to Lambda Feedback
24+
permissions:
25+
contents: write
26+
packages: write
27+
id-token: write
28+
uses: lambda-feedback/chat-function-workflows/.github/workflows/deploy.yml@main
29+
with:
30+
template-repository-name: "lambda-feedback/chat-function-boilerplate"
31+
environment: "production"
32+
version-bump: ${{ inputs.version-bump }}
33+
branch: ${{ inputs.branch }}
34+
deployed-environment-variables: '[\"OPENAI_API_KEY\",\"OPENAI_MODEL\",\"GOOGLE_AI_API_KEY\",\"GOOGLE_AI_MODEL\"]'
35+
secrets:
36+
aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }}
37+
aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET }}
38+
function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY }}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
name: Dev deployment of chatbot lambda function
1+
name: Deploy to Staging
22

33
on:
44
push:
5-
branches: [dev]
5+
branches: [main]
66
workflow_dispatch:
77

88
jobs:
99
test:
10-
name: Dev deployment of chatbot lambda function
10+
name: Test
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
actions: read
15+
checks: write
16+
pull-requests: write
1217
strategy:
1318
fail-fast: false
1419
matrix:
@@ -28,20 +33,10 @@ jobs:
2833
with:
2934
python-version: ${{ matrix.python-version }}
3035

31-
# - name: Load cached venv
32-
# id: dependencies-cache
33-
# uses: actions/cache@v3
34-
# with:
35-
# path: .venv
36-
# key: venv-${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}
37-
38-
- name: Create Venv if Cache not found
39-
# if: steps.dependencies-cache.outputs.cache-hit != 'true'
40-
run: |
41-
python -m venv .venv
36+
- name: Create Venv
37+
run: python -m venv .venv
4238

4339
- name: Install dependencies
44-
# if: steps.dependencies-cache.outputs.cache-hit != 'true'
4540
run: |
4641
pip install --upgrade pip
4742
pip install -r requirements.txt
@@ -61,28 +56,19 @@ jobs:
6156
path: ./reports/pytest.xml
6257
if-no-files-found: warn
6358

64-
build:
65-
name: Build Docker Image
66-
uses: lambda-feedback/chat-function-workflows/.github/workflows/gh_build.yml@main
67-
needs: test
68-
permissions:
69-
contents: read
70-
id-token: write
71-
packages: write
72-
7359
deploy:
7460
name: Deploy to Lambda Feedback
75-
uses: lambda-feedback/chat-function-workflows/.github/workflows/dev_deploy.yml@main
7661
needs: test
62+
permissions:
63+
contents: write
64+
packages: write
65+
id-token: write
66+
uses: lambda-feedback/chat-function-workflows/.github/workflows/deploy.yml@main
7767
with:
7868
template-repository-name: "lambda-feedback/chat-function-boilerplate"
79-
# allow for developer to specify the environment variables that are used by the deployed AWS Lambda. Default to mock then admin can update.
69+
environment: "staging"
8070
deployed-environment-variables: '[\"OPENAI_API_KEY\",\"OPENAI_MODEL\",\"GOOGLE_AI_API_KEY\",\"GOOGLE_AI_MODEL\"]'
81-
permissions:
82-
contents: read
83-
id-token: write
84-
packages: write
8571
secrets:
86-
aws-access-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }}
87-
aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}}
72+
aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }}
73+
aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET }}
8874
function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY }}

.github/workflows/test-lint.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test and Lint
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
name: Test
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
actions: read
13+
checks: write
14+
pull-requests: write
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ["3.13"]
19+
env:
20+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
21+
OPENAI_MODEL: ${{ vars.OPENAI_MODEL }}
22+
GOOGLE_AI_API_KEY: ${{ secrets.GOOGLE_AI_API_KEY }}
23+
GOOGLE_AI_MODEL: ${{ vars.GOOGLE_AI_MODEL }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
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: Create Venv
35+
run: python -m venv .venv
36+
37+
- name: Install dependencies
38+
run: |
39+
pip install --upgrade pip
40+
pip install -r requirements.txt
41+
pip install flake8
42+
43+
- name: Lint with flake8
44+
run: |
45+
# Fail on syntax errors / undefined names
46+
flake8 ./src ./index.py --count --select=E9,F63,F7,F82 --show-source --statistics
47+
# Style report (non-blocking)
48+
flake8 ./src ./index.py --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+
export PYTHONPATH=$PYTHONPATH:.
55+
pytest --junit-xml=./reports/pytest.xml --tb=auto -v
56+
57+
- name: Upload test results
58+
uses: actions/upload-artifact@v4
59+
if: always()
60+
with:
61+
name: test-results
62+
path: ./reports/pytest.xml
63+
if-no-files-found: warn

.github/workflows/test-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test Report
22

33
on:
44
workflow_run:
5-
workflows: ["Build, Test and Deploy"]
5+
workflows: ["Deploy to Staging", "Deploy to Production", "Test and Lint"]
66
types:
77
- completed
88

AGENTS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to AI agents when working with code in this reposito
44

55
## Project Overview
66

7-
This is a chat function connecting students to an AI educational chatbot that is integrated with the **Lambda-Feedback** educational platform. It deploys as an AWS Lambda function (containerized via Docker) that receives student chat messages with educational context and returns LLM-powered chatbot responses.
7+
This is a chat function connecting students to an AI educational chatbot that is integrated with the **Lambda-Feedback** educational platform. It deploys as an AWS Lambda function (containerized via Docker) that receives student chat messages with educational context and returns LLM-powered chatbot responses. Incoming requests follow the [muEd API](https://mued.org/) schema (`context`, `user`, `messages`).
88

99
## Commands
1010

@@ -25,7 +25,7 @@ docker run --env-file .env -p 8080:8080 llm_chat
2525
```bash
2626
curl -X POST http://localhost:8080/2015-03-31/functions/function/invocations \
2727
-H 'Content-Type: application/json' \
28-
-d '{"body":"{\"conversationId\": \"12345Test\", \"messages\": [{\"role\": \"USER\", \"content\": \"hi\"}], \"user\": {\"type\": \"LEARNER\"}}"}'
28+
-d '{"body":"{\"messages\": [{\"role\": \"USER\", \"content\": \"hi\"}]}"}'
2929
```
3030

3131
**Run a single test:**
@@ -83,6 +83,7 @@ The agent uses **two separate LLM instances** — `self.llm` for chat responses
8383

8484
## Deployment
8585

86-
- Pushing to `dev` branch triggers the dev deployment GitHub Actions workflow
87-
- Pushing to `main` triggers staging deployment, with manual approval required for production
86+
- Pull requests: `.github/workflows/test-lint.yml` runs pytest only
87+
- Pushing to `main`: `.github/workflows/staging-deploy.yml` runs tests then deploys to AWS staging via the shared `lambda-feedback/chat-function-workflows` reusable workflows
88+
- Production: `.github/workflows/production-deploy.yml` is `workflow_dispatch`-only with a `version-bump` input; redeploys staging, pauses on the `production-override` GitHub Environment for manual approval, then creates a `vX.Y.Z` tag + GitHub Release and deploys to prod
8889
- All environment variables (API keys, model names) are injected via GitHub Actions secrets/variables — do not hardcode them

0 commit comments

Comments
 (0)