Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tahb committed Dec 7, 2020
2 parents 00fcc3b + bd72142 commit 0d2a659
Show file tree
Hide file tree
Showing 99 changed files with 1,577 additions and 684 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ROLLBAR_ACCESS_TOKEN=ROLLBAR_ACCESS_TOKEN
ROLLBAR_ENV=development

DATABASE_URL=postgres://postgres@localhost:5432/buy-for-your-school-development
REDIS_CACHE_URL=redis://localhost:6379/1

# Contentful
CONTENTFUL_URL=cdn.contentful.com
Expand All @@ -18,3 +19,4 @@ CONTENTFUL_ENVIRONMENT=master
CONTENTFUL_ACCESS_TOKEN=
CONTENTFUL_PLANNING_START_ENTRY_ID=
CONTENTFUL_PREVIEW_APP=false
CONTENTFUL_ENTRY_CACHING=false
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Reference: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use

DATABASE_URL=postgres://postgres@localhost:5432/buy-for-your-school-test
REDIS_CACHE_URL=redis://localhost:6379/2

# Contentful
CONTENTFUL_URL=cdn.contentful.com
Expand All @@ -14,3 +15,4 @@ CONTENTFUL_ENVIRONMENT=master
CONTENTFUL_ACCESS_TOKEN=123
CONTENTFUL_PLANNING_START_ENTRY_ID=1UjQurSOi5MWkcRuGxdXZS
CONTENTFUL_PREVIEW_APP=false
CONTENTFUL_ENTRY_CACHING=false
20 changes: 4 additions & 16 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@ on:
jobs:
test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Docker
run: docker network create test
- name: Set up Postgres
run: docker run -d --name pg --network test -e POSTGRES_USER=test -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres:11
- name: Build a new Docker image
run: docker build . --build-arg RAILS_ENV=test -t app:test
- name: Run the tests
run: |
docker run --name test-container \
--network test \
-e RAILS_ENV=test \
-e DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true \
-e DATABASE_URL=postgres://test@pg:5432/app_test \
app:test bundle exec rake
- name: Build
run: docker-compose -f docker-compose.ci.yml build
- name: Test
run: docker-compose -f docker-compose.ci.yml run --rm test bundle exec rake
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog 1.0.0].

## [Unreleased]

## [release-003] - 2020-12-07

- add database foreign key constraints for better data integrity
- Contentful entry requests use a new Redis read cache
- service name included in the header
- refactor name of "Plan" to "Journey"
- refactor name of "Question" to "Step"
- refactor redis caching into reusable class
- users can be shown a step in the journey that is only static content

## [release-002] - 2020-11-16

- migrate answer database table into Radio and ShortText
Expand All @@ -24,8 +34,10 @@ Contentful fixture
- multiple radio questions can be answered in sequence
- users can be asked to answer a short text question
- Contentful can redirect users to preview endpoints
- users can be asked to answer a long text question

[unreleased]: https://github.com/DfE/DFE-Digital/buy-for-your-school/compare/release-001...HEAD
[unreleased]: https://github.com/DFE-Digital/buy-for-your-school/compare/release-003...HEAD
[release-003]: https://github.com/DFE-Digital/buy-for-your-school/compare/release-002...release-003
[release-002]: https://github.com/DFE-Digital/buy-for-your-school/compare/release-001...release-002
[release-001]: https://github.com/DFE-Digital/buy-for-your-school/compare/release-000...release-001

Expand Down
64 changes: 37 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,61 @@
FROM ruby:2.6.6 as release
# BUILD STAGE #
FROM ruby:2.6.6 AS build
MAINTAINER dxw <rails@dxw.com>

ENV INSTALL_PATH /srv/app
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-production}
ENV RACK_ENV=${RAILS_ENV:-production}

WORKDIR $INSTALL_PATH

RUN apt-get update && apt-get install -qq -y \
build-essential \
libpq-dev \
--fix-missing --no-install-recommends
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs

ENV INSTALL_PATH /srv/app
RUN mkdir -p $INSTALL_PATH
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json

WORKDIR $INSTALL_PATH
RUN npm install

# set rails environment
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-production}
ENV RACK_ENV=${RAILS_ENV:-production}
COPY Gemfile* ./
RUN gem install bundler:2.1.4 --no-document

COPY package.json $INSTALL_PATH/package.json
COPY package-lock.json $INSTALL_PATH/package-lock.json
ARG BUNDLE_EXTRA_GEM_GROUPS
ENV BUNDLE_GEM_GROUPS=${BUNDLE_EXTRA_GEM_GROUPS:-"production"}
RUN bundle config set no-cache "true"
RUN bundle config set with $BUNDLE_GEM_GROUPS
RUN bundle install --no-binstubs --retry=3 --jobs=4

RUN npm install
COPY . .

# RELEASE STAGE #
FROM ruby:2.6.6 AS release

COPY Gemfile $INSTALL_PATH/Gemfile
COPY Gemfile.lock $INSTALL_PATH/Gemfile.lock
ENV INSTALL_PATH /srv/app
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-production}
ENV RACK_ENV=${RAILS_ENV:-production}

RUN gem update --system
RUN gem install bundler
WORKDIR $INSTALL_PATH

# bundle ruby gems based on the current environment, default to production
RUN echo $RAILS_ENV
RUN \
if [ "$RAILS_ENV" = "production" ]; then \
bundle install --without development test --retry 10; \
else \
bundle install --retry 10; \
fi
RUN gem install bundler:2.1.4 --no-document

COPY . $INSTALL_PATH
COPY --from=build /usr/local/bundle/ /usr/local/bundle/
COPY --from=build $INSTALL_PATH $INSTALL_PATH

RUN RAILS_ENV=$RAILS_ENV SECRET_KEY_BASE="super secret" bundle exec rake assets:precompile --quiet
# Compiling assets requires a key to exist: https://github.com/rails/rails/issues/32947
RUN if [ "$RAILS_ENV" = "production" ]; then \
RAILS_ENV=production SECRET_KEY_BASE="key" bundle exec rake assets:precompile; \
fi

# db setup
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 3000

CMD ["rails", "server"]
CMD ["bundle", "exec", "rails", "server"]
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ gem "jbuilder", "~> 2.5"
gem "jquery-rails"
gem "pg"
gem "mini_racer"
gem "puma", "~> 5.0"
gem "puma", "~> 5.1"
gem "redis", "~> 4.2"
gem "redis-namespace"
gem "rollbar"
gem "rails", "~> 6.0.0"
gem "sass-rails", "~> 6.0"
Expand All @@ -31,6 +33,7 @@ end

group :test do
gem "capybara", ">= 2.15"
gem "mock_redis"
gem "selenium-webdriver"
gem "shoulda-matchers"
gem "simplecov"
Expand Down
49 changes: 29 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ GEM
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
capybara (3.33.0)
capybara (3.34.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand Down Expand Up @@ -104,22 +104,22 @@ GEM
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.9.0)
erubi (1.10.0)
execjs (2.7.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
railties (>= 5.0.0)
faker (2.14.0)
faker (2.15.1)
i18n (>= 1.6, < 2)
ffi (1.13.1)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
globalid (0.4.2)
activesupport (>= 4.2.0)
govuk_design_system_formbuilder (2.1.4)
govuk_design_system_formbuilder (2.1.5)
actionview (>= 5.2)
activemodel (>= 5.2)
activesupport (>= 5.2)
Expand All @@ -145,10 +145,10 @@ GEM
launchy (2.5.0)
addressable (~> 2.7)
libv8 (8.4.255.0)
listen (3.3.1)
listen (3.3.3)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0)
loofah (2.8.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -162,20 +162,21 @@ GEM
mini_racer (0.3.1)
libv8 (~> 8.4.255)
minitest (5.14.2)
mock_redis (0.26.0)
msgpack (1.3.3)
multi_json (1.15.0)
nio4r (2.5.4)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
parallel (1.20.0)
parallel (1.20.1)
parser (2.7.2.0)
ast (~> 2.4.1)
pg (1.2.3)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
puma (5.0.4)
puma (5.1.0)
nio4r (~> 2.0)
rack (2.2.3)
rack-test (1.1.0)
Expand Down Expand Up @@ -212,9 +213,12 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.2.5)
redis-namespace (1.8.0)
redis (>= 3.0.4)
regexp_parser (1.8.2)
rexml (3.2.4)
rollbar (3.1.0)
rollbar (3.1.1)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
Expand All @@ -232,19 +236,19 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (1.2.0)
rubocop (1.4.2)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 1.0.1)
rubocop-ast (>= 1.1.1)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.1.1)
rubocop-ast (1.3.0)
parser (>= 2.7.1.5)
rubocop-performance (1.8.1)
rubocop (>= 0.87.0)
rubocop-performance (1.9.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.10.1)
rubyzip (2.3.0)
Expand All @@ -263,10 +267,12 @@ GEM
rubyzip (>= 1.2.2)
shoulda-matchers (4.4.1)
activesupport (>= 4.2.0)
simplecov (0.19.1)
simplecov (0.20.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
spring (2.1.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
Expand All @@ -280,9 +286,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
standard (0.9.0)
rubocop (= 1.2.0)
rubocop-performance (= 1.8.1)
standard (0.10.1)
rubocop (= 1.4.2)
rubocop-performance (= 1.9.1)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
Expand All @@ -308,7 +314,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.1)
zeitwerk (2.4.2)

PLATFORMS
ruby
Expand All @@ -334,11 +340,14 @@ DEPENDENCIES
launchy
listen (>= 3.0.5, < 3.4)
mini_racer
mock_redis
pg
pry
puma (~> 5.0)
puma (~> 5.1)
rails (~> 6.0.0)
rails_layout
redis (~> 4.2)
redis-namespace
rollbar
rspec-rails
sass-rails (~> 6.0)
Expand Down
Loading

0 comments on commit 0d2a659

Please sign in to comment.