pact_broker 2.76.2 → 2.79.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +12 -0
- data/.github/workflows/release_gem.yml +1 -0
- data/.github/workflows/test-ruby-3.yml +19 -0
- data/.github/workflows/test.yml +16 -7
- data/.gitignore +3 -1
- data/CHANGELOG.md +53 -0
- data/DEVELOPER_DOCUMENTATION.md +13 -0
- data/DEVELOPER_SETUP.md +62 -3
- data/Dockerfile +1 -0
- data/ISSUES.md +7 -7
- data/config.ru +2 -1
- data/db/ddl_statements/head_pact_tags.rb +24 -1
- data/db/ddl_statements/latest_tagged_pact_consumer_version_orders.rb +11 -0
- data/db/ddl_statements/latest_tagged_pact_publications.rb +6 -0
- data/db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb +13 -0
- data/db/migrations/20210117_add_branch_to_version.rb +9 -0
- data/db/migrations/20210202_add_created_at_to_head_pact_tags.rb +14 -0
- data/db/migrations/20210205_add_pacticipant_id_to_tag.rb +17 -0
- data/db/migrations/20210206_add_index_to_tags_and_versions.rb +27 -0
- data/db/migrations/20210207_optimise_latest_verification_ids_for_consumer_version_tags.rb +13 -0
- data/db/migrations/20210208_optimise_latest_tagged_pact_cv_orders.rb +13 -0
- data/db/migrations/20210210_create_environments_table.rb +16 -0
- data/docker-compose-dev-postgres.yml +9 -1
- data/lib/pact_broker/api.rb +7 -2
- data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +8 -0
- data/lib/pact_broker/api/contracts/environment_schema.rb +49 -0
- data/lib/pact_broker/api/decorators/base_decorator.rb +11 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +5 -1
- data/lib/pact_broker/api/decorators/environment_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/environments_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +3 -1
- data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/version_decorator.rb +15 -2
- data/lib/pact_broker/api/pact_broker_urls.rb +8 -0
- data/lib/pact_broker/api/resources/default_base_resource.rb +18 -0
- data/lib/pact_broker/api/resources/environment.rb +76 -0
- data/lib/pact_broker/api/resources/environments.rb +75 -0
- data/lib/pact_broker/api/resources/index.rb +20 -0
- data/lib/pact_broker/api/resources/latest_version.rb +27 -0
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +1 -0
- data/lib/pact_broker/api/resources/version.rb +15 -9
- data/lib/pact_broker/app.rb +1 -1
- data/lib/pact_broker/certificates/certificate.rb +1 -1
- data/lib/pact_broker/config/setting.rb +1 -1
- data/lib/pact_broker/config/space_delimited_integer_list.rb +25 -0
- data/lib/pact_broker/configuration.rb +22 -1
- data/lib/pact_broker/db/data_migrations/helpers.rb +4 -0
- data/lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb +29 -0
- data/lib/pact_broker/db/migrate_data.rb +1 -0
- data/lib/pact_broker/db/seed_example_data.rb +13 -13
- data/lib/pact_broker/deployments/environment.rb +15 -0
- data/lib/pact_broker/deployments/environment_service.rb +39 -0
- data/lib/pact_broker/doc/views/index/environment.markdown +37 -0
- data/lib/pact_broker/doc/views/index/environments.markdown +53 -0
- data/lib/pact_broker/doc/views/index/latest-pact-versions.markdown +1 -1
- data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +1 -0
- data/lib/pact_broker/doc/views/index/pacticipant-version.markdown +13 -0
- data/lib/pact_broker/domain/index_item.rb +18 -4
- data/lib/pact_broker/domain/pacticipant.rb +9 -5
- data/lib/pact_broker/domain/tag.rb +131 -71
- data/lib/pact_broker/domain/verification.rb +3 -2
- data/lib/pact_broker/domain/version.rb +58 -23
- data/lib/pact_broker/domain/webhook.rb +6 -3
- data/lib/pact_broker/index/service.rb +55 -49
- data/lib/pact_broker/locale/en.yml +3 -1
- data/lib/pact_broker/matrix/quick_row.rb +8 -0
- data/lib/pact_broker/metrics/service.rb +1 -1
- data/lib/pact_broker/pacts/eager_loaders.rb +52 -0
- data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +18 -13
- data/lib/pact_broker/pacts/lazy_loaders.rb +14 -0
- data/lib/pact_broker/pacts/pact_publication.rb +38 -84
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +297 -0
- data/lib/pact_broker/pacts/pact_version.rb +1 -2
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +286 -0
- data/lib/pact_broker/pacts/repository.rb +5 -240
- data/lib/pact_broker/pacts/selected_pact.rb +4 -0
- data/lib/pact_broker/pacts/selector.rb +56 -1
- data/lib/pact_broker/pacts/selectors.rb +16 -0
- data/lib/pact_broker/pacts/service.rb +2 -6
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +1 -4
- data/lib/pact_broker/pacts/verifiable_pact.rb +23 -2
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +56 -16
- data/lib/pact_broker/repositories/helpers.rb +4 -0
- data/lib/pact_broker/services.rb +9 -0
- data/lib/pact_broker/tags/eager_loaders.rb +47 -0
- data/lib/pact_broker/tags/repository.rb +3 -1
- data/lib/pact_broker/tags/service.rb +0 -3
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +1 -0
- data/lib/pact_broker/test/http_test_data_builder.rb +23 -7
- data/lib/pact_broker/test/test_data_builder.rb +50 -3
- data/lib/pact_broker/ui/view_models/index_item.rb +19 -2
- data/lib/pact_broker/ui/view_models/matrix_line.rb +38 -2
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +14 -6
- data/lib/pact_broker/ui/views/matrix/show.haml +12 -2
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +7 -5
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/eager_loaders.rb +71 -0
- data/lib/pact_broker/versions/lazy_loaders.rb +13 -0
- data/lib/pact_broker/versions/repository.rb +22 -2
- data/lib/pact_broker/versions/service.rb +5 -1
- data/lib/pact_broker/webhooks/execution.rb +3 -2
- data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +2 -0
- data/lib/pact_broker/webhooks/triggered_webhook.rb +11 -4
- data/lib/pact_broker/webhooks/webhook.rb +1 -1
- data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
- data/lib/pact_broker/webhooks/webhook_execution_result.rb +6 -1
- data/lib/pact_broker/webhooks/webhook_request_logger.rb +7 -1
- data/lib/rack/pact_broker/set_base_url.rb +35 -5
- data/lib/sequel/plugins/upsert.rb +18 -4
- data/pact_broker.gemspec +1 -1
- data/public/javascripts/clipboard.js +8 -2
- data/public/stylesheets/index.css +26 -2
- data/public/stylesheets/matrix.css +0 -21
- data/regression/can_i_deploy_spec.rb +5 -4
- data/regression/index_spec.rb +26 -0
- data/regression/regression_helper.rb +29 -3
- data/regression/script/clear.sh +3 -0
- data/regression/script/run.sh +3 -0
- data/script/demonstrate-version-branches.rb +33 -0
- data/script/pry.rb +2 -2
- data/spec/features/create_environment_spec.rb +47 -0
- data/spec/features/create_tag_spec.rb +32 -0
- data/spec/features/create_version_spec.rb +70 -0
- data/spec/features/delete_environment_spec.rb +16 -0
- data/spec/features/end_deployment_spec.rb +29 -0
- data/spec/features/get_environment_spec.rb +19 -0
- data/spec/features/get_environments_spec.rb +20 -0
- data/spec/features/record_deployment_spec.rb +28 -0
- data/spec/features/update_environment_spec.rb +44 -0
- data/spec/fixtures/approvals/modifiable_resources.approved.json +6 -0
- data/spec/fixtures/dashboard.json +4 -2
- data/spec/lib/pact_broker/api/contracts/environment_schema_spec.rb +83 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +4 -2
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +11 -6
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +6 -0
- data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +18 -0
- data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +4 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
- data/spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb +47 -0
- data/spec/lib/pact_broker/configuration_spec.rb +12 -0
- data/spec/lib/pact_broker/domain/tag_spec.rb +101 -27
- data/spec/lib/pact_broker/domain/version_spec.rb +103 -15
- data/spec/lib/pact_broker/domain/webhook_spec.rb +1 -1
- data/spec/lib/pact_broker/index/service_spec.rb +89 -15
- data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +400 -0
- data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +434 -14
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_branch_spec.rb +224 -0
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +20 -7
- data/spec/lib/pact_broker/pacts/selector_spec.rb +3 -2
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +2 -3
- data/spec/lib/pact_broker/pacts/service_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +57 -10
- data/spec/lib/pact_broker/tags/repository_spec.rb +2 -0
- data/spec/lib/pact_broker/versions/repository_spec.rb +54 -0
- data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +8 -0
- data/spec/lib/rack/pact_broker/set_base_url_spec.rb +86 -0
- data/spec/lib/sequel/plugins/upsert_spec.rb +31 -3
- data/spec/migrations/change_migration_strategy_spec.rb +3 -3
- data/spec/service_consumers/hal_relation_proxy_app.rb +3 -1
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +16 -0
- data/spec/spec_helper.rb +17 -5
- data/spec/support/approvals.rb +24 -0
- data/spec/support/shared_examples_for_responses.rb +11 -0
- data/tasks/database.rb +1 -1
- data/tasks/db.rake +1 -0
- data/tasks/rspec.rake +1 -1
- data/vendor/hal-browser/styles.css +6 -0
- metadata +70 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95badfada259b53967395cf6851ae3c73524f840f03f458c8ddaee800b43e8b7
|
4
|
+
data.tar.gz: dc0168aa2af112bc896e55ae32b5e3e9c4bf4531eec51908a8acc5a6c38068d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 286e176364f2c583e6751aaa4c85205eefb6823994e65eff24494cb78318fb391f0ad96cc478162f078fabacda071893c546c789788197e18ef9d61c46a3d65f
|
7
|
+
data.tar.gz: 80a06b3f6aba77993311f46d8d558132d1d61d8922725d219d08352c78dd6e27fd799e03fd283b183edb8c0973974fe115212eadabe130f785a007d5289c0444
|
data/.codeclimate.yml
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
---
|
2
|
+
checks:
|
3
|
+
argument-count:
|
4
|
+
config:
|
5
|
+
threshold: 6
|
6
|
+
method-count:
|
7
|
+
config:
|
8
|
+
threshold: 40
|
9
|
+
similar-code:
|
10
|
+
enabled: false
|
2
11
|
engines:
|
3
12
|
csslint:
|
4
13
|
enabled: true
|
@@ -35,3 +44,6 @@ exclude_patterns:
|
|
35
44
|
- public/javascripts/highlight.pack.js
|
36
45
|
- public/javascripts/jquery*.js
|
37
46
|
- public/js/bootstrap*.js
|
47
|
+
- public/javascripts/pagination.js
|
48
|
+
- public/javascripts/material-menu.js
|
49
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Tests for Ruby 3.0 - these are hardcoded to succeed so every commit doesn't look like it's failing
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
sqlite:
|
7
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
8
|
+
runs-on: "ubuntu-latest"
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby_version: ["3.0"]
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby_version }}
|
18
|
+
- run: "bundle install"
|
19
|
+
- run: "bundle exec rake || true"
|
data/.github/workflows/test.yml
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
name: Test
|
2
2
|
|
3
|
-
on: push
|
3
|
+
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
sqlite:
|
7
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
7
8
|
runs-on: "ubuntu-latest"
|
8
|
-
continue-on-error: ${{ matrix.experimental }}
|
9
9
|
strategy:
|
10
10
|
fail-fast: false
|
11
11
|
matrix:
|
12
12
|
ruby_version: ["2.7"]
|
13
|
-
experimental: [false]
|
14
|
-
include:
|
15
|
-
- ruby_version: "3.0"
|
16
|
-
experimental: true
|
17
13
|
steps:
|
18
14
|
- uses: actions/checkout@v2
|
19
15
|
- uses: ruby/setup-ruby@v1
|
20
16
|
with:
|
21
17
|
ruby-version: ${{ matrix.ruby_version }}
|
22
18
|
- run: "bundle install"
|
23
|
-
-
|
19
|
+
- name: "Install CodeClimate Test Reporter"
|
20
|
+
run: |
|
21
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
22
|
+
chmod +x ./cc-test-reporter
|
23
|
+
- name: Tests
|
24
|
+
run: bundle exec rake
|
25
|
+
- name: Report test coverage
|
26
|
+
run: ./cc-test-reporter after-build --exit-code 0 || true
|
27
|
+
env:
|
28
|
+
CC_TEST_REPORTER_ID: dc2c30b67c9e2a5309e1aef699c30fdab55ba4f0e4f1beac029ba93e293835db
|
24
29
|
postgres:
|
30
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
25
31
|
runs-on: "ubuntu-latest"
|
26
32
|
strategy:
|
33
|
+
fail-fast: false
|
27
34
|
matrix:
|
28
35
|
ruby_version: ["2.5", "2.7"]
|
29
36
|
services:
|
@@ -51,8 +58,10 @@ jobs:
|
|
51
58
|
DATABASE_ADAPTER: github_actions_postgres
|
52
59
|
INSTALL_PG: "true"
|
53
60
|
mysql:
|
61
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
54
62
|
runs-on: "ubuntu-latest"
|
55
63
|
strategy:
|
64
|
+
fail-fast: false
|
56
65
|
matrix:
|
57
66
|
ruby_version: ["2.7"]
|
58
67
|
steps:
|
data/.gitignore
CHANGED
@@ -39,4 +39,6 @@ db/test/change_migration_strategy/pact_broker_database.sqlite3
|
|
39
39
|
coverage
|
40
40
|
db/test/backwards_compatibility/pids
|
41
41
|
db/test/backwards_compatibility/pact_broker_database.sqlite3
|
42
|
-
spec/examples.txt
|
42
|
+
spec/examples.txt
|
43
|
+
.approvals
|
44
|
+
regression/fixtures/approvals
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,56 @@
|
|
1
|
+
<a name="v2.79.1"></a>
|
2
|
+
### v2.79.1 (2021-03-01)
|
3
|
+
|
4
|
+
#### Bug Fixes
|
5
|
+
|
6
|
+
* lock reform gem ([53aa92f8](/../../commit/53aa92f8))
|
7
|
+
|
8
|
+
* **ui**
|
9
|
+
* Make long pacticipant versions look nice (#407) ([96b50572](/../../commit/96b50572))
|
10
|
+
|
11
|
+
<a name="v2.79.0"></a>
|
12
|
+
### v2.79.0 (2021-02-25)
|
13
|
+
|
14
|
+
#### Features
|
15
|
+
|
16
|
+
* allow multiple base URLs to be configured ([6d0dc8b3](/../../commit/6d0dc8b3))
|
17
|
+
* copy full git sha rather than abbreviated one when clicking the copy button next to an application version ([dae9cae5](/../../commit/dae9cae5))
|
18
|
+
|
19
|
+
#### Bug Fixes
|
20
|
+
|
21
|
+
* fix missing verification status colours in matrix rows ([687d4647](/../../commit/687d4647))
|
22
|
+
|
23
|
+
<a name="v2.78.1"></a>
|
24
|
+
### v2.78.1 (2021-02-18)
|
25
|
+
|
26
|
+
#### Bug Fixes
|
27
|
+
|
28
|
+
* handle nil response when determining webhook success status ([20ca9e66](/../../commit/20ca9e66))
|
29
|
+
|
30
|
+
<a name="v2.78.0"></a>
|
31
|
+
### v2.78.0 (2021-02-15)
|
32
|
+
|
33
|
+
#### Features
|
34
|
+
|
35
|
+
* support create, update and delete of environment resources (#379) ([410f2e80](/../../commit/410f2e80))
|
36
|
+
* allow version to be created with tags ([798afce9](/../../commit/798afce9))
|
37
|
+
* Follow up for #239 + adding list of success codes to SAVABLE_SETTING_NAMES variable (#388) ([08c0ad09](/../../commit/08c0ad09))
|
38
|
+
|
39
|
+
<a name="v2.77.0"></a>
|
40
|
+
### v2.77.0 (2021-02-11)
|
41
|
+
|
42
|
+
#### Features
|
43
|
+
|
44
|
+
* **webhooks**
|
45
|
+
* allow the http codes to be considered as "successful" to be configured. ([a84989b1](/../../commit/a84989b1))
|
46
|
+
|
47
|
+
* add duplicate columns to tags table to reduce joins ([5ca9de62](/../../commit/5ca9de62))
|
48
|
+
* set the branch in the seed data ([9a00ce6d](/../../commit/9a00ce6d))
|
49
|
+
* display version branch on index and matrix pages ([2057df7d](/../../commit/2057df7d))
|
50
|
+
* support creating version with branch (#371) ([5884a047](/../../commit/5884a047))
|
51
|
+
* sort tags on index and matrix pages and APIs by creation date ([91590718](/../../commit/91590718))
|
52
|
+
* sort consumer version tags by date in dashboard response ([f82ba1bc](/../../commit/f82ba1bc))
|
53
|
+
|
1
54
|
<a name="v2.76.2"></a>
|
2
55
|
### v2.76.2 (2021-01-29)
|
3
56
|
|
data/DEVELOPER_DOCUMENTATION.md
CHANGED
@@ -148,3 +148,16 @@ In the beginning, I made a lot of Sequel models based on views that pulled in th
|
|
148
148
|
* Write a spec for the repository.
|
149
149
|
* Go back and make the original feature spec pass.
|
150
150
|
* Profit.
|
151
|
+
|
152
|
+
## Writing Data migrations
|
153
|
+
|
154
|
+
The same database may be used by multiple application instances to support highly available set ups and no downtime deployments. This can lead to the situation where the database migrations have been applied, but new data is written to the database by old application code, which may lead to some columns not being populated. The mitigation to this problem is to run the *data* migrations only each time an application instance starts up. This ensures that that any data inserted into the database by a previous version of the application are migrated. This is done automatically in the `PactBroker::App` class.
|
155
|
+
|
156
|
+
If you write a schema migration that then requires a data migration to populate or update any columns:
|
157
|
+
|
158
|
+
* Create a data migrations class in `lib/pact_broker/db/data_migrations`, copying the existing pattern.
|
159
|
+
* Add a call to the new class at the end of `lib/pact_broker/db/migrate_data.rb`
|
160
|
+
* Make sure you check for the existance of the required columns, because you don't know which version of the database might be running with this code.
|
161
|
+
* Add a null check (eg. `db[:my_table].where(my_column: nil).update(...)`) where appropriate to make sure that the data migration doesn't run more than once.
|
162
|
+
* Don't use any Sequel Models, as this will run before the model classes are loaded, and migrations should never depend on Models because models change as the schema migrations are applied.
|
163
|
+
* Create a migration file in `db/migrations` that calls the data migration (eg. like `db/migrations/20190603_migrate_webhook_headers.rb`)
|
data/DEVELOPER_SETUP.md
CHANGED
@@ -36,7 +36,7 @@ Remember to rebuild the image if you change any of the gems or gem versions.
|
|
36
36
|
|
37
37
|
### With native install
|
38
38
|
|
39
|
-
* You will need to install Ruby 2.
|
39
|
+
* You will need to install Ruby 2.7, and preferably a ruby version manager. I recommend using [chruby][chruby] and [ruby-install][ruby-install].
|
40
40
|
* Install bundler (the Ruby gem dependency manager) `gem install bundler`
|
41
41
|
* Check out the pact_broker repository and cd into it.
|
42
42
|
* Run `bundle install`. If you have any gem conflict issues, run `bundle update`.
|
@@ -75,17 +75,27 @@ Running a mysql client in the mysql-tests container:
|
|
75
75
|
mysql -hmysql -upact_broker -ppact_broker
|
76
76
|
```
|
77
77
|
|
78
|
+
Running a postgresql client in the postgres-tests container:
|
79
|
+
|
80
|
+
```
|
81
|
+
psql postgres://postgres:postgres@postgres/postgres
|
82
|
+
```
|
83
|
+
|
78
84
|
## Running the tests
|
79
85
|
|
80
86
|
* To run everything (specs, pact verifications, vulnerability scan...):
|
81
87
|
```sh
|
82
88
|
bundle exec rake
|
83
89
|
```
|
90
|
+
* To set up the database (this is done automatically when running the default rake task, but if you want to run a different task without running the default task first, this must be run once beforehand):
|
91
|
+
```sh
|
92
|
+
bundle exec rake db:prepare:test
|
93
|
+
```
|
84
94
|
* To run a smaller subset of the tests:
|
85
95
|
```sh
|
86
96
|
bundle exec rake spec
|
87
97
|
```
|
88
|
-
* To run the "quick tests" (skip the lengthy migration specs)
|
98
|
+
* To run the "quick tests" (skip the lengthy migration specs and db setup)
|
89
99
|
```sh
|
90
100
|
bundle exec rake spec:quick
|
91
101
|
```
|
@@ -94,7 +104,56 @@ mysql -hmysql -upact_broker -ppact_broker
|
|
94
104
|
bundle exec rspec path_to_your_spec.rb
|
95
105
|
```
|
96
106
|
|
97
|
-
|
107
|
+
## Running the regression tests
|
108
|
+
|
109
|
+
The regression tests record a series of API requests/responses using a real exported database (not included in the git repository because of the size) and store the expectations in files using the Approvals gem. They allow you to make sure that the changes you have made have not made any (unexpected) changes to the interface.
|
110
|
+
|
111
|
+
The tests and files are stored in the [regression](regression) directory.
|
112
|
+
|
113
|
+
To run:
|
114
|
+
|
115
|
+
1. Set up your local development environment as described above, making sure you have `INSTALL_PG=true` exported in your shell.
|
116
|
+
|
117
|
+
1. Make sure you have the master branch checked out.
|
118
|
+
|
119
|
+
1. Load an exported real database into a postgres docker image. The exported file must be in the pg dump format to use this script, and it must be located in the project root directory for it to be found via the mounted directory.
|
120
|
+
|
121
|
+
```
|
122
|
+
script/docker/reload.sh <export>
|
123
|
+
|
124
|
+
```
|
125
|
+
1. Clear any previously generated approvals.
|
126
|
+
|
127
|
+
```
|
128
|
+
regression/script/clear.sh
|
129
|
+
```
|
130
|
+
|
131
|
+
1. Run the tests. They will fail because there are no approval files yet.
|
132
|
+
|
133
|
+
```
|
134
|
+
regression/script/run.sh
|
135
|
+
```
|
136
|
+
|
137
|
+
1. Approval all the things.
|
138
|
+
|
139
|
+
```
|
140
|
+
regression/script/approval-all.sh
|
141
|
+
```
|
142
|
+
|
143
|
+
1. Run the tests again to make sure that the same results can be expected each time.
|
144
|
+
|
145
|
+
```
|
146
|
+
regression/script/run.sh
|
147
|
+
```
|
148
|
+
|
149
|
+
1. Check out the feature branch (or enable the feature toggle)
|
150
|
+
|
151
|
+
1. Run the tests again.
|
152
|
+
```
|
153
|
+
regression/script/run.sh
|
154
|
+
```
|
155
|
+
|
156
|
+
1. If there is a diff, you can set `SHOW_REGRESSION_DIFF=true`, but the output is quite noisy, and you're probably better off using diff or diffmerge to view the differences.
|
98
157
|
|
99
158
|
[chruby]: https://github.com/postmodern/chruby
|
100
159
|
[ruby-install]: https://github.com/postmodern/ruby-install
|
data/Dockerfile
CHANGED
data/ISSUES.md
CHANGED
@@ -2,29 +2,29 @@
|
|
2
2
|
|
3
3
|
## Reproducing an issue
|
4
4
|
|
5
|
-
In [script/reproduce-issue.rb](script/reproduce-issue.rb) you will find
|
5
|
+
In [script/reproduce-issue.rb](script/reproduce-issue.rb) you will find an example fluent API script that allows you to simulate client libraries interacting with the Pact Broker.
|
6
6
|
|
7
|
-
You can use it to easily reproduce issues.
|
7
|
+
You can use it to easily reproduce issues. You will need Docker and Docker Compose installed (but not Ruby).
|
8
8
|
|
9
9
|
To use it:
|
10
10
|
|
11
11
|
* Run the Pact Broker using a specific Pact Broker Docker image by setting the required tag for the pact-broker service in the docker-compose-issue-repro-with-pact-broker-docker-image.yml file.
|
12
12
|
|
13
13
|
```
|
14
|
-
|
14
|
+
git clone git@github.com:pact-foundation/pact_broker.git
|
15
|
+
cd pact_broker
|
16
|
+
|
15
17
|
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up pact-broker
|
16
18
|
|
17
|
-
# if needing webhooks - new window
|
19
|
+
# if needing webhooks - run this in a new window so the logs are clearer
|
18
20
|
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up webhook-server
|
19
21
|
|
20
|
-
# new window
|
21
|
-
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml run repro-issue
|
22
|
-
|
23
22
|
```
|
24
23
|
|
25
24
|
* Run the reproduction script.
|
26
25
|
|
27
26
|
```
|
27
|
+
# in a new shell
|
28
28
|
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml run repro-issue
|
29
29
|
```
|
30
30
|
|
data/config.ru
CHANGED
@@ -26,7 +26,8 @@ app = PactBroker::App.new do | config |
|
|
26
26
|
config.webhook_host_whitelist = [/.*/, "10.0.0.0/8"]
|
27
27
|
config.webhook_scheme_whitelist = ['http', 'https']
|
28
28
|
config.webhook_http_method_whitelist = ['GET', 'POST']
|
29
|
-
|
29
|
+
config.webhook_http_code_success = [200, 201, 202, 203, 204, 205, 206]
|
30
|
+
config.base_url = ENV['PACT_BROKER_BASE_URL']
|
30
31
|
|
31
32
|
database_logger = PactBroker::DB::LogQuietener.new(config.logger)
|
32
33
|
config.database_connection = Sequel.connect(DATABASE_URL, DB_OPTIONS.merge(logger: database_logger))
|
@@ -5,6 +5,29 @@ def head_pact_tags_v1(connection)
|
|
5
5
|
Sequel[:lp][:consumer_id] => Sequel[:o][:consumer_id],
|
6
6
|
Sequel[:lp][:provider_id] => Sequel[:o][:provider_id],
|
7
7
|
Sequel[:cv][:order] => Sequel[:o][:latest_consumer_version_order]
|
8
|
-
}, { table_alias: :o})
|
8
|
+
}, { table_alias: :o })
|
9
9
|
.select(Sequel[:o][:tag_name].as(:name), Sequel[:lp][:pact_publication_id])
|
10
10
|
end
|
11
|
+
|
12
|
+
def head_pact_tags_v2_rollback(connection, postgres)
|
13
|
+
if(postgres)
|
14
|
+
head_pact_tags_v1(connection).select_append(Sequel.lit("TIMESTAMP 'epoch'").as(:created_at))
|
15
|
+
else
|
16
|
+
head_pact_tags_v1(connection)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def head_pact_tags_v2(connection)
|
21
|
+
connection.from(Sequel.as(:latest_pact_publication_ids_for_consumer_versions, :lp))
|
22
|
+
.join(:versions,{ Sequel[:lp][:consumer_version_id] => Sequel[:cv][:id]}, { table_alias: :cv })
|
23
|
+
.join(:latest_tagged_pact_consumer_version_orders, {
|
24
|
+
Sequel[:lp][:consumer_id] => Sequel[:o][:consumer_id],
|
25
|
+
Sequel[:lp][:provider_id] => Sequel[:o][:provider_id],
|
26
|
+
Sequel[:cv][:order] => Sequel[:o][:latest_consumer_version_order]
|
27
|
+
}, { table_alias: :o } )
|
28
|
+
.join(:tags, {
|
29
|
+
Sequel[:tags][:version_id] => Sequel[:cv][:id],
|
30
|
+
Sequel[:tags][:name] => Sequel[:o][:tag_name]
|
31
|
+
})
|
32
|
+
.select(Sequel[:o][:tag_name].as(:name), Sequel[:lp][:pact_publication_id], Sequel[:tags][:created_at])
|
33
|
+
end
|
@@ -21,3 +21,14 @@ def latest_tagged_pact_consumer_version_orders_v3(connection)
|
|
21
21
|
.join(:versions, { Sequel[:lp][:consumer_version_id] => Sequel[:cv][:id] }, { table_alias: :cv} )
|
22
22
|
.join(:tags, { Sequel[:t][:version_id] => Sequel[:lp][:consumer_version_id] }, { table_alias: :t })
|
23
23
|
end
|
24
|
+
|
25
|
+
def latest_tagged_pact_consumer_version_orders_v4(connection)
|
26
|
+
view = Sequel.as(:latest_pact_publication_ids_for_consumer_versions, :lp)
|
27
|
+
connection.from(view)
|
28
|
+
.select_group(
|
29
|
+
Sequel[:lp][:provider_id],
|
30
|
+
Sequel[:lp][:consumer_id],
|
31
|
+
Sequel[:t][:name].as(:tag_name))
|
32
|
+
.select_append{ max(version_order).as(latest_consumer_version_order) }
|
33
|
+
.join(:tags, { Sequel[:t][:version_id] => Sequel[:lp][:consumer_version_id] }, { table_alias: :t })
|
34
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
LATEST_TAGGED_PACT_PUBLICATIONS = "select lp.*, o.tag_name
|
2
|
+
from latest_pact_publications_by_consumer_versions lp
|
3
|
+
inner join latest_tagged_pact_consumer_version_orders o
|
4
|
+
on lp.consumer_id = o.consumer_id
|
5
|
+
and lp.provider_id = o.provider_id
|
6
|
+
and lp.consumer_version_order = latest_consumer_version_order"
|
@@ -51,3 +51,16 @@ LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V3 = "select
|
|
51
51
|
on v.provider_version_id = pv.id
|
52
52
|
where v.id in (select latest_verification_id from latest_verification_ids_for_pact_versions)
|
53
53
|
group by pv.pacticipant_id, lpp.consumer_id, t.name"
|
54
|
+
|
55
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V4 = "select
|
56
|
+
lpp.provider_id,
|
57
|
+
lpp.consumer_id,
|
58
|
+
t.name as consumer_version_tag_name,
|
59
|
+
max(lv.latest_verification_id) as latest_verification_id
|
60
|
+
from latest_verification_ids_for_pact_versions lv
|
61
|
+
join latest_pact_publication_ids_for_consumer_versions lpp
|
62
|
+
on lv.pact_version_id = lpp.pact_version_id
|
63
|
+
join tags t
|
64
|
+
on lpp.consumer_version_id = t.version_id
|
65
|
+
group by lpp.provider_id, lpp.consumer_id, t.name
|
66
|
+
"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../ddl_statements'
|
2
|
+
require_relative 'migration_helper'
|
3
|
+
|
4
|
+
include PactBroker::MigrationHelper
|
5
|
+
|
6
|
+
Sequel.migration do
|
7
|
+
up do
|
8
|
+
create_or_replace_view(:head_pact_tags, head_pact_tags_v2(self))
|
9
|
+
end
|
10
|
+
|
11
|
+
down do
|
12
|
+
create_or_replace_view(:head_pact_tags, head_pact_tags_v2_rollback(self, postgres?))
|
13
|
+
end
|
14
|
+
end
|