forked from rubygems/rubygems.org
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (49 loc) · 1.84 KB
/
erd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: ERD
on:
pull_request:
paths:
- ".github/workflows/erd.yml"
- "db/schema.rb"
- "doc/erd.svg"
- "doc/erd.dot"
push:
branches:
- master
paths:
- "db/schema.rb"
- "doc/erd.svg"
- "doc/erd.dot"
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
erd:
name: Verify ERD up-to-date
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Install and start database service
run: |
docker-compose up -d db
- uses: ruby/setup-ruby@7d546f4868fb108ed378764d873683f920672ae2 # v1.149.0
with:
bundler-cache: true
- name: Install Graphviz
run: sudo apt-get install graphviz
- name: Prepare environment
run: |
cp config/database.yml.sample config/database.yml
bundle exec rake db:setup
- name: Generate ERD
run: |
bundle exec rake erd filetype=dot filename=doc/erd-ci orientation=vertical title="RubyGems.org domain model"
- name: Check diff
# `tr -d "[:blank:]"`: remove horizontal whitespace to account for machine differences (works better than diff's --ignore-all-space)
# `sort`: sorts line since Graphviz instruction order is non-deterministic
# diff to check the source controlled-file against CI-generated file
# Inspired by: https://github.com/voormedia/rails-erd/issues/281#issuecomment-1048721398
run: diff --unified <(tr -d "[:blank:]" < doc/erd-ci.dot | sort) <(tr -d "[:blank:]" < doc/erd.dot | sort)
- name: Print error
if: ${{ failure() }}
run: |
echo "::error file=doc/erd.dot::ERD is out of date."
echo "Please install Graphviz (\`brew install graphviz\`) and run \`rake gen_erd\`"