Skip to content

Commit

Permalink
Fri 17/add schema doc generation (#28)
Browse files Browse the repository at this point in the history
* Add build step for build of data dictionary [schemaspy]

* Add orb import
  • Loading branch information
awhodgson256 authored Dec 20, 2024
1 parent 3b60e29 commit a8e3d78
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: 2.1
orbs:
hmpps: ministryofjustice/hmpps@10
mem: circleci/[email protected]
parameters:
releases-slack-channel:
type: string
Expand Down Expand Up @@ -51,10 +52,53 @@ jobs:
path: build/test-results
- store_artifacts:
path: build/reports/tests

publish_data:
executor:
name: hmpps/java
tag: "21"
docker: *db_docker_config
steps:
- checkout
- mem/recall:
env_var: APP_VERSION
- run:
name: Migrate the database
command: |
wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.15.2/flyway-commandline-10.15.2-linux-x64.tar.gz | \
tar xvz && sudo ln -s `pwd`/flyway-10.15.2/flyway /usr/local/bin
flyway migrate -url="jdbc:postgresql://localhost:5433/$POSTGRES_DB" -user="postgres" -password="password" -locations="src/main/resources/db/migration" -postgresql.transactional.lock=false
- setup_remote_docker
- run:
name: Build data dictionary
command: |
sudo apt update && sudo apt install graphviz
script/build-data-dictionary.sh
- run:
name: Tag docker image
command: |
docker tag data-dictionary "quay.io/hmpps/${CIRCLE_PROJECT_REPONAME}:data-dictionary-${APP_VERSION}"
- when:
condition:
or:
- equal: [ main, << pipeline.git.branch >> ]
- matches:
pattern: "^hotfix/.+$"
value: << pipeline.git.branch >>
steps:
- run:
name: Publish docker image
command: |
docker login -u="${QUAYIO_USERNAME}" -p="${QUAYIO_PASSWORD}" quay.io
docker push "quay.io/hmpps/${CIRCLE_PROJECT_REPONAME}:data-dictionary-${APP_VERSION}"
workflows:
version: 2
build-test-and-deploy:
jobs:
- publish_data:
requires:
- build_docker
- validate:
filters:
tags:
Expand All @@ -81,6 +125,7 @@ workflows:
requires:
- validate
- build_docker
- publish_data
- helm_lint
helm_timeout: 5m
# - request-preprod-approval:
Expand Down
4 changes: 4 additions & 0 deletions script/Dockerfile.data-dictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM bitnami/nginx:1.27

WORKDIR /app
COPY schema/ meta/schema/
16 changes: 16 additions & 0 deletions script/build-data-dictionary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -e
basedir=$(dirname "$0")
jardir="$basedir/libs"
schemadir="$basedir/schema"

mkdir -p "$jardir" "$schemadir"

wget https://github.com/schemaspy/schemaspy/releases/download/v6.1.0/schemaspy-6.1.0.jar -O "$jardir/schemaspy.jar"
wget https://jdbc.postgresql.org/download/postgresql-42.2.19.jar -O "$jardir/postgresql.jar"

java -jar "$jardir/schemaspy.jar" -t pgsql -dp "$jardir/postgresql.jar" \
-db "${POSTGRES_DB:-findandrefer}" -host "localhost" -port "5433" -u "postgres" -p "password" \
-nopages \
-o "$schemadir"

docker build --pull --file="$basedir/Dockerfile.data-dictionary" --tag=data-dictionary "$basedir"

0 comments on commit a8e3d78

Please sign in to comment.