Skip to content

Commit f93c544

Browse files
update all workflows
1 parent a6e3858 commit f93c544

File tree

14 files changed

+481
-0
lines changed

14 files changed

+481
-0
lines changed

.github/release-drafter.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name-template: "$RESOLVED_VERSION"
3+
tag-template: "$RESOLVED_VERSION"
4+
template: |
5+
# Changelog
6+
7+
$CHANGES
8+
9+
---
10+
11+
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release.
12+
13+
categories:
14+
- title: ":warning: Breaking Changes"
15+
labels:
16+
- "major"
17+
- title: "🚀 Features"
18+
labels:
19+
- "minor"
20+
- title: "🔧 Fixes"
21+
collapse-after: 3
22+
labels:
23+
- "patch"
24+
25+
autolabeler:
26+
- label: "major"
27+
branch:
28+
- '/(patch|bug|fix|feature)!\/.+/'
29+
- label: "minor"
30+
branch:
31+
- '/feature\/.+/'
32+
- label: "patch"
33+
branch:
34+
- '/(patch|bug|fix)\/.+/'
35+
36+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
37+
38+
version-resolver:
39+
major:
40+
labels:
41+
- "major"
42+
minor:
43+
labels:
44+
- "minor"
45+
patch:
46+
labels:
47+
- "patch"
48+
default: patch

.github/workflows/draft-release.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Draft Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
draft-release:
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5
19+
with:
20+
commitish: main
21+
disable-autolabeler: true
22+
latest: true
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Label Pull Request
2+
3+
on:
4+
pull_request:
5+
# Only following types are handled by the action, but one can default to all as well
6+
types: [opened, reopened, synchronize]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
configure-labels:
13+
permissions:
14+
issues: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f
18+
- name: Configure missing labels
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
gh label ls --json name > labels.json
23+
jq -e 'if map(select(.name | contains ("patch"))) == [] then null else "Label patch exists" end' labels.json || gh label create patch --color "006b75"
24+
jq -e 'if map(select(.name | contains ("minor"))) == [] then null else "Label minor exists" end' labels.json || gh label create minor --color "fbca04"
25+
jq -e 'if map(select(.name | contains ("major"))) == [] then null else "Label major exists" end' labels.json || gh label create major --color "b60205"
26+
label-pr:
27+
permissions:
28+
contents: read
29+
pull-requests: write
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5
33+
with:
34+
config-name: release-drafter.yaml
35+
disable-autolabeler: false
36+
disable-releaser: true
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/python-tests.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python Tests
5+
6+
on:
7+
push:
8+
branches-ignore: [ "main" ]
9+
pull_request:
10+
branches: [ "**" ]
11+
12+
permissions:
13+
contents: write
14+
checks: write
15+
pull-requests: write
16+
17+
jobs:
18+
run-tests:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
# Adjust the matrix to test against different or multiple versions.
23+
# Note that adding more versions will result in a code coverage report
24+
# for each version; you may wish to adjust that step's behavior.
25+
python-version: ["3.13"]
26+
steps:
27+
- uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: astral-sh/setup-uv@252c9954247a3257f40af94d0d836d0ffb58f808
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- name: Ruff check
33+
run: |
34+
uvx ruff check
35+
- name: Install dependencies
36+
run: |
37+
uv sync
38+
- name: Test with pytest
39+
run: |
40+
uv run pytest
41+
- name: Report coverage
42+
uses: MishaKav/pytest-coverage-comment@13d3c18e21895566c746187c9ea74736372e5e91
43+
with:
44+
pytest-xml-coverage-path: ./htmlcov/coverage.xml
45+
title: Coverage report for Python ${{ matrix.python-version }}
46+
remove-link-from-badge: true
47+
unique-id-for-comment: ${{ matrix.python-version }}
48+
coverage-path-prefix: src/

.github/workflows/release-published.yml

Whitespace-only changes.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Deploy Environment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tf_version:
7+
description: 'Version of Terraform to utilize'
8+
required: true
9+
default: '1.5.5'
10+
type: string
11+
tg_version:
12+
description: 'Version of Terragrunt to utilize'
13+
required: true
14+
default: '0.54.11'
15+
type: string
16+
environment:
17+
description: 'Environment (subfolder of platform, e.g. sandbox) to deploy'
18+
required: true
19+
type: string
20+
region:
21+
description: 'Region within the environment (e.g. us-east-1) to deploy'
22+
required: true
23+
type: string
24+
env_id:
25+
description: 'Instance within the region (e.g. 000) to deploy.'
26+
required: true
27+
type: string
28+
29+
permissions:
30+
id-token: write
31+
contents: read
32+
33+
jobs:
34+
deploy:
35+
name: "Plan & Deploy ${{ inputs.environment }}/${{ inputs.region }}/${{ inputs.env_id }}"
36+
runs-on: ubuntu-latest
37+
environment: ${{ inputs.environment }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f
41+
42+
- name: "Validate GitHub Environment"
43+
run: |
44+
raised=0
45+
test -z "${{ vars.DEPLOY_ROLE_ARN }}" && (echo "::error title=Repository Configuration Incomplete::This repository is missing an environment variable for DEPLOY_ROLE_ARN in the ${{ inputs.environment }} environment!"; raised=1)
46+
exit $raised
47+
48+
- name: Configure AWS credentials
49+
uses: aws-actions/configure-aws-credentials@a95656fcd9ec16a226c7099657b9fc91cc777601
50+
with:
51+
role-to-assume: ${{ vars.DEPLOY_ROLE_ARN }}
52+
role-session-name: ${{ github.run_id }}
53+
aws-region: ${{ inputs.region }}
54+
55+
- name: Plan
56+
id: plan
57+
uses: gruntwork-io/terragrunt-action@aee21a7df999be8b471c2a8564c6cd853cb674e1
58+
env:
59+
AWS_REGION: ${{ inputs.region }}
60+
INPUT_PRE_EXEC_0: |
61+
sudo apt update -yqq && sudo apt install python3 -yqq
62+
with:
63+
tf_version: ${{ inputs.tf_version }}
64+
tg_version: ${{ inputs.tg_version }}
65+
tg_dir: 'platform/${{ inputs.environment }}/${{ inputs.region }}/${{ inputs.env_id }}'
66+
tg_command: 'plan -out=${{ inputs.environment }}-${{ inputs.region }}-${{ inputs.env_id }}.tfplan'
67+
68+
- name: Deploy
69+
uses: gruntwork-io/terragrunt-action@aee21a7df999be8b471c2a8564c6cd853cb674e1
70+
env:
71+
AWS_REGION: ${{ inputs.region }}
72+
TERRAFORM_PLAN: ${{ steps.plan.outputs.TERRAFORM_PLAN }}
73+
INPUT_PRE_EXEC_0: |
74+
sudo apt update -yqq && sudo apt install python3 -yqq
75+
with:
76+
tf_version: ${{ inputs.tf_version }}
77+
tg_version: ${{ inputs.tg_version }}
78+
tg_dir: 'platform/${{ inputs.environment }}/${{ inputs.region }}/${{ inputs.env_id }}'
79+
tg_command: 'apply ${{ inputs.environment }}-${{ inputs.region }}-${{ inputs.env_id }}.tfplan'
80+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
**/provider.tf
33
.terragrunt-cache
44
.terraform
5+
.venv
6+
__pycache__
7+
.pytest_cache
8+
.coverage

README.md

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create_package = true
2+
create = true
3+
handler = "app.alternate_lambda_handler"
4+
cors = { allow_origins = ["*"] }
5+
source_path = "../../../../../../../src/function/"
6+
name = "platform-sample-lambda-function-2"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include "root" {
2+
path = find_in_parent_folders()
3+
}
4+
5+
terraform {
6+
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-lambda_function//.?ref=1.0.3"
7+
}

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[project]
2+
name = "python-platform-sample-lambda-function"
3+
version = "0.0.0"
4+
description = "A sample Lambda function for demonstrating workflows"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = [
11+
"pytest>=8.4.0",
12+
"pytest-cov>=6.2.1",
13+
"ruff>=0.11.13",
14+
]
15+
16+
[tool.pytest.ini_options]
17+
pythonpath = "src"
18+
minversion = "8.0"
19+
addopts = "-s -ra --cov=src --cov-fail-under=80 --cov-report term --cov-report html --cov-report xml:htmlcov/coverage.xml"
20+
testpaths = [
21+
"test"
22+
]
23+
24+
[tool.coverage.report]
25+
skip_empty = true
26+
27+
[tool.ruff]
28+
exclude = [
29+
".bzr",
30+
".direnv",
31+
".eggs",
32+
".git",
33+
".git-rewrite",
34+
".hg",
35+
".ipynb_checkpoints",
36+
".mypy_cache",
37+
".nox",
38+
".pants.d",
39+
".pyenv",
40+
".pytest_cache",
41+
".pytype",
42+
".ruff_cache",
43+
".svn",
44+
".tox",
45+
".venv",
46+
".vscode",
47+
"__pypackages__",
48+
"_build",
49+
"buck-out",
50+
"build",
51+
"dist",
52+
"node_modules",
53+
"site-packages",
54+
".venv",
55+
]

src/function/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
def lambda_handler(event, context):
22
return {"statusCode": 200, "body": "Hello from a sample Python Lambda!"}
3+
4+
5+
def alternate_lambda_handler(event, context):
6+
return {"statusCode": 200, "body": "Hello from a different sample Python Lambda!"}

test/unit/test_app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from function import app
2+
3+
4+
def test_primary_handler():
5+
result = app.lambda_handler(None, None)
6+
assert result["statusCode"] == 200
7+
assert result["body"] == "Hello from a sample Python Lambda!"
8+
9+
10+
def test_alternate_handler():
11+
result = app.alternate_lambda_handler(None, None)
12+
assert result["statusCode"] == 200
13+
assert result["body"] == "Hello from a different sample Python Lambda!"

0 commit comments

Comments
 (0)