Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS-4528: Build and Deploy to AWS Environments. #7

Merged
merged 11 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
_Add ticket reference to Pull Request title: e.g. 'FS-123: Add content', if there is no ticket prefix with BAU_


### Change description
_A brief description of the pull request_

- [ ] Unit tests and other appropriate tests added or updated
- [ ] README and other documentation has been updated / added (if needed)
- [ ] Commit messages are meaningful and follow good commit message guidelines (e.g. "FS-XXXX: Add margin to nav items preventing overlapping of logo")


### How to test
_If manual testing is needed, give suggested testing steps_


### Screenshots of UI changes (if applicable)
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
pull-request-branch-name:
separator: "-"
rebase-strategy: "auto"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
pull-request-branch-name:
separator: "-"
rebase-strategy: "auto"
75 changes: 75 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
paths-ignore:
- "**/README.md"
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths-ignore:
- "**/README.md"

schedule:
- cron: '44 9 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
161 changes: 161 additions & 0 deletions .github/workflows/copilot_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Deploy to AWS
run-name: AWS Deploy ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev') }}

on:
workflow_dispatch:
inputs:
environment:
description: Which AWS Account to use
type: choice
required: true
options:
- dev
- test
- uat
- prod
run_performance_tests:
required: false
default: false
type: boolean
description: Run performance tests
run_e2e_tests_assessment:
required: false
default: false
type: boolean
description: Run e2e tests (assessment)
run_e2e_tests_application:
required: false
default: true
type: boolean
description: Run e2e tests (application)
push:
# Ignore README markdown and the docs folder
# Only automatically deploy when something in the app or tests folder has changed
paths:
- '!**/README.md'
- '!docs/**'
- 'app/**'
- 'config/**'
- 'tests/**'
- 'requirements-dev.in'
- 'requirements-dev.txt'
- 'requirements.in'
- 'requirements.txt'
- '.github/workflows/copilot_deploy.yml'

jobs:
setup:
uses: communitiesuk/funding-service-design-workflows/.github/workflows/determine-jobs.yml@main
with:
environment: ${{ inputs.environment }}

pre_deploy_tests:
uses: communitiesuk/funding-service-design-workflows/.github/workflows/pre-deploy.yml@main
with:
postgres_unit_testing: true
db_name: fab_unit_test

paketo_build:
needs: [ setup ]
permissions:
packages: write
uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main
with:
version_to_build: sha-${{ github.sha }}
owner: ${{ github.repository_owner }}
application: funding-service-design-self-serve
assets_required: false

dev_deploy:
needs: [ pre_deploy_tests, paketo_build, setup ]
if: ${{ contains(fromJSON(needs.setup.outputs.jobs_to_run), 'dev') }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: dev
app_name: self-serve
version: sha-${{ github.sha }}

post_dev_deploy_tests:
needs: dev_deploy
concurrency:
group: 'fsd-preaward-dev'
cancel-in-progress: false
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || true }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || false }}
app_name: self-serve
environment: dev

test_deploy:
needs: [ dev_deploy, post_dev_deploy_tests, paketo_build, setup ]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: test
app_name: self-serve
version: sha-${{ github.sha }}

post_test_deploy_tests:
needs: test_deploy
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}}
concurrency:
group: 'fsd-preaward-test'
cancel-in-progress: false
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || false }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || true }}
app_name: self-serve
environment: test

uat_deploy:
needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, paketo_build, setup ]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: uat
app_name: self-serve
version: sha-${{ github.sha }}

post_uat_deploy_tests:
needs: uat_deploy
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}}
concurrency:
group: 'fsd-preaward-uat'
cancel-in-progress: false
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || false }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || true }}
app_name: self-serve
environment: uat

prod_deploy:
needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, uat_deploy, post_uat_deploy_tests, paketo_build, setup ]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'prod') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: prod
app_name: self-serve
version: sha-${{ github.sha }}
5 changes: 4 additions & 1 deletion config/envs/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from os import getenv

from fsd_utils import configclass

Expand All @@ -11,4 +12,6 @@ class UnitTestConfig(Config):
# Logging
FSD_LOG_LEVEL = logging.DEBUG

SQLALCHEMY_DATABASE_URI = "postgresql://postgres:password@fab-db:5432/fab_unit_test" # pragma: allowlist secret
SQLALCHEMY_DATABASE_URI = getenv(
"DATABASE_URL", "postgresql://postgres:[email protected]:5432/fab_unit_test" # pragma: allowlist secret
)
1 change: 1 addition & 0 deletions copilot/.workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application: pre-award
Loading