pact_broker 2.58.0 → 2.59.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +45 -0
  3. data/.travis.yml +5 -3
  4. data/CHANGELOG.md +37 -0
  5. data/DEVELOPER_SETUP.md +46 -16
  6. data/Dockerfile +23 -2
  7. data/Gemfile +29 -2
  8. data/config.ru +32 -12
  9. data/config/database.yml +7 -0
  10. data/docker-compose-dev-postgres.yml +35 -0
  11. data/docker-compose-test.yml +100 -0
  12. data/lib/pact_broker/api/decorators/decorator_context.rb +1 -1
  13. data/lib/pact_broker/api/decorators/version_decorator.rb +2 -0
  14. data/lib/pact_broker/api/pact_broker_urls.rb +4 -4
  15. data/lib/pact_broker/api/paths.rb +15 -0
  16. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +26 -8
  17. data/lib/pact_broker/api/resources/all_webhooks.rb +12 -3
  18. data/lib/pact_broker/api/resources/badge.rb +4 -0
  19. data/lib/pact_broker/api/resources/base_resource.rb +2 -174
  20. data/lib/pact_broker/api/resources/can_i_deploy.rb +8 -0
  21. data/lib/pact_broker/api/resources/dashboard.rb +4 -0
  22. data/lib/pact_broker/api/resources/default_base_resource.rb +211 -0
  23. data/lib/pact_broker/api/resources/error_handler.rb +3 -5
  24. data/lib/pact_broker/api/resources/group.rb +7 -11
  25. data/lib/pact_broker/api/resources/index.rb +4 -0
  26. data/lib/pact_broker/api/resources/integration.rb +12 -0
  27. data/lib/pact_broker/api/resources/integrations.rb +9 -1
  28. data/lib/pact_broker/api/resources/label.rb +16 -6
  29. data/lib/pact_broker/api/resources/latest_pact.rb +8 -0
  30. data/lib/pact_broker/api/resources/latest_pacts.rb +9 -4
  31. data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +16 -2
  32. data/lib/pact_broker/api/resources/matrix.rb +2 -2
  33. data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +1 -1
  34. data/lib/pact_broker/api/resources/pact.rb +8 -0
  35. data/lib/pact_broker/api/resources/pact_content_diff.rb +1 -2
  36. data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +1 -7
  37. data/lib/pact_broker/api/resources/pact_versions.rb +1 -3
  38. data/lib/pact_broker/api/resources/pact_webhooks.rb +2 -5
  39. data/lib/pact_broker/api/resources/pact_webhooks_status.rb +1 -17
  40. data/lib/pact_broker/api/resources/pacticipant.rb +11 -14
  41. data/lib/pact_broker/api/resources/pacticipants.rb +15 -1
  42. data/lib/pact_broker/api/resources/pacticipants_for_label.rb +1 -1
  43. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +8 -1
  44. data/lib/pact_broker/api/resources/provider_pacts.rb +9 -1
  45. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +1 -1
  46. data/lib/pact_broker/api/resources/tag.rb +5 -1
  47. data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -2
  48. data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +4 -0
  49. data/lib/pact_broker/api/resources/verification.rb +7 -3
  50. data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +5 -1
  51. data/lib/pact_broker/api/resources/verifications.rb +7 -3
  52. data/lib/pact_broker/api/resources/version.rb +4 -1
  53. data/lib/pact_broker/api/resources/versions.rb +1 -3
  54. data/lib/pact_broker/api/resources/webhook.rb +6 -2
  55. data/lib/pact_broker/api/resources/webhook_execution.rb +4 -0
  56. data/lib/pact_broker/api/resources/webhooks.rb +3 -18
  57. data/lib/pact_broker/app.rb +1 -0
  58. data/lib/pact_broker/badges/service.rb +3 -2
  59. data/lib/pact_broker/configuration.rb +21 -2
  60. data/lib/pact_broker/db/clean.rb +0 -6
  61. data/lib/pact_broker/doc/views/layouts/main.haml +1 -1
  62. data/lib/pact_broker/domain/pacticipant.rb +7 -2
  63. data/lib/pact_broker/domain/version.rb +3 -0
  64. data/lib/pact_broker/groups/service.rb +1 -1
  65. data/lib/pact_broker/index/service.rb +9 -43
  66. data/lib/pact_broker/matrix/deployment_status_summary.rb +1 -1
  67. data/lib/pact_broker/pacticipants/repository.rb +2 -2
  68. data/lib/pact_broker/pacts/content.rb +2 -1
  69. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +2 -5
  70. data/lib/pact_broker/pacts/pact_publication.rb +11 -9
  71. data/lib/pact_broker/pacts/pact_version.rb +3 -4
  72. data/lib/pact_broker/pacts/repository.rb +53 -39
  73. data/lib/pact_broker/pacts/verifiable_pact.rb +8 -0
  74. data/lib/pact_broker/policies.rb +53 -0
  75. data/lib/pact_broker/repositories/helpers.rb +3 -20
  76. data/lib/pact_broker/test/test_data_builder.rb +4 -4
  77. data/lib/pact_broker/ui/controllers/clusters.rb +1 -1
  78. data/lib/pact_broker/ui/controllers/groups.rb +2 -2
  79. data/lib/pact_broker/ui/controllers/index.rb +1 -3
  80. data/lib/pact_broker/ui/controllers/matrix.rb +2 -2
  81. data/lib/pact_broker/ui/views/groups/show.html.erb +3 -3
  82. data/lib/pact_broker/ui/views/index/show-with-tags.haml +10 -10
  83. data/lib/pact_broker/ui/views/index/show.haml +6 -6
  84. data/lib/pact_broker/ui/views/layouts/main.haml +1 -1
  85. data/lib/pact_broker/ui/views/matrix/show.haml +4 -5
  86. data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +3 -5
  87. data/lib/pact_broker/version.rb +1 -1
  88. data/lib/pact_broker/versions/repository.rb +2 -4
  89. data/lib/rack/pact_broker/request_target.rb +6 -1
  90. data/lib/sequel/plugins/insert_ignore.rb +69 -0
  91. data/lib/sequel/plugins/upsert.rb +103 -0
  92. data/pact_broker.gemspec +22 -41
  93. data/public/javascripts/pact.js +6 -2
  94. data/script/docker/db-execute-sql-file.sh +2 -0
  95. data/script/issues/consumer-version-selectors-docs/issue-text.txt +11 -0
  96. data/script/issues/consumer-version-selectors-docs/issues.txt +6 -0
  97. data/script/issues/consumer-version-selectors-docs/raise-issue-in-client-repos.sh +10 -0
  98. data/script/prod/redact-data.sql +1 -0
  99. data/script/release-via-github-action.sh +7 -0
  100. data/script/seed.rb +5 -7
  101. data/script/trigger-release.sh +30 -0
  102. data/spec/features/get_versions_spec.rb +1 -6
  103. data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +4 -0
  104. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +2 -2
  105. data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +24 -6
  106. data/spec/lib/pact_broker/api/resources/all_webhooks_spec.rb +1 -1
  107. data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +158 -0
  108. data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +18 -1
  109. data/spec/lib/pact_broker/api/resources/tag_spec.rb +2 -2
  110. data/spec/lib/pact_broker/api/resources/webhook_spec.rb +1 -1
  111. data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +1 -1
  112. data/spec/lib/pact_broker/badges/service_spec.rb +6 -6
  113. data/spec/lib/pact_broker/db/clean_old_spec.rb +125 -0
  114. data/spec/lib/pact_broker/db/clean_spec.rb +45 -11
  115. data/spec/lib/pact_broker/index/service_spec.rb +2 -3
  116. data/spec/lib/pact_broker/pacts/content_spec.rb +8 -0
  117. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +36 -0
  118. data/spec/lib/pact_broker/versions/repository_spec.rb +8 -0
  119. data/spec/lib/rack/pact_broker/request_target_spec.rb +7 -0
  120. data/spec/lib/sequel/plugins/insert_ignore_spec.rb +82 -0
  121. data/spec/lib/sequel/plugins/upsert_spec.rb +125 -0
  122. data/spec/spec_helper.rb +1 -0
  123. data/tasks/audit.rake +6 -2
  124. data/tasks/development.rake +2 -2
  125. metadata +46 -284
  126. data/spec/lib/pact_broker/api/resources/base_resource_spec.rb +0 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9b3ca0a02cb3eb39138704d804ed6a9997aa044cf0729059175d24acf02794f
4
- data.tar.gz: 619a828a1ab0f7b1d5677525c5d52b82ec785455a19c0603ce18a3981be81eb7
3
+ metadata.gz: f1933f8f7902c43ed7d9db7c022a66f2569c6301dec2c8ac767e1da7b05f70b5
4
+ data.tar.gz: 40d82183c3a94b2bfc2bfa37a9aee12cc27729e1c3a1b3191df980c2ba3ad192
5
5
  SHA512:
6
- metadata.gz: 80e5a6272e05b35ff82a5a08fc26cb8acc2729d64b969f3764dbd1bb6be4ed168722d884ca635fe85dc58946c085dc60d65b1d4c95cc0fc8d9437a9f8aaa3356
7
- data.tar.gz: d094ef10bf315a635afd6c6ef52148ac25c2e03afafcbb5e53b411c4ff2e676fd01d9db45414be4354054396547ae182b4991beadf6e6f0de63045cb38b2ccde
6
+ metadata.gz: 5078b560d3d0abe897572f35276b3aec1c6752026ba849a9b61517def382ea0d936731a6b2f59801b0101cab7bde636ef3e9e5e7afe9524e13c3def552f48ded
7
+ data.tar.gz: 6fc016ea9e10bcbad4f78d60b93a81b5d0aab2ffbfef9d222a094e0348f632680995bce488abe9fefe55cad745afafef323ce3c972db3e78a7e1f6759d222f6e
@@ -0,0 +1,45 @@
1
+ name: Release gem
2
+
3
+ on:
4
+ repository_dispatch:
5
+ types:
6
+ - release-triggered
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0
15
+ # - name: 'Wait for status checks'
16
+ # id: wait-for-status-checks
17
+ # uses: "WyriHaximus/github-action-wait-for-status@v2"
18
+ # with:
19
+ # checkInterval: 15
20
+ # env:
21
+ # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
22
+ - uses: pact-foundation/release-gem@v0.0.11
23
+ env:
24
+ GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
25
+ GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
26
+ INCREMENT: '${{ github.event.client_payload.increment }}'
27
+ notify-gem-released:
28
+ needs: release
29
+ strategy:
30
+ matrix:
31
+ repository: [pact-foundation/pact-broker-docker, DiUS/pact_broker-docker]
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - name: Notify ${{ matrix.repository }} of gem release
35
+ uses: peter-evans/repository-dispatch@v1
36
+ with:
37
+ token: ${{ secrets.GHTOKENNOTIFYPBRELEASED }}
38
+ repository: ${{ matrix.repository }}
39
+ event-type: gem-released
40
+ client-payload: |
41
+ {
42
+ "name": "${{ needs.release.outputs.gem_name }}",
43
+ "version": "${{ needs.release.outputs.version }}",
44
+ "increment": "${{ needs.release.outputs.increment }}"
45
+ }
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ # Only supporting 2.4 until we upgrade the DiUS pact broker base image
3
4
  - 2.4.1
4
5
  - 2.5
5
6
  services:
@@ -11,11 +12,10 @@ env:
11
12
  global:
12
13
  - CC_TEST_REPORTER_ID=dc2c30b67c9e2a5309e1aef699c30fdab55ba4f0e4f1beac029ba93e293835db
13
14
  - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
14
- - INSTALL_MYSQL=true
15
15
  matrix:
16
16
  - DATABASE_ADAPTER=default RUBYOPT="-W0"
17
- - DATABASE_ADAPTER=postgres RUBYOPT="-W0"
18
- - DATABASE_ADAPTER=mysql RUBYOPT="-W0"
17
+ - DATABASE_ADAPTER=postgres RUBYOPT="-W0" INSTALL_PG=true
18
+ - DATABASE_ADAPTER=mysql RUBYOPT="-W0" INSTALL_MYSQL=true
19
19
  before_script:
20
20
  - cp config/database.travis.yml config/database.yml
21
21
  - psql -U postgres -c "CREATE DATABASE pact_broker;"
@@ -23,6 +23,8 @@ before_script:
23
23
  - mysql -e "GRANT ALL ON pact_broker.* TO 'travis'@'%';"
24
24
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25
25
  - chmod +x ./cc-test-reporter
26
+ before_install:
27
+ - bundle config set without 'development'
26
28
  script:
27
29
  - bundle exec rake
28
30
  - if [ "$DATABASE_ADAPTER" == "postgres" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true; fi
@@ -1,3 +1,40 @@
1
+ <a name="v2.59.2"></a>
2
+ ### v2.59.2 (2020-08-06)
3
+
4
+ #### Bug Fixes
5
+
6
+ * gracefully handle contracts without interactions or messages in deployment status warnings ([6c223e69](/../../commit/6c223e69))
7
+ * add missing info level log for business level errors ([80a895bf](/../../commit/80a895bf))
8
+
9
+ <a name="v2.59.1"></a>
10
+ ### v2.59.1 (2020-08-04)
11
+
12
+ #### Bug Fixes
13
+
14
+ * fix error rendering relationships diagram when the number of index items is greater than one page ([93a19982](/../../commit/93a19982))
15
+
16
+ <a name="v2.59.0"></a>
17
+ ### v2.59.0 (2020-07-30)
18
+
19
+ #### Features
20
+
21
+ * add timestamps to version resource ([818a0c2c](/../../commit/818a0c2c))
22
+
23
+ <a name="v2.58.3"></a>
24
+ ### v2.58.3 (2020-07-25)
25
+
26
+ #### Bug Fixes
27
+
28
+ * correctly encode user entered data in attributes, Javascript, and HTML ([523980e2](/../../commit/523980e2))
29
+
30
+ <a name="v2.58.2"></a>
31
+ ### v2.58.2 (2020-07-17)
32
+
33
+ #### Bug Fixes
34
+
35
+ * update CSP to allow badges to be loaded from shields.io ([a87e5274](/../../commit/a87e5274))
36
+ * add missing URL encoding in various URLs ([276094bc](/../../commit/276094bc))
37
+
1
38
  <a name="v2.58.0"></a>
2
39
  ### v2.58.0 (2020-06-19)
3
40
 
@@ -2,36 +2,66 @@
2
2
 
3
3
  ## Preparation
4
4
 
5
- ### With virtual battery
5
+ ### With Docker Compose
6
+
7
+ The following command runs the application from the source code and binds it to port 9292 of your host. It mounts the source code as a volume, so changes to the code will be applied if you stop and start the containers (the app code doesn't hot reload however).
8
+
9
+ ```sh
10
+ docker-compose -f docker-compose-dev-postgres.yml up --build
11
+ ```
12
+
13
+ ### With Docker
14
+
15
+ This allows you to open a shell to a development environment where you can run the tests and rake tasts.
6
16
 
7
17
  * Build an initial local image with Docker
8
- ```sh
9
- docker build --rm -t pact_broker:dev .
10
- ```
18
+
19
+ ```sh
20
+ docker build --rm -t pact_broker:dev .
21
+ ```
11
22
 
12
23
  * Spin up a container with mounted volume and open an interactive shell session
13
- ```sh
14
- docker run --rm -v $(PWD):/app -w /app -it pact_broker:dev bash
15
- ```
24
+
25
+ ```sh
26
+ docker run --rm -v $(PWD):/home -w /home -it pact_broker:dev bash
27
+ ```
28
+
29
+ Remember to rebuild the image if you change any of the gems or gem versions.
16
30
 
17
31
  ### With native install
18
32
 
19
33
  * You will need to install Ruby 2.5, and preferably a ruby version manager. I recommend using [chruby][chruby] and [ruby-install][ruby-install].
20
34
  * Install bundler (the Ruby gem dependency manager) `gem install bundler`
21
35
  * Check out the pact_broker repository and cd into it.
22
- * Run `bundle install`. If you have not got mysql or postgres installed locally, comment out the `mysql2` and `pg` development dependency lines in `pact_broker.gemspec`, as these are only really required on Travis.
36
+ * Run `bundle install`. If you have any gem conflict issues, run `bundle update`.
37
+
38
+ To make the barrier to entry as low as possible, the mysql2 and pg gems are not installed by default, as they require mysql and postgres to be installed on your local machine. If you want to install them, set `INSTALL_MYSQL=true` and/or `INSTALL_PG=true` before running `bundle install`.
23
39
 
24
40
  ## Running a local application
25
41
 
26
- * Run `bundle exec rake pact_broker:dev:setup`. This will create an example application that you can run locally, that uses the local source code.
27
- * To run the example:
28
- ```sh
29
- cd dev
30
- bundle install
31
- bundle exec rackup
32
- ```
33
- * The application will be available on `http://localhost:9292`
42
+ * Install Ruby and the gems as per the instructions above.
43
+ * Run `bundle exec rackup`.
44
+ * The application will be available on `http://localhost:9292`. It uses a sqlite database that is stored in the `./tmp` directory.
45
+
46
+ You can set the `PACT_BROKER_DATABASE_URL` environment variable to use a postgres/mysql database using the format `driver://username:password@host:port/database` eg. `postgres://pact_broker:password@localhost/pact_broker`. Ensure you have set `INSTALL_MYSQL=true` or `INSTALL_PG=true` and run `bundle install` to make sure the required gems are present.
47
+
48
+ ## Running the tests with postgres and mysql
49
+
50
+ ```
51
+ docker-compose -f docker-compose-test.yml up --build --remove-orphans
52
+
53
+ # in separate console window...
54
+ docker-compose -f docker-compose-test.yml run --rm postgres-tests bash
55
+
56
+ # in separate console window...
57
+ docker-compose -f docker-compose-test.yml run --rm mysql-tests bash
58
+
59
+ # inside the tests container
60
+ bundle exec rake
34
61
 
62
+ # if you don't want to run the whole rake test suite, init the db first
63
+ /home/init-db.sh
64
+ ```
35
65
  ## Running the tests
36
66
 
37
67
  * To run everything (specs, pact verifications, vulnerability scan...):
data/Dockerfile CHANGED
@@ -1,6 +1,9 @@
1
1
  FROM ruby:2.5.3-alpine
2
2
 
3
+ WORKDIR /home
4
+
3
5
  ENV INSTALL_MYSQL=true
6
+ ENV INSTALL_PG=true
4
7
  RUN apk update \
5
8
  && apk --no-cache add \
6
9
  "build-base>=0.5" \
@@ -14,11 +17,29 @@ RUN apk update \
14
17
  "mariadb-dev>=10.3" \
15
18
  && rm -rf /var/cache/apk/*
16
19
 
17
- WORKDIR /app
20
+ RUN apk add --no-cache openssl less
21
+
22
+ ENV DOCKERIZE_VERSION v0.6.1
23
+ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
24
+ && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
25
+ && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
26
+
18
27
 
19
- COPY . ./
28
+ COPY Gemfile /home/Gemfile
29
+ COPY pact_broker.gemspec /home/pact_broker.gemspec
30
+ COPY lib/pact_broker/version.rb /home/lib/pact_broker/version.rb
31
+ COPY .gitignore /home/.gitignore
20
32
 
21
33
  RUN gem install bundler -v '~>2.0.0' \
22
34
  && bundle install --jobs 3 --retry 3
23
35
 
36
+ RUN echo '#!/bin/sh' >> /home/start.sh
37
+ RUN echo 'bundle exec rackup -o 0.0.0.0 -p 9292' >> /home/start.sh
38
+ RUN chmod +x /home/start.sh
39
+
40
+ RUN echo '#!/bin/sh' >> /home/init-db.sh
41
+ RUN echo 'bundle exec rake db:prepare:test' >> /home/init-db.sh
42
+ RUN chmod +x /home/init-db.sh
43
+
44
+ ENTRYPOINT bash
24
45
  CMD []
data/Gemfile CHANGED
@@ -2,8 +2,35 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'simplecov', :require => false, :group => :test
5
+ gem 'rake', '~>12.3.3'
6
+ gem 'sqlite3', '~>1.3'
7
+ gem 'conventional-changelog', '~>1.3'
8
+ gem 'bump', '~> 0.5'
9
+
10
+ group :development do
11
+ gem 'pry-byebug'
12
+ gem 'sequel-annotate', '~>1.3'
13
+ end
14
+
15
+ group :test do
16
+ gem 'simplecov', :require => false
17
+ gem 'pact', '~>1.14'
18
+ gem 'rspec-pact-matchers', '~>0.1'
19
+ gem 'bundler-audit', '~>0.4'
20
+ gem 'fakefs', '~>0.4'
21
+ gem 'webmock', '~>2.3'
22
+ gem 'rspec', '~>3.0'
23
+ gem 'rspec-its', '~>1.2'
24
+ gem 'database_cleaner', '~>1.8', '>= 1.8.1'
25
+ gem 'timecop', '~> 0.9'
26
+ gem 'faraday', '~>0.15'
27
+ gem 'docker-api', '~>1.34'
28
+ end
6
29
 
7
30
  if ENV['INSTALL_MYSQL'] == "true"
8
31
  gem 'mysql2', '~>0.5'
9
- end
32
+ end
33
+
34
+ if ENV['INSTALL_PG'] == 'true'
35
+ gem 'pg', '~>1.2'
36
+ end
data/config.ru CHANGED
@@ -1,15 +1,35 @@
1
- require File.dirname(__FILE__) + '/config/boot'
2
- require 'db'
3
- require 'pact_broker/api'
4
- require 'rack/hal_browser'
5
- require 'pact_broker/ui/controllers/index'
1
+ require 'fileutils'
2
+ require 'logger'
3
+ require 'sequel'
4
+ require 'pact_broker'
6
5
 
6
+ FileUtils.mkdir_p('tmp') unless ENV['PACT_BROKER_DATABASE_URL']
7
7
 
8
- use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => "public"
9
- use Rack::HalBrowser::Redirect, :exclude => ['/diagnostic', '/trace','/index']
8
+ DATABASE_URL = ENV['PACT_BROKER_DATABASE_URL'] || 'sqlite://tmp/pact_broker_database.sqlite3'
9
+ DB_OPTIONS = { encoding: 'utf8', sql_log_level: :debug }
10
10
 
11
- run Rack::URLMap.new(
12
- '/ui/relationships' => PactBroker::UI::Controllers::Index,
13
- '/network-graph' => Rack::File.new("#{File.dirname(__FILE__)}/public/Network Graph REA.html"),
14
- '/' => PactBroker::API,
15
- )
11
+ ENV['TZ'] = 'Australia/Melbourne'
12
+
13
+ SemanticLogger.add_appender(io: $stderr)
14
+ SemanticLogger.default_level = :info
15
+
16
+ app = PactBroker::App.new do | config |
17
+ # config.logger.level = ::Logger::INFO
18
+ config.auto_migrate_db = true
19
+ config.enable_public_badge_access = true
20
+ config.order_versions_by_date = true
21
+ config.allow_missing_migration_files = true
22
+ config.base_equality_only_on_content_that_affects_verification_results = true
23
+ config.badge_provider_mode = :redirect
24
+
25
+ config.webhook_retry_schedule = [3, 3, 3]
26
+ config.webhook_host_whitelist = [/.*/, "10.0.0.0/8"]
27
+ config.webhook_scheme_whitelist = ['http', 'https']
28
+ config.webhook_http_method_whitelist = ['GET', 'POST']
29
+ #config.base_url = ENV['PACT_BROKER_BASE_URL']
30
+
31
+ database_logger = PactBroker::DB::LogQuietener.new(config.logger)
32
+ config.database_connection = Sequel.connect(DATABASE_URL, DB_OPTIONS.merge(logger: database_logger))
33
+ end
34
+
35
+ run app
@@ -18,6 +18,13 @@ test:
18
18
  password: postgres
19
19
  host: localhost
20
20
  port: "5433"
21
+ docker_compose_postgres:
22
+ adapter: postgres
23
+ database: postgres
24
+ username: postgres
25
+ password: postgres
26
+ host: postgres
27
+ port: "5432"
21
28
  mysql:
22
29
  <<: *default
23
30
  adapter: mysql2
@@ -0,0 +1,35 @@
1
+ version: "3"
2
+
3
+ services:
4
+ postgres:
5
+ image: postgres
6
+ healthcheck:
7
+ test: psql postgres --command "select 1" -U postgres
8
+ ports:
9
+ - "5432:5432"
10
+ environment:
11
+ POSTGRES_USER: postgres
12
+ POSTGRES_PASSWORD: postgres
13
+ POSTGRES_DB: postgres
14
+ volumes:
15
+ - postgres-volume:/var/lib/postgresql/data
16
+
17
+ pact-broker:
18
+ build: .
19
+ ports:
20
+ - "9292:9292"
21
+ depends_on:
22
+ - postgres
23
+ environment:
24
+ DATABASE_URL: postgres://postgres:postgres@postgres/postgres
25
+ PACT_BROKER_HIDE_PACTFLOW_MESSAGES: 'true'
26
+ command: dockerize -wait tcp://postgres:5432 /home/start.sh
27
+ volumes:
28
+ - ./lib:/home/lib
29
+ - ./db:/home/db
30
+ - ./config.ru:/home/config.ru
31
+ - ./tasks:/home/tasks
32
+ - ./Rakefile:/home/Rakefile
33
+
34
+ volumes:
35
+ postgres-volume:
@@ -0,0 +1,100 @@
1
+ # This doesn't work yet
2
+ version: "3"
3
+
4
+ services:
5
+ postgres:
6
+ image: postgres
7
+ healthcheck:
8
+ test: psql postgres --command "select 1" -U postgres
9
+ ports:
10
+ - "5432:5432"
11
+ environment:
12
+ POSTGRES_USER: postgres
13
+ POSTGRES_PASSWORD: postgres
14
+ POSTGRES_DB: postgres
15
+
16
+ init-postgres:
17
+ build: .
18
+ depends_on:
19
+ - postgres
20
+ environment:
21
+ DATABASE_ADAPTER: docker_compose_postgres
22
+ PACT_BROKER_HIDE_PACTFLOW_MESSAGES: 'true'
23
+ INSTALL_PG: 'true'
24
+ volumes:
25
+ - ./lib:/home/lib
26
+ - ./db:/home/db
27
+ - ./tasks:/home/tasks
28
+ - ./Rakefile:/home/Rakefile
29
+ - ./config:/home/config
30
+ command: dockerize --wait tcp://postgres:5432 /home/init-db.sh
31
+
32
+ postgres-tests:
33
+ build: .
34
+ depends_on:
35
+ - postgres
36
+ environment:
37
+ DATABASE_ADAPTER: docker_compose_postgres
38
+ PACT_BROKER_HIDE_PACTFLOW_MESSAGES: 'true'
39
+ INSTALL_PG: 'true'
40
+ volumes:
41
+ - ./lib:/home/lib
42
+ - ./spec:/home/spec
43
+ - ./db:/home/db
44
+ - ./config.ru:/home/config.ru
45
+ - ./tasks:/home/tasks
46
+ - ./Rakefile:/home/Rakefile
47
+ - ./config:/home/config
48
+ - ./.rspec:/home/.rspec
49
+ - ./.rubocop:/home/.rubocop
50
+ - ./.gitignore:/home/.gitignore
51
+ - ./public:/home/public
52
+
53
+ mysql:
54
+ image: mysql:5.7.28
55
+ command: --default-authentication-plugin=mysql_native_password
56
+ environment:
57
+ MYSQL_ROOT_PASSWORD: pact_broker
58
+ MYSQL_DATABASE: pact_broker
59
+ MYSQL_USER: pact_broker
60
+ MYSQL_PASSWORD: pact_broker
61
+ ports:
62
+ - "3306:3306"
63
+
64
+ init-mysql:
65
+ build: .
66
+ depends_on:
67
+ - mysql
68
+ environment:
69
+ DATABASE_ADAPTER: docker_compose_mysql
70
+ PACT_BROKER_HIDE_PACTFLOW_MESSAGES: 'true'
71
+ INSTALL_MYSQL: 'true'
72
+ volumes:
73
+ - ./lib:/home/lib
74
+ - ./db:/home/db
75
+ - ./tasks:/home/tasks
76
+ - ./Rakefile:/home/Rakefile
77
+ - ./config:/home/config
78
+ command: dockerize --wait tcp://mysql:3306 /home/init-db.sh
79
+
80
+ mysql-tests:
81
+ build: .
82
+ depends_on:
83
+ - mysql
84
+ environment:
85
+ DATABASE_ADAPTER: docker_compose_mysql
86
+ PACT_BROKER_HIDE_PACTFLOW_MESSAGES: 'true'
87
+ INSTALL_MYSQL: 'true'
88
+ volumes:
89
+ - ./lib:/home/lib
90
+ - ./spec:/home/spec
91
+ - ./db:/home/db
92
+ - ./config.ru:/home/config.ru
93
+ - ./tasks:/home/tasks
94
+ - ./Rakefile:/home/Rakefile
95
+ - ./config:/home/config
96
+ - ./.rspec:/home/.rspec
97
+ - ./.rubocop:/home/.rubocop
98
+ - ./.gitignore:/home/.gitignore
99
+ - ./public:/home/public
100
+