Skip to content

Commit

Permalink
Platform migration testing (#915)
Browse files Browse the repository at this point in the history
- Azure shell and rails console access compatible with GPaas
- Frontend snags, deprecation warnings
- Editor workflow tweaks for CMS
- Workflows moving to Azure
- Changing review app env vars
- Dashboard export moving to Azure
  • Loading branch information
peterdavidhamilton authored Oct 25, 2023
1 parent c8886bb commit 61c354e
Show file tree
Hide file tree
Showing 38 changed files with 206 additions and 135 deletions.
7 changes: 4 additions & 3 deletions .docker-profile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
echo "Welcome to the EYFS Recovery Application"

export PATH=$PATH:/usr/local/bin:/usr/local/bundle/bin
export PATH=$PATH:/usr/local/bin:/usr/local/bundle/bin
export GEM_HOME=/usr/local/bundle
export BUNDLE_APP_CONFIG=/usr/local/bundle
export RAILS_ENV=production
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ CONTENTFUL_PREVIEW_TOKEN=
DISABLE_USER_ANSWER=true
# Opt-in end-to-end testing (inactive for review apps)
E2E=true

# Deployment environment
ENVIRONMENT=
9 changes: 7 additions & 2 deletions .github/workflows/azure-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
target: app
context: .
push: true
platforms: linux/amd64,linux/arm64
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Early Years Recovery Rails Application
build-args: |
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.sha }}
Expand Down Expand Up @@ -97,10 +99,13 @@ jobs:
--image ${{ env.DOCKER_IMAGE }}:${{ github.sha }} \
--cpu 1 \
--memory 2 \
--command-line "bundle exec que" \
--command-line "que" \
--restart-policy OnFailure \
--log-analytics-workspace ${{ secrets.AZURE_LOG_ANALYTICS_WORKSPACE }} \
--vnet ${{ secrets.AZURE_VNET }} \
--subnet ${{ secrets.AZURE_WORKER_APP_SUBNET }} \
--ip-address Private \
--environment-variables RAILS_ENV=${{ vars.WEBAPP_CONFIG_RAILS_ENV }} RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} RAILS_LOG_TO_STDOUT=${{ vars.WEBAPP_CONFIG_RAILS_LOG_TO_STDOUT }} GCS_CREDENTIALS=${{ secrets.GCS_CREDENTIALS }} GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }}
--environment-variables \
EDITOR=vi RAILS_ENV=production RAILS_LOG_TO_STDOUT=true \
GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} \
RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }} GCS_CREDENTIALS=${{ secrets.GCS_CREDENTIALS }}
7 changes: 5 additions & 2 deletions .github/workflows/azure-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ jobs:
--image ${{ env.DOCKER_IMAGE }}:${{ inputs.version || github.ref_name }} \
--cpu 1 \
--memory 2 \
--command-line "bundle exec que" \
--command-line "que" \
--restart-policy OnFailure \
--log-analytics-workspace ${{ secrets.AZURE_LOG_ANALYTICS_WORKSPACE }} \
--vnet ${{ secrets.AZURE_VNET }} \
--subnet ${{ secrets.AZURE_WORKER_APP_SUBNET }} \
--ip-address Private \
--environment-variables RAILS_ENV=${{ vars.WEBAPP_CONFIG_RAILS_ENV }} RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} RAILS_LOG_TO_STDOUT=${{ vars.WEBAPP_CONFIG_RAILS_LOG_TO_STDOUT }} GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }}
--environment-variables \
EDITOR=vi RAILS_ENV=production RAILS_LOG_TO_STDOUT=true \
GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} \
RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }} GCS_CREDENTIALS=${{ secrets.GCS_CREDENTIALS }}
2 changes: 1 addition & 1 deletion .github/workflows/azure-deploy-review-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
az postgres flexible-server db delete --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--server-name ${{ vars.RESOURCE_NAME_PREFIX }}-psqlfs \
--database-name ${{ env.PR_NUMBER }} \
--yes
--yes
16 changes: 9 additions & 7 deletions .github/workflows/azure-deploy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'App Deploy [Azure - REVIEW]'
on:
pull_request:
types:
- labeled
- labeled # uses 'review'
- synchronize
paths-ignore:
- '**/*.md'
Expand Down Expand Up @@ -35,7 +35,7 @@ env:

jobs:
build-and-deploy:
if: contains(github.event.pull_request.labels.*.name, 'deployed')
if: contains(github.event.pull_request.labels.*.name, 'review')
runs-on: ubuntu-latest
environment: development

Expand Down Expand Up @@ -64,13 +64,15 @@ jobs:
- name: Build and push dependencies
uses: docker/build-push-action@v5
with:
target: deps
context: .
build-args: BUILDKIT_INLINE_CACHE=1
push: true
build-args: |
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.event.pull_request.head.sha }}
cache-from: |
${{ env.DOCKER_IMAGE }}:deps
push: true
tags: ${{ env.DOCKER_IMAGE }}:deps
target: deps

- name: Build and push Docker image
uses: docker/build-push-action@v5
Expand Down Expand Up @@ -125,12 +127,12 @@ jobs:
az webapp config appsettings set --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ vars.REVIEWAPP_NAME }} \
--slot ${{ env.PR_NUMBER }} \
--slot-settings DOMAIN="https://${{ vars.REVIEWAPP_NAME }}-${{ env.PR_NUMBER }}.azurewebsites.net" \
--slot-settings DOMAIN="${{ vars.REVIEWAPP_NAME }}-${{ env.PR_NUMBER }}.azurewebsites.net" \
--output none
# Add URL to Pull Request
- name: Comment URL to PR
uses: mshick/add-pr-comment@v2
with:
message: https://${{ vars.REVIEWAPP_NAME }}-${{ env.PR_NUMBER }}.azurewebsites.net
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions .github/workflows/azure-deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ jobs:
--image ${{ env.DOCKER_IMAGE }}:${{ inputs.candidate || github.ref_name }} \
--cpu 1 \
--memory 2 \
--command-line "bundle exec que" \
--command-line "que" \
--restart-policy OnFailure \
--log-analytics-workspace ${{ secrets.AZURE_LOG_ANALYTICS_WORKSPACE }} \
--vnet ${{ secrets.AZURE_VNET }} \
--subnet ${{ secrets.AZURE_WORKER_APP_SUBNET }} \
--ip-address Private \
--environment-variables RAILS_ENV=${{ vars.WEBAPP_CONFIG_RAILS_ENV }} RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} RAILS_LOG_TO_STDOUT=${{ vars.WEBAPP_CONFIG_RAILS_LOG_TO_STDOUT }} GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }}
--environment-variables \
EDITOR=vi RAILS_ENV=production RAILS_LOG_TO_STDOUT=true \
GOOGLE_CLOUD_BUCKET=${{ vars.WEBAPP_CONFIG_GOOGLE_CLOUD_BUCKET }} \
RAILS_MASTER_KEY=${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }} DATABASE_URL=${{ secrets.WEBAPP_DATABASE_URL }} GCS_CREDENTIALS=${{ secrets.GCS_CREDENTIALS }}
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ jobs:
-
name: Compile assets
run: bundle exec rails assets:precompile
# -
# name: Validate content
# run: bundle exec rails eyfs:cms:validate
-
name: Run test suite
run: bundle exec rspec
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ jobs:
name: Build and push Docker image for dependencies
uses: docker/build-push-action@v5
with:
target: deps
context: .
build-args: BUILDKIT_INLINE_CACHE=1
push: true
build-args: |
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.event.pull_request.head.sha }}
cache-from: |
${{ env.REGISTRY }}:deps
push: true
tags: ${{ env.REGISTRY }}:deps
target: deps
-
name: Build and push Docker image
uses: docker/build-push-action@v5
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pa11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ on:
workflow_dispatch:
inputs:
workspace:
description: Deployment workspace to test against (staging, dev, pr-xxx)
description: Deployment workspace to test against (staging, dev, review-pr-xxx)
type: string
default: staging

jobs:
test:
runs-on: ubuntu-latest
environment: development
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
DOMAIN: ey-recovery-${{ inputs.workspace || 'dev' }}.london.cloudapps.digital
BOT_TOKEN: ${{ secrets.WEBAPP_CONFIG_BOT_TOKEN }}
DOMAIN: eyrecovery-${{ inputs.workspace || 'dev' }}.azurewebsites.net
steps:
-
name: Checkout Code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:
inputs:
workspace:
description: Deployment workspace to test against (dev, pr-xxx)
description: Deployment workspace to test against (dev, review-pr-xxx)
type: string
default: dev

Expand All @@ -24,7 +24,7 @@ on:
- completed

env:
BASE_URL: https://ey-recovery-${{ inputs.workspace || 'dev' }}.london.cloudapps.digital
BASE_URL: https://eyrecovery-${{ inputs.workspace || 'dev' }}.azurewebsites.net
USER_PASSWORD: ${{ secrets.USER_PASSWORD }}

jobs:
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ RUN bundle install --no-binstubs --retry=10 --jobs=4
# ------------------------------------------------------------------------------
FROM base AS app

LABEL org.opencontainers.image.source=https://github.com/DFE-Digital/early-years-foundation-recovery
LABEL org.opencontainers.image.description "Early Years Recovery Rails Application"

RUN apk add --no-cache --no-progress --no-check-certificate postgresql-dev yarn chromium
RUN echo "Welcome to the EYFS Recovery Application" > /etc/motd
RUN apk add --no-cache --no-progress --no-check-certificate postgresql-dev yarn chromium openssh
RUN echo "root:Docker!" | chpasswd && cd /etc/ssh/ && ssh-keygen -A

ENV GROVER_NO_SANDBOX true
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
Expand Down Expand Up @@ -77,6 +80,7 @@ COPY --from=deps /build/node_modules ${APP_HOME}/node_modules

RUN SECRET_KEY_BASE=x bundle exec rails assets:precompile

COPY sshd_config /etc/ssh/
COPY ./docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,6 @@ The status of GovUK notify can be checked here: <https://status.notifications.se
For more information the Notify team can be contacted here: <https://www.notifications.service.gov.uk/support>,
or in the UK Government digital slack workspace in the `#govuk-notify` channel.

---

## Content

Content designers can author text in markdown which is parsed using [govuk_markdown](https://github.com/DFE-Digital/govuk-markdown) which applies default frontend classes.

This service uses the following bespoke markup:

- Button links: `{button}[Continue](/path/to/page){/button}`
- External links: `{external}[Read more](https://example.com){/external}`
- User prompts:
```
{quote}
This is the quote
This is the citation
{/quote}
```

---

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Hero layout

#hero-layout {
.govuk-notification-banner {
margin-top: govuk-spacing(3);
margin-top: govuk-spacing(6);
margin-bottom: govuk-spacing(-4);
}
}
Expand Down
5 changes: 3 additions & 2 deletions app/assets/stylesheets/module-overview.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$icon-diameter: 36px;
$line-shift: calc(($icon-diameter + 1px) / 2);
$progress-bar-container-width: 81px;

.module-overview-section-break {
Expand Down Expand Up @@ -54,10 +55,10 @@ $progress-bar-container-width: 81px;
border-left: 1px solid govuk-colour('mid-grey');
position: relative;
z-index: 1;
right: 7.5px + ($icon-diameter + 1px)/2;
right: $line-shift + 7.5px;

@include govuk-media-query($from: tablet) {
right: 10px + ($icon-diameter + 1px)/2;
right: $line-shift + 10px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/learning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def module_progress

# @return [String]
def module_table
ModuleDebugDecorator.new(progress_service).markdown_table
ModuleDebugDecorator.new(progress_service).rows
end

# @return [PaginationDecorator]
Expand Down
43 changes: 20 additions & 23 deletions app/decorators/module_debug_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
# :nocov:
#
# Module structure and user activity in a tabular form
#
# :nocov:
class ModuleDebugDecorator < DelegateClass(ModuleProgress)
# @return [String]
def markdown_table
body = []
body << '|'
rows.each do |row|
row.each do |value|
body << value
body << '|'
end
body << "\n"
end
body << "\n"

body.join
# @return [Array<Array>]
def rows
[HEADERS, *columns]
end

private
Expand All @@ -38,25 +27,33 @@ def markdown_table
# @return [Array<Array>]
def columns
mod.content.each.with_index(1).map do |item, pos|
pagination = PaginationDecorator.new(item)
pagination = paginate(item)
[
pos.ordinalize,
visited?(item),
visited?(item).to_s,
pagination.section_numbers,
pagination.percentage,
item.submodule,
item.topic,
item.submodule.to_s,
item.topic.to_s,
pagination.page_numbers,
item.content_type.id,
item.page_type,
item.name,
link_to(item),
]
end
end

# @return [Array<Array>]
def rows
[HEADERS, *columns]
# @return [String]
# @param item [Training::Page, Training::Question, Training::Video]
def link_to(item)
path = Rails.application.routes.url_helpers.training_module_page_path(mod.name, item.name)
ApplicationController.helpers.link_to(item.name, path)
end

# @return [PaginationDecorator]
# @param item [Training::Page, Training::Question, Training::Video]
def paginate(item)
PaginationDecorator.new(item)
end
end
# :nocov:
28 changes: 14 additions & 14 deletions app/views/training/debug/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
pre.debug_dump
strong Module
br
= mod.name
'
h1.govuk-heading-l Module #{mod.position}

= mod.id
br
br

strong Questions
br
= mod.questions.count
br
br
dl
dt: strong Content
dd= mod.content.count
dt: strong Pages
dd= mod.text_pages.count
dt: strong Questions
dd= mod.questions.count
dt: strong Videos
dd= mod.video_pages.count

pre.debug_dump
.gem-c-govspeak
= m(module_table)

.light-grey-box
= govuk_table(rows: module_table, caption: mod.title)
3 changes: 3 additions & 0 deletions app/views/training/modules/_section_bar.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@

#progress-inactive
#progress-active style="width: #{section_bar.percentage}"

- if Rails.application.preview?
= govuk_link_to 'Edit in Contentful', "https://app.contentful.com/spaces/#{Rails.application.config.contentful_space}/environments/#{Rails.application.config.contentful_environment}/entries/#{content.id}"
Loading

0 comments on commit 61c354e

Please sign in to comment.