Skip to content

Commit

Permalink
Add smoke test post deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
RMcVelia committed Dec 1, 2023
1 parent ab2d67c commit 15b2f53
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 40 deletions.
44 changes: 4 additions & 40 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,11 @@ runs:
TF_VAR_azure_sp_credentials: ${{ inputs.azure-credentials }}
CONFIRM_PRODUCTION: true

- name: Set up environment variables
shell: bash
run: |
case ${{ env.cluster }} in
test)
echo "cluster_rg=s189t01-tsc-ts-rg" >> $GITHUB_ENV
echo "cluster_name=s189t01-tsc-test-aks" >> $GITHUB_ENV
;;
production)
echo "cluster_rg=s189p01-tsc-pd-rg" >> $GITHUB_ENV
echo "cluster_name=s189p01-tsc-production-aks" >> $GITHUB_ENV
;;
*)
echo "unknown cluster"
;;
esac
- name: Install kubectl
uses: azure/setup-kubectl@v3
- name: Run Smoke Tests for ${{ inputs.environment }}
uses: ./.github/workflows/smoke-test.yml
with:
version: "v1.26.1" # default is latest stable

- name: K8 setup
shell: bash
run: |
az aks get-credentials -g ${{ env.cluster_rg }} -n ${{ env.cluster_name }}
make install-konduit
# review app seeded?
# - name: Generate example data
# shell: bash
# if: inputs.environment == 'review'
# run: kubectl exec -n ${{ env.namespace }} deployment/teacher-relocation-payment-${APP_NAME} -- /bin/sh -c "cd /app && bin/rails RAILS_ENV=test db:schema:load && bin/rails RAILS_ENV=test db:seed"

# - name: Run Smoke Tests for ${{ inputs.environment }}
# uses: ./.github/actions/smoke-test_v2/
# with:
# environment: ${{ inputs.environment }}
# app-env: ${{ env.aks_app_environment }}
# pr-number: ${{ inputs.pr-number }}
# slack-webhook: ${{ inputs.slack-webhook }}
environment: ${{ inputs.environment }}
url: ${{ steps.set_env_var.outputs.deploy_url }}

# - name: Notify Slack channel on job failure
# if: ${{ failure() && github.ref == 'refs/heads/main' }}
Expand Down
46 changes: 46 additions & 0 deletions .github/actions/smoke-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: smoke-test
description: runs smoke tests

inputs:
environment:
description: Environment to run tests in
required: true
url:
description: APP URL
required: true

runs:
using: composite
services:
postgres:
image: postgres:11-alpine
ports:
- '5432:5432'
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DATABASE_URL: 'postgres://rails:password@localhost:5432/rails_test'
GOVUK_NOTIFY_API_KEY: dummy
GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID: dummy

steps:
- name: Set up Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2

- name: Bundle smoke test gems
shell: bash
run: |
gem install bundler
echo 'gem "rspec"' >> Gemfile
bundle
- name: Run smoke tests
shell: bash
run: bin/smoke
env:
SMOKE_URL: ${{ inputs.url }}
66 changes: 66 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: smoke-test
description: runs smoke tests

on:
workflow_call:
inputs:
environment:
description: Environment to run tests in
required: true
url:
description: APP URL
required: true

jobs:
smoke-test:
runs_on: ubuntu-latest
services:
postgres:
image: postgres:11-alpine
ports:
- '5432:5432'
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
RAILS_ENV: test
DATABASE_URL: 'postgres://rails:password@localhost:5432/rails_test'
GOVUK_NOTIFY_API_KEY: dummy
GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID: dummy

steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '18.18.2'
# - name: Setup yarn
# run: npm install -g yarn
# - name: Install Node packages
# run: yarn install
- name: Set up Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
# - name: Precompile assets
# run: bundle exec rails assets:precompile
# - name: Set up database schema
# run: bin/rails db:schema:load
# - name: Copy env file
# run: cp .env.example .env


- name: Bundle smoke test gems
shell: bash
run: |
gem install bundler
echo 'gem "rspec"' >> Gemfile
bundle
- name: Run smoke tests
shell: bash
run: bin/smoke
env:
SMOKE_URL: ${{ inputs.url }}

0 comments on commit 15b2f53

Please sign in to comment.