Skip to content

Commit 919726b

Browse files
feat: Add Terraform configuration for frontend (#22)
Co-authored-by: Kevin Boyer <kevinboyer@navapbc.com>
1 parent ddc9b87 commit 919726b

48 files changed

Lines changed: 1346 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cd-frontend.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy frontend
2+
# Need to set a default value for when the workflow is triggered from a git push
3+
# which bypasses the default configuration for inputs
4+
run-name: Deploy ${{inputs.version || 'main' }} to frontend ${{ inputs.environment || 'dev' }}
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
paths:
11+
- "frontend/**"
12+
- "bin/**"
13+
- "infra/**"
14+
workflow_dispatch:
15+
inputs:
16+
environment:
17+
description: Environment to deploy to
18+
required: true
19+
default: "dev"
20+
type: choice
21+
options:
22+
- dev
23+
- staging
24+
- prod
25+
version:
26+
required: true
27+
default: "main"
28+
description: Tag or branch or SHA to deploy
29+
30+
jobs:
31+
deploy:
32+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
33+
uses: ./.github/workflows/deploy.yml
34+
with:
35+
app_name: "frontend"
36+
environment: ${{ inputs.environment || 'dev' }}
37+
version: ${{ inputs.version || 'main' }}
38+
secrets: inherit
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI Infra Service Checks - frontend
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- infra/frontend/service/**
9+
- infra/modules/**
10+
- infra/test/**
11+
- .github/workflows/ci-frontend-infra-service.yml
12+
pull_request:
13+
paths:
14+
- infra/frontend/service/**
15+
- infra/modules/**
16+
- infra/test/**
17+
- .github/workflows/ci-frontend-infra-service.yml
18+
workflow_dispatch:
19+
inputs:
20+
version:
21+
required: true
22+
default: "main"
23+
description: Tag or branch or SHA to test
24+
25+
jobs:
26+
build-and-publish:
27+
name: Build
28+
uses: ./.github/workflows/build-and-publish.yml
29+
with:
30+
app_name: frontend
31+
ref: ${{ inputs.version || github.ref }}
32+
33+
infra-test-e2e:
34+
name: Test service
35+
runs-on: ubuntu-latest
36+
needs: [build-and-publish]
37+
38+
permissions:
39+
contents: read
40+
id-token: write
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
ref: ${{ inputs.version || github.ref }}
46+
47+
- name: Set up Terraform
48+
uses: ./.github/actions/setup-terraform
49+
50+
- uses: actions/setup-go@v5
51+
with:
52+
go-version-file: "infra/test/go.mod"
53+
54+
- name: Configure AWS credentials
55+
uses: ./.github/actions/configure-aws-credentials
56+
with:
57+
app_name: frontend
58+
# Run infra CI on dev environment
59+
environment: dev
60+
61+
- name: Run Terratest
62+
run: make infra-test-service APP_NAME=frontend
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI frontend PR Environment Checks
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
pr_number:
6+
required: true
7+
type: string
8+
commit_hash:
9+
required: true
10+
type: string
11+
pull_request:
12+
13+
jobs:
14+
update:
15+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
16+
uses: ./.github/workflows/pr-environment-checks.yml
17+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.state == 'open'
18+
with:
19+
app_name: "frontend"
20+
environment: "dev"
21+
pr_number: ${{ inputs.pr_number || github.event.number }}
22+
commit_hash: ${{ inputs.commit_hash || github.event.pull_request.head.sha }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI frontend PR Environment Destroy
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
pr_number:
6+
required: true
7+
type: string
8+
pull_request_target:
9+
types: [closed]
10+
11+
jobs:
12+
destroy:
13+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
14+
uses: ./.github/workflows/pr-environment-destroy.yml
15+
with:
16+
app_name: "frontend"
17+
environment: "dev"
18+
pr_number: ${{ inputs.pr_number || github.event.number }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI Vulnerability Scans - frontend
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- frontend/**
9+
- .grype.yml
10+
- .hadolint.yaml
11+
- .trivyignore
12+
- .github/workflows/vulnerability-scans.yml
13+
- .github/workflows/ci-frontend-vulnerability-scans.yml
14+
pull_request:
15+
paths:
16+
- frontend/**
17+
- .grype.yml
18+
- .hadolint.yaml
19+
- .trivyignore
20+
- .github/workflows/vulnerability-scans.yml
21+
- .github/workflows/ci-frontend-vulnerability-scans.yml
22+
23+
jobs:
24+
vulnerability-scans:
25+
name: Vulnerability Scans
26+
uses: ./.github/workflows/vulnerability-scans.yml
27+
with:
28+
app_name: "frontend"

.template-infra/app-frontend.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changes here will be overwritten by Copier
2+
_commit: v0.15.6
3+
_src_path: https://github.com/navapbc/template-infra
4+
app_has_dev_env_setup: true
5+
app_local_port: 3001
6+
app_name: frontend
7+
template: app

e2e/frontend/playwright.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import baseConfig from '../playwright.config';
2+
import { deepMerge } from '../lib/util';
3+
import { defineConfig } from '@playwright/test';
4+
5+
export default defineConfig(
6+
deepMerge(baseConfig, {
7+
use: {
8+
baseURL: baseConfig.use.baseURL || 'localhost:3001',
9+
},
10+
})
11+
);

e2e/frontend/tests/index.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Page, expect, test } from '@playwright/test';
2+
3+
import AxeBuilder from '@axe-core/playwright';
4+
5+
test.describe('Generic Webpage Tests', () => {
6+
test('should load the webpage successfully', async ({ page }) => {
7+
const response = await page.goto('/');
8+
const title = await page.title();
9+
expect(response!.status()).toBe(200);
10+
});
11+
12+
test('should take a screenshot of the webpage', async ({ page }) => {
13+
await page.goto('/');
14+
await page.screenshot({ path: 'example-screenshot.png', fullPage: true });
15+
});
16+
17+
// https://playwright.dev/docs/accessibility-testing
18+
test('should not have any automatically detectable accessibility issues', async ({ page }) => {
19+
await page.goto('/');
20+
const accessibilityScanResults = await new AxeBuilder({ page }).analyze();
21+
expect(accessibilityScanResults.violations).toEqual([]);
22+
});
23+
24+
// Example test of finding a an html element on the index/home page
25+
// test('should check for an element to be visible', async ({ page }) => {
26+
// await page.goto('/');
27+
// const element = page.locator('h1');
28+
// await expect(element).toBeVisible();
29+
// });
30+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data "external" "account_ids_by_name" {
2+
program = ["${path.module}/../../../bin/account-ids-by-name"]
3+
}
4+
5+
locals {
6+
image_repository_name = "${local.project_name}-${local.app_name}"
7+
image_repository_region = module.project_config.default_region
8+
image_repository_account_name = module.project_config.network_configs[local.shared_network_name].account_name
9+
image_repository_account_id = data.external.account_ids_by_name.result[local.image_repository_account_name]
10+
11+
build_repository_config = {
12+
name = local.image_repository_name
13+
region = local.image_repository_region
14+
network_name = local.shared_network_name
15+
account_name = local.image_repository_account_name
16+
account_id = local.image_repository_account_id
17+
repository_arn = "arn:aws:ecr:${local.image_repository_region}:${local.image_repository_account_id}:repository/${local.image_repository_name}"
18+
repository_url = "${local.image_repository_account_id}.dkr.ecr.${local.image_repository_region}.amazonaws.com/${local.image_repository_name}"
19+
}
20+
}

infra/frontend/app-config/dev.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module "dev_config" {
2+
source = "./env-config"
3+
project_name = local.project_name
4+
app_name = local.app_name
5+
default_region = module.project_config.default_region
6+
environment = "dev"
7+
network_name = "dev"
8+
domain_name = "app.referral-pilot-dev.navateam.com"
9+
enable_https = true
10+
has_database = local.has_database
11+
has_incident_management_service = local.has_incident_management_service
12+
enable_notifications = local.enable_notifications
13+
14+
# Enable and configure identity provider.
15+
enable_identity_provider = local.enable_identity_provider
16+
17+
# Support local development against the dev instance.
18+
extra_identity_provider_callback_urls = ["http://localhost"]
19+
extra_identity_provider_logout_urls = ["http://localhost"]
20+
21+
# Enables ECS Exec access for debugging or jump access.
22+
# See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html
23+
# Defaults to `false`. Uncomment the next line to enable.
24+
# enable_command_execution = true
25+
26+
# Uncomment to override default feature flag values
27+
# feature_flag_overrides = {
28+
# BAR = true
29+
# }
30+
}

0 commit comments

Comments
 (0)