Skip to content

Commit

Permalink
Merge pull request #1085 from alphagov/port-to-postgresql
Browse files Browse the repository at this point in the history
Port to PostgreSQL
  • Loading branch information
aldavidson authored Jan 2, 2024
2 parents 821e8f5 + 7919408 commit e383e17
Show file tree
Hide file tree
Showing 73 changed files with 1,575 additions and 642 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
description: 'Commit, tag or branch name to deploy'
required: true
type: string
default: 'main'
environment:
description: 'Environment to deploy to'
required: true
Expand All @@ -18,14 +19,6 @@ on:
- staging
- production
default: 'integration'
ecrRepositoryName:
description: 'ECR repo name to push image to'
required: true
type: choice
options:
- content-store
- content-store-postgresql-branch
default: 'content-store'
release:
types: [released]

Expand All @@ -35,7 +28,7 @@ jobs:
name: Build and publish image
uses: alphagov/govuk-infrastructure/.github/workflows/build-and-push-image.yml@main
with:
ecrRepositoryName: ${{ inputs.ecrRepositoryName || 'content-store' }}
ecrRepositoryName: content-store
gitRef: ${{ inputs.gitRef || github.ref_name }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_GOVUK_ECR_ACCESS_KEY_ID }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ jobs:
name: Run RSpec
runs-on: ubuntu-latest
steps:
- name: Setup MongoDB
uses: alphagov/govuk-infrastructure/.github/actions/setup-mongodb@main
with:
version: 2.6
- name: Setup Postgres
id: setup-postgres
uses: alphagov/govuk-infrastructure/.github/actions/setup-postgres@main

- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -44,10 +43,12 @@ jobs:
- name: Initialize database
env:
RAILS_ENV: test
TEST_DATABASE_URL: ${{ steps.setup-postgres.outputs.db-url }}
run: bundle exec rails db:setup

- name: Run RSpec
env:
RAILS_ENV: test
TEST_DATABASE_URL: ${{ steps.setup-postgres.outputs.db-url }}
GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas
run: bundle exec rake spec
12 changes: 8 additions & 4 deletions .github/workflows/verify-pact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ jobs:
env:
RAILS_ENV: test
steps:
- name: Setup MongoDB
uses: alphagov/govuk-infrastructure/.github/actions/setup-mongodb@main
with:
version: 2.6
- name: Setup Postgres
id: setup-postgres
uses: alphagov/govuk-infrastructure/.github/actions/setup-postgres@main

- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -44,11 +43,14 @@ jobs:

- name: Initialize database
run: bundle exec rails db:setup
env:
TEST_DATABASE_URL: ${{ steps.setup-postgres.outputs.db-url }}

- name: Verify pact consumer version
if: inputs.pact_artifact == ''
env:
PACT_CONSUMER_VERSION: ${{ inputs.pact_consumer_version }}
TEST_DATABASE_URL: ${{ steps.setup-postgres.outputs.db-url }}
run: bundle exec rake pact:verify

- name: Download pact artifact
Expand All @@ -61,3 +63,5 @@ jobs:
- name: Verify pact artifact
if: inputs.pact_artifact != ''
run: bundle exec rake pact:verify:at[tmp/pacts/publishing_api-content_store.json]
env:
TEST_DATABASE_URL: ${{ steps.setup-postgres.outputs.db-url }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

/coverage
/spec/reports

.byebug_history
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ inherit_mode:
# See https://github.com/alphagov/rubocop-govuk/blob/main/CONTRIBUTING.md
# **************************************************************

# Mongoid doesn't support this
Rails/FindBy:
Enabled: false
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ RUN bootsnap precompile --gemfile .

FROM $base_image

# TODO: remove this temporary MongoDB package once we no longer need mongoexport (once the migration to Postgres is done).
ARG mongo_package=mongodb-database-tools-ubuntu2204-x86_64-100.7.2.deb
ARG mongo_package_repo=https://fastdl.mongodb.org/tools/db
WORKDIR /tmp
RUN curl -LSsf "${mongo_package_repo}/${mongo_package}" --output "${mongo_package}" && \
apt-get install -y --no-install-recommends "./${mongo_package}" && \
rm -fr /tmp/*
# Need psql for importing from Mongo exports
RUN install_packages postgresql-client

ENV GOVUK_APP_NAME=content-store

Expand Down
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
source "https://rubygems.org"

gem "rails", "7.0.8"
gem "rails", "7.1.2"

gem "bootsnap", require: false
gem "deepsort"
gem "gds-api-adapters"
gem "gds-sso"
gem "govuk_app_config"
gem "mongo", "2.15.0" # Later releases require Mongo >= 3.6
gem "mongoid"
gem "pg"
gem "plek"
gem "rack-cache"
gem "uuidtools"
Expand All @@ -17,7 +16,7 @@ gem "whenever", require: false
group :development, :test do
gem "ci_reporter_rspec"
gem "climate_control"
gem "database_cleaner-mongoid"
gem "database_cleaner-active_record"
gem "factory_bot"
gem "govuk_schemas"
gem "govuk_test"
Expand Down
Loading

0 comments on commit e383e17

Please sign in to comment.