Skip to content

Commit

Permalink
Merge pull request #578 from Crown-Commercial-Service/release-2.0.0
Browse files Browse the repository at this point in the history
STAGING - Release 2.0.0
  • Loading branch information
tim-s-ccs authored Nov 13, 2023
2 parents 7ab0a0d + f6159e6 commit 9dc6c35
Show file tree
Hide file tree
Showing 79 changed files with 2,259 additions and 1,175 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/deploy_to_gpaas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Deploy latest code to GPaaS"

on:
workflow_call:
inputs:
environment:
description: 'The name of the environment we are deploying to'
required: true
type: string
secrets:
CF_API:
description: 'The GPaaS API'
required: true
CF_USERNAME:
description: 'The GPaaS Username'
required: true
CF_PASSWORD:
description: 'The GPaaS Password'
required: true
CF_ORG:
description: 'The org to deploy to'
required: true

concurrency:
group: deploy-${{ inputs.environment }}

jobs:
run-unit-tests:
uses: ./.github/workflows/rubyonrails.yml

run-docker-tests:
uses: ./.github/workflows/docker-image.yml

deploy-to-application:
runs-on: ubuntu-latest
needs:
- run-unit-tests
- run-docker-tests
environment:
name: ${{ inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Deploy to GPaaS
uses: citizen-of-planet-earth/cf-cli-action@master
with:
cf_api: ${{ secrets.CF_API }}
cf_username: ${{ secrets.CF_USERNAME }}
cf_password: ${{ secrets.CF_PASSWORD }}
cf_org: ${{ secrets.CF_ORG }}
cf_space: ${{ inputs.environment }}
command: push -f config/manifests/${{ inputs.environment }}.yml --strategy rolling
18 changes: 18 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Docker Image CI

on:
workflow_call:

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build
uses: docker/build-push-action@v5
23 changes: 14 additions & 9 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name: "Ruby on Rails CI"

on:
push:
branches-ignore:
- develop
- staging
- main
pull_request:
workflow_call:
inputs:
publish_test_report:
description: 'A trigger to publish the test report'
default: false
required: false
type: boolean
secrets:
cc_test_reporter_id:
description: 'The code climate test report ID'
required: false

jobs:
unit-test:
Expand All @@ -25,14 +30,14 @@ jobs:
env:
RAILS_ENV: test
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test"
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_ID: ${{ secrets.cc_test_reporter_id }}

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

- name: Install Ruby and gems
uses: ruby/setup-ruby@v1.154.0
uses: ruby/setup-ruby@v1.159.0
with:
bundler-cache: true

Expand All @@ -49,4 +54,4 @@ jobs:
uses: paambaati/[email protected]
with:
debug: true
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'develop' }}
if: ${{ inputs.publish_test_report }}
55 changes: 55 additions & 0 deletions .github/workflows/setup_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Set up deployment of latest code to GPaaS"

on:
push:
branches:
- develop
- staging
- main

jobs:
determine-environment:
runs-on: ubuntu-latest
outputs:
ENV_NAME: ${{ steps.determine_environment.outputs.ENV_NAME }}
steps:
- name: Determine the environment to deploy to
id: determine_environment
run: |
echo "ENV_NAME=$(
case ${{ github.ref }} in
"refs/heads/develop")
echo "development"
;;
"refs/heads/staging")
echo "pre-production"
;;
"refs/heads/main")
echo "production"
;;
*)
echo "FAIL"
;;
esac
)" >> $GITHUB_OUTPUT
- name: Fail if not an environment
run: |
echo "ERROR: No environment found"
exit 1
if: steps.determine_environment.outputs.ENV_NAME == 'FAIL'

- name: Show where we are deploying to
run: echo "We will deploy to ${{ steps.determine_environment.outputs.ENV_NAME }}"

deploy-to-gpaas:
uses: ./.github/workflows/deploy_to_gpaas.yml
needs:
- determine-environment
with:
environment: ${{ needs.determine-environment.outputs.ENV_NAME }}
secrets:
CF_API: ${{ secrets.CF_API }}
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Run our tests"

on:
push:
branches-ignore:
- develop
- staging
- main
pull_request:

jobs:
run-unit-tests:
uses: ./.github/workflows/rubyonrails.yml
with:
publish_test_report: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'develop' }}
secrets:
cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}

run-docker-build:
uses: ./.github/workflows/docker-image.yml
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.2.2
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

47 changes: 36 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
FROM ruby:3.2.1

# Pass in nodejs version
ARG NODE_VERSION=20.0.0

# Pull in the nodejs image
FROM node:${NODE_VERSION}-alpine AS node

# Pull in relevant ruby image
FROM ruby:3.2.2-alpine

# As this is a multistage Docker image build
# we will pull in the contents from the previous node image build stage
# to our current ruby build image stage
# so that the ruby image build stage has the correct nodejs version
COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/share /usr/local/share
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin

# Set the app directory
WORKDIR /app

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get update && \
apt-get install -y nodejs && \
npm install -g [email protected]
# Install application dependencies
RUN apk add --update --no-cache \
npm \
ca-certificates \
build-base \
libpq-dev \
git \
tzdata \
curl

COPY Gemfile Gemfile.lock ./
RUN npm install -g [email protected] --force

RUN yarn install --check-files

RUN gem install bundler && bundle install --jobs 20 --retry 5

COPY . .

RUN rake assets:precompile
COPY Gemfile Gemfile.lock ./

RUN gem install bundler && bundle install --jobs 20 --retry 5

RUN NODE_OPTIONS=--openssl-legacy-provider rake assets:precompile

EXPOSE 3000

CMD ["rails", "server", "-b", "0.0.0.0"]
CMD ["rails", "server", "-b", "0.0.0.0"]
23 changes: 13 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.1'
ruby '3.2.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 7.0.8'
gem 'rails', '~> 7.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.6'
# Use Puma as the app server
Expand All @@ -24,40 +24,43 @@ gem 'aws-sdk-cognitoidentityprovider', '~> 1.82.0'
# importing creds
gem 'aws-sdk-s3', '~> 1'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '~> 1.16.0', '>= 1.16.0', require: false
gem 'bootsnap', '~> 1.17.0', require: false

# For scheduling tasks
gem 'arask', '~> 1.2.3'

# for postgresql
gem 'activerecord-postgis-adapter', '~> 8.0.3'
gem 'activerecord-postgis-adapter', '~> 9.0.1'
gem 'pg', '~> 1.5.4'
# remove if not option two taken in project
gem 'jwt', '~> 2.7.1'
gem 'rest-client', '~> 2.1'
gem 'rollbar', '~> 3.4.0'
gem 'rollbar', '~> 3.4.1'
gem 'roo', '~> 2.10.0'
# remove if not option two taken in project

# For canonical urls
gem 'canonical-rails', github: 'jumph4x/canonical-rails'

# For environment variables
gem 'aws-sdk-ssm', '~> 1.158.0'
gem 'aws-sdk-ssm', '~> 1.159.0'

# Add rate limiting on the API
gem 'rack-attack', '~> 6.7.0'

# GOV.UK Frontend helpers
gem 'ccs-frontend_helpers', '~> 0.1.1'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '~> 11.1.3', platforms: %i[mri mingw x64_mingw]
gem 'dotenv-rails', '~> 2.8.1', '>= 2.8.1'
gem 'i18n-tasks', '~> 1.0.12', '>= 1.0.12'
gem 'i18n-tasks', '~> 1.0.13'
gem 'rspec-rails', '~> 6.0.3', '>= 6.0.3'
gem 'rubocop', '~> 1.56.4'
gem 'rubocop', '~> 1.57.2'
gem 'rubocop-performance', '~> 1.19.1'
gem 'rubocop-rails', '~> 2.21.2'
gem 'rubocop-rspec', '~> 2.24.1' # or gem 'rubocop-minitest'
gem 'rubocop-rails', '~> 2.22.1'
gem 'rubocop-rspec', '~> 2.25.0' # or gem 'rubocop-minitest'
gem 'brakeman', '~> 6.0.1'
end

Expand Down
Loading

0 comments on commit 9dc6c35

Please sign in to comment.