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

Test review apps #2747

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4ed3baf
Running new_service command and copying in config files
AbigailMcP May 8, 2024
df344ab
Tidy up generated files
AbigailMcP May 9, 2024
a5ae696
Comment out statuscake
AbigailMcP May 10, 2024
948e04d
Add startup command
AbigailMcP May 13, 2024
d0ebb9d
Pull image from docker hub
AbigailMcP May 13, 2024
2affc29
App config for review environment
AbigailMcP May 13, 2024
52be482
update seed file
AbigailMcP May 13, 2024
e9dfbfd
linting;
AbigailMcP May 13, 2024
f25519a
WIP: Use the PR tagged image for now
vacabor May 13, 2024
16a8c7d
Add a build action to build and push the container to GHCR
vacabor May 14, 2024
6e7e482
Set the right subscription
vacabor May 14, 2024
6447b20
Call review-aks rather than review
vacabor May 14, 2024
9ebf339
Call terraform-apply-aks
vacabor May 14, 2024
e473604
Use PR number and not event number
vacabor May 14, 2024
e61e37e
Change PR message, fix deployment name
vacabor May 14, 2024
a607a53
Correct comment URLs
vacabor May 14, 2024
127e22d
Align table header
vacabor May 14, 2024
6feebd3
Add delete-review-app workflow
AbigailMcP May 14, 2024
b18159a
Output APP_URL from build and use in PR comment
AbigailMcP May 14, 2024
67cd34d
Try to pull the APP_ULR from env again
AbigailMcP May 14, 2024
474e557
output raw url not json
AbigailMcP May 14, 2024
7ff5ed0
Update README
AbigailMcP May 14, 2024
eb4fc46
Update config for test env
AbigailMcP May 15, 2024
9309799
Echo correct URL in makefile
AbigailMcP May 15, 2024
8b6680a
dont suppress dfe analytics in review apps
AbigailMcP May 15, 2024
dc01c39
Bump selenium-webdriver from 4.19.0 to 4.20.1 (#2735)
dependabot[bot] May 15, 2024
acc1e23
Bump nokogiri from 1.16.2 to 1.16.5 (#2743)
dependabot[bot] May 15, 2024
bf6ea7e
Add dfe:analytics:check lint step to the CI workflow
vacabor May 15, 2024
025283b
Fix indentation
vacabor May 15, 2024
def6f3d
Update .github/workflows/build_and_deploy.yml
May 15, 2024
1f46832
Bump dotenv-rails from 3.1.0 to 3.1.2 (#2746)
dependabot[bot] May 15, 2024
45eb821
Merge branch 'master' into capt-1632-implement-review-apps
vacabor May 15, 2024
cae3f93
Require deploy tag to build, remove master branch condition
AbigailMcP May 16, 2024
306c5e8
test
AbigailMcP May 16, 2024
3f5f486
set review config from production
AbigailMcP May 16, 2024
7f0fb34
update env name and rails env
AbigailMcP May 16, 2024
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
44 changes: 44 additions & 0 deletions .github/actions/deploy-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy environment
description: Deploys an application environment

inputs:
environment:
description: The name of the environment
required: true
docker-image:
description: The Docker image to deploy
required: true
azure-credentials:
description: JSON object containing a service principal that can read from Azure Key Vault
required: true
pull-request-number:
description: The pull request number which triggered this deploy.
required: false

runs:
using: composite

steps:
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
terraform_wrapper: false

- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
with:
azure-credentials: ${{ inputs.azure-credentials }}

- name: Terraform Apply
shell: bash
run: |
make ci ${{ inputs.environment }} terraform-apply-aks
env:
DOCKER_IMAGE_TAG: ${{ inputs.docker-image }}
PR_NUMBER: ${{ inputs.pull-request-number }}

- name: Extract Terraform outputs
shell: bash
id: set_outputs
run: |
output=$(terraform -chdir=terraform/application output -raw url)
echo "APP_URL=$output" >> $GITHUB_ENV
76 changes: 76 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and deploy to AKS cluster

on:
pull_request:
types: [labeled, opened, reopened, synchronize]

concurrency: deploy-${{ github.ref }}

permissions:
packages: write
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
outputs:
docker-image-tag: ${{ steps.build-image.outputs.tag }}

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

- name: Build and push docker image
id: build-image
uses: DFE-Digital/github-actions/build-docker-image@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
context: .

deploy_review:
name: Deploy to review environment
concurrency: deploy_review_${{ github.event.pull_request.number }}
runs-on: ubuntu-latest
needs: [build]
environment:
name: review-aks

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

- uses: ./.github/actions/deploy-environment
id: deploy
with:
environment: review-aks
docker-image: ${{ needs.build.outputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
pull-request-number: ${{ github.event.pull_request.number }}

- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Seed review app
shell: bash
if: github.event.number != ''
run: |
make ci review-aks get-cluster-credentials
kubectl exec -n srtl-development deployment/claim-additional-payments-for-teaching-review-${{ github.event.pull_request.number }} -- sh -c "cd /app && bundle exec rake db:schema:load db:seed"
env:
PR_NUMBER: ${{ github.event.pull_request.number }}

- name: Post comment to Pull Request ${{ github.event.number }}
if: ${{ github.event_name == 'pull_request' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: aks
message: |
### Deployments

| Journey | URL |
| ------------------- | ------------------------------------ |
| Additional Payments | <${{ env.APP_URL }}/additional-payments/claim> |
| Student Loans | <${{ env.APP_URL }}/student-loans/claim> |
| Admin | <${{ env.APP_URL }}/admin> |
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ jobs:
- name: Linting - Standardrb
run: bin/rails standard

lint-dfe-analytics:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11-alpine
ports:
- '5432:5432'
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DFE_TEACHERS_PAYMENT_SERVICE_DATABASE_USERNAME: postgres
DFE_TEACHERS_PAYMENT_SERVICE_DATABASE_PASSWORD: password
DFE_TEACHERS_PAYMENT_SERVICE_DATABASE_HOST: localhost
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Prepare DB
run: bin/rails db:prepare
- name: Linting - DfE::Analytics
run: bin/rails dfe:analytics:check

test:
runs-on: ubuntu-latest
strategy:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/delete_review_app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Delete review app on AKS

on:
pull_request:
branches:
- master
types:
- closed

jobs:
delete-review-app:
name: Delete review app ${{ github.event.pull_request.number }}
concurrency: deploy_review_${{ github.event.pull_request.number }}
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
environment: review-aks
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
terraform_wrapper: false

- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Terraform destroy
run: |
make ci review-aks terraform-destroy-aks
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ coverage/
# Editor specific files
.vscode/
.rspec-local

.terraform
terraform/application/vendor
terraform/domains/environment_domains/vendor
terraform.tfstate*
bin/terrafile
bin/konduit.sh
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
terraform 1.2.4
terraform 1.6.4
ruby 3.2.0
nodejs 16.17.0
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ GEM
delayed_job (>= 3.0, < 5)
diff-lcs (1.5.1)
docile (1.4.0)
dotenv (3.1.0)
dotenv-rails (3.1.0)
dotenv (= 3.1.0)
dotenv (3.1.2)
dotenv-rails (3.1.2)
dotenv (= 3.1.2)
railties (>= 6.1)
erubi (1.12.0)
et-orbi (1.2.7)
Expand Down Expand Up @@ -218,7 +218,7 @@ GEM
html-attributes-utils (0.9.2)
activesupport (>= 6.1.4.4)
httpclient (2.8.3)
i18n (1.14.4)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
Expand Down Expand Up @@ -257,10 +257,10 @@ GEM
rack (>= 2.1.4.1)
marcel (1.0.3)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.22.2)
mini_portile2 (2.8.6)
minitest (5.22.3)
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.3.0)
Expand All @@ -275,10 +275,10 @@ GEM
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.2)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
notifications-ruby-client (5.4.0)
jwt (>= 1.5, < 3)
Expand Down Expand Up @@ -320,7 +320,7 @@ GEM
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.7.3)
rack (2.2.8.1)
rack (2.2.9)
rack-mini-profiler (3.3.1)
rack (>= 1.2.0)
rack-oauth2 (1.21.3)
Expand Down Expand Up @@ -369,7 +369,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.1.0)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -434,7 +434,7 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.19.0)
selenium-webdriver (4.20.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
Expand Down Expand Up @@ -523,7 +523,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.13)
zeitwerk (2.6.14)

PLATFORMS
ruby
Expand Down
Loading
Loading