Skip to content

Commit

Permalink
Reinstate ER diagram generation
Browse files Browse the repository at this point in the history
changelog: Internal, Documentation, Generate the ER diagram on migrations

1. Diagrams are generated automatically during CI
2. Diagram can be customized using .erdconfig

We used to do this in the past and abandoned it in commit 47020c9,
as it was not maintained. This iteration should make it easier.
  • Loading branch information
vrajmohan committed Dec 12, 2024
1 parent 3200cf8 commit 587668a
Show file tree
Hide file tree
Showing 6 changed files with 1,761 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .erdconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: login.gov IdP entity-relationship diagram
notation: bachman
filename: idp_erd
filetype: svg
attributes:
- primary_keys
- foreign_keys
- content
sort: false
29 changes: 29 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,32 @@ deploy_eks:
IMAGE_TAG: $CI_COMMIT_SHA
rules:
- if: $CI_COMMIT_BRANCH == "main"

publish_er_diagram:
stage: .post
needs:
- job: build-ci-image
variables:
DOCKER_DB_HOST: db-postgres
POSTGRES_DB: identity_idp_test
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_password
POSTGRES_HOST_AUTH_METHOD: trust
RAILS_ENV: test
services:
- name: public.ecr.aws/docker/library/postgres:16.4
alias: db-postgres
command: ['--fsync=false', '--synchronous_commit=false', '--full_page_writes=false']
cache:
- <<: *ruby_cache
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "vm-reinstate-erd"
image: "${ECR_REGISTRY}/idp/ci:${CI_COMMIT_SHA}"
script:
- *bundle_install
- bundle exec rake db:create db:migrate --trace
- bundle exec rails erd
artifacts:
paths:
- idp_erd.svg
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ group :development, :test do
gem 'pry-doc'
gem 'pry-rails'
gem 'psych'
gem 'rails-erd'
gem 'rspec', '~> 3.13.0'
gem 'rspec-rails', '~> 7.0'
gem 'rubocop', '~> 1.69.1', require: false
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ GEM
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
cbor (0.5.9.8)
choice (0.2.0)
chunky_png (1.4.0)
coderay (1.1.3)
coercible (1.0.0)
Expand Down Expand Up @@ -544,6 +545,11 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
Expand Down Expand Up @@ -634,6 +640,8 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.2.0)
rubocop (~> 1.61)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.13.0)
ruby-saml (1.17.0)
nokogiri (>= 1.13.10)
Expand Down Expand Up @@ -833,6 +841,7 @@ DEPENDENCIES
rack_session_access (>= 0.2.0)
rails (~> 7.2.1)
rails-controller-testing (>= 1.0.4)
rails-erd
redacted_struct
redis (>= 3.2.0)
redis-session-store!
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/idp_ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN apt-get update -qq && \
nodejs \
locales \
google-chrome-stable \
graphviz \
yarn

RUN curl -Ss "https://storage.googleapis.com/chrome-for-testing-public/$(google-chrome --version | grep -Po '\d+\.\d+\.\d+\.\d+' | tr -d '\n')/linux64/chromedriver-linux64.zip" > /tmp/chromedriver.zip && \
Expand Down
Loading

0 comments on commit 587668a

Please sign in to comment.