pact_broker 2.75.0 → 2.78.0
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/test-ruby-3.yml +19 -0
- data/.github/workflows/test.yml +19 -4
- data/.gitignore +3 -1
- data/CHANGELOG.md +48 -0
- data/DEVELOPER_SETUP.md +62 -3
- data/Dockerfile +1 -0
- data/ISSUES.md +13 -5
- data/README.md +1 -1
- data/config.ru +1 -0
- 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-issue-repro-with-pact-broker-docker-image.yml +44 -0
- 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 +8 -2
- data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -2
- 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/paths.rb +5 -0
- data/lib/pact_broker/api/resources/default_base_resource.rb +15 -2
- 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/verifications.rb +5 -2
- data/lib/pact_broker/api/resources/version.rb +15 -9
- data/lib/pact_broker/api/resources/webhook_execution.rb +1 -1
- data/lib/pact_broker/app.rb +3 -0
- 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 +18 -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/controllers/app.rb +1 -1
- 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 +12 -9
- data/lib/pact_broker/hash_refinements.rb +4 -0
- 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 -231
- 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 +6 -8
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +1 -4
- data/lib/pact_broker/pacts/verifiable_pact.rb +45 -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 +101 -35
- data/lib/pact_broker/test/test_data_builder.rb +50 -3
- data/lib/pact_broker/ui/app.rb +6 -0
- data/lib/pact_broker/ui/controllers/base_controller.rb +5 -1
- data/lib/pact_broker/ui/controllers/pacts.rb +18 -0
- data/lib/pact_broker/ui/view_models/index_item.rb +9 -0
- data/lib/pact_broker/ui/view_models/matrix_line.rb +36 -0
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +8 -0
- data/lib/pact_broker/ui/views/matrix/show.haml +10 -0
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +7 -5
- data/lib/pact_broker/verifications/service.rb +2 -1
- 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/pact_and_verification_parameters.rb +10 -3
- data/lib/pact_broker/webhooks/service.rb +8 -7
- data/lib/pact_broker/webhooks/trigger_service.rb +56 -23
- data/lib/pact_broker/webhooks/triggered_webhook.rb +14 -5
- 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 +4 -1
- data/lib/pact_broker/webhooks/webhook_request_logger.rb +5 -1
- data/lib/rack/pact_broker/set_base_url.rb +22 -0
- data/lib/sequel/plugins/upsert.rb +18 -4
- data/public/stylesheets/index.css +22 -1
- 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/script/reproduce-issue-starting-up.rb +13 -23
- data/script/reproduce-issue.rb +18 -14
- data/script/trigger-release.sh +1 -1
- data/script/webhook-server.ru +5 -5
- 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/integration/ui/index_spec.rb +4 -4
- 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/reason_decorator_spec.rb +6 -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/default_base_resource_spec.rb +1 -12
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +4 -0
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +2 -5
- data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +3 -2
- 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/doc/controllers/app_spec.rb +3 -5
- 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 +7 -7
- 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 +46 -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 +9 -7
- 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/verifications/service_spec.rb +4 -1
- data/spec/lib/pact_broker/versions/repository_spec.rb +54 -0
- data/spec/lib/pact_broker/webhooks/render_spec.rb +6 -5
- data/spec/lib/pact_broker/webhooks/service_spec.rb +13 -9
- data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +60 -18
- data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +8 -0
- data/spec/lib/sequel/plugins/upsert_spec.rb +31 -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/db.rake +1 -0
- data/tasks/rspec.rake +1 -1
- metadata +69 -4
- data/docker-compose-issue-repro.yml +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4260e4320105662bc678b63a94054f7485609557b2e967e58ac59512fca69f81
|
4
|
+
data.tar.gz: 4d40a31b9f93c9e08a67e2b1e50cff0fc0c59e0344d3a8672b629d425a93444a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2dec2c3934c80e7edf5d85370aecf511e8ce8e403486c964182b8f2f397f91bdad7ac886c1dd2955f6d4c9cac52bbac81c22b89d824d7d19fe57d224715ecb5
|
7
|
+
data.tar.gz: 8d60c2beaa8719efe9bfd7551ddda158d4c4f06cdf92884fdbb1312e8a7a306b5fc5754f5f467bd922e688eb37c899ea60c1758de48fce7696553ee57b84fd32
|
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,23 +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
9
|
strategy:
|
10
|
+
fail-fast: false
|
9
11
|
matrix:
|
10
12
|
ruby_version: ["2.7"]
|
11
13
|
steps:
|
12
14
|
- uses: actions/checkout@v2
|
13
|
-
- uses:
|
15
|
+
- uses: ruby/setup-ruby@v1
|
14
16
|
with:
|
15
17
|
ruby-version: ${{ matrix.ruby_version }}
|
16
18
|
- run: "bundle install"
|
17
|
-
-
|
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
|
18
29
|
postgres:
|
30
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
19
31
|
runs-on: "ubuntu-latest"
|
20
32
|
strategy:
|
33
|
+
fail-fast: false
|
21
34
|
matrix:
|
22
35
|
ruby_version: ["2.5", "2.7"]
|
23
36
|
services:
|
@@ -34,7 +47,7 @@ jobs:
|
|
34
47
|
- 5432:5432
|
35
48
|
steps:
|
36
49
|
- uses: actions/checkout@v2
|
37
|
-
- uses:
|
50
|
+
- uses: ruby/setup-ruby@v1
|
38
51
|
with:
|
39
52
|
ruby-version: ${{ matrix.ruby_version }}
|
40
53
|
- run: "gem install bundler && bundle install"
|
@@ -45,8 +58,10 @@ jobs:
|
|
45
58
|
DATABASE_ADAPTER: github_actions_postgres
|
46
59
|
INSTALL_PG: "true"
|
47
60
|
mysql:
|
61
|
+
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
48
62
|
runs-on: "ubuntu-latest"
|
49
63
|
strategy:
|
64
|
+
fail-fast: false
|
50
65
|
matrix:
|
51
66
|
ruby_version: ["2.7"]
|
52
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,51 @@
|
|
1
|
+
<a name="v2.78.0"></a>
|
2
|
+
### v2.78.0 (2021-02-15)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* support create, update and delete of environment resources (#379) ([410f2e80](/../../commit/410f2e80))
|
7
|
+
* allow version to be created with tags ([798afce9](/../../commit/798afce9))
|
8
|
+
* Follow up for #239 + adding list of success codes to SAVABLE_SETTING_NAMES variable (#388) ([08c0ad09](/../../commit/08c0ad09))
|
9
|
+
|
10
|
+
<a name="v2.77.0"></a>
|
11
|
+
### v2.77.0 (2021-02-11)
|
12
|
+
|
13
|
+
#### Features
|
14
|
+
|
15
|
+
* **webhooks**
|
16
|
+
* allow the http codes to be considered as "successful" to be configured. ([a84989b1](/../../commit/a84989b1))
|
17
|
+
|
18
|
+
* add duplicate columns to tags table to reduce joins ([5ca9de62](/../../commit/5ca9de62))
|
19
|
+
* set the branch in the seed data ([9a00ce6d](/../../commit/9a00ce6d))
|
20
|
+
* display version branch on index and matrix pages ([2057df7d](/../../commit/2057df7d))
|
21
|
+
* support creating version with branch (#371) ([5884a047](/../../commit/5884a047))
|
22
|
+
* sort tags on index and matrix pages and APIs by creation date ([91590718](/../../commit/91590718))
|
23
|
+
* sort consumer version tags by date in dashboard response ([f82ba1bc](/../../commit/f82ba1bc))
|
24
|
+
|
25
|
+
<a name="v2.76.2"></a>
|
26
|
+
### v2.76.2 (2021-01-29)
|
27
|
+
|
28
|
+
#### Bug Fixes
|
29
|
+
|
30
|
+
* trigger one webhook for each pact publication that the verified content belongs to when using the 'pacts for verification' API (#378) ([114ccad0](/../../commit/114ccad0))
|
31
|
+
|
32
|
+
<a name="v2.76.1"></a>
|
33
|
+
### v2.76.1 (2021-01-28)
|
34
|
+
|
35
|
+
#### Bug Fixes
|
36
|
+
|
37
|
+
* deduplicate wip pacts by content ([0af90776](/../../commit/0af90776))
|
38
|
+
* message when pending pact is verified successfully for the first time (#376) ([4fc69190](/../../commit/4fc69190))
|
39
|
+
* use base URL from rack env in UI ([5bf21324](/../../commit/5bf21324))
|
40
|
+
|
41
|
+
<a name="v2.76.0"></a>
|
42
|
+
### v2.76.0 (2021-01-21)
|
43
|
+
|
44
|
+
#### Features
|
45
|
+
|
46
|
+
* **verification results**
|
47
|
+
* redirect requests for verification results to the HAL browser if requested in a web browser ([0f948de5](/../../commit/0f948de5))
|
48
|
+
|
1
49
|
<a name="v2.75.0"></a>
|
2
50
|
### v2.75.0 (2021-01-18)
|
3
51
|
|
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,22 +2,30 @@
|
|
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
|
-
* Run the Pact Broker using the
|
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
|
+
|
17
|
+
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up pact-broker
|
18
|
+
|
19
|
+
# if needing webhooks - run this in a new window so the logs are clearer
|
20
|
+
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up webhook-server
|
21
|
+
|
15
22
|
```
|
16
23
|
|
17
24
|
* Run the reproduction script.
|
18
25
|
|
19
26
|
```
|
20
|
-
|
27
|
+
# in a new shell
|
28
|
+
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml run repro-issue
|
21
29
|
```
|
22
30
|
|
23
31
|
You can modify `script/reproduce-issue.rb` and then re-run it with the change applied.
|
data/README.md
CHANGED
@@ -116,7 +116,7 @@ Use the HAL browser to view documentation as you browse.
|
|
116
116
|
|
117
117
|
### To have a play around on your local machine
|
118
118
|
|
119
|
-
* Install
|
119
|
+
* Install Ruby and Bundler (check the automated tests to find the most recent version of Ruby and Bundler that are supported)
|
120
120
|
* Windows users: get a Rails/Ruby installer from [RailsInstaller](http://railsinstaller.org/) and run it
|
121
121
|
* unix users just use your package manager
|
122
122
|
* Run `git clone git@github.com:pact-foundation/pact_broker.git && cd pact_broker/example`
|
data/config.ru
CHANGED
@@ -26,6 +26,7 @@ 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
|
+
config.webhook_http_code_success = [200, 201, 202, 203, 204, 205, 206]
|
29
30
|
#config.base_url = ENV['PACT_BROKER_BASE_URL']
|
30
31
|
|
31
32
|
database_logger = PactBroker::DB::LogQuietener.new(config.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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'migration_helper'
|
2
|
+
|
3
|
+
include PactBroker::MigrationHelper
|
4
|
+
|
5
|
+
Sequel.migration do
|
6
|
+
change do
|
7
|
+
alter_table(:tags) do
|
8
|
+
# TODO set_column_not_null(:pacticipant_id)
|
9
|
+
# TODO set_column_not_null(:version_order)
|
10
|
+
add_column(:pacticipant_id, Integer)
|
11
|
+
add_column(:version_order, Integer)
|
12
|
+
add_index(:version_order, name: "tags_version_order_index")
|
13
|
+
add_index(:version_id, name: "tags_version_id_index")
|
14
|
+
add_index(:pacticipant_id, name: "tags_pacticipant_id_index")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|