Skip to content

Commit 000f50e

Browse files
committed
chore: publish and verify with branches not tags
1 parent d1ea974 commit 000f50e

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ pact {
10841084
pactBrokerUrl = 'http://localhost:8000/'
10851085
pactBrokerUsername = getOrDefault('PACT_BROKER_USERNAME', 'pact_workshop')
10861086
pactBrokerPassword = getOrDefault('PACT_BROKER_PASSWORD', 'pact_workshop')
1087-
tags = [getGitBranch(), 'test', 'prod']
1087+
consumerBranch = getGitBranch()
10881088
consumerVersion = getGitHash()
10891089
}
10901090
}
@@ -1150,9 +1150,9 @@ def getGitBranch = { ->
11501150
test {
11511151
useJUnitPlatform()
11521152
1153+
systemProperty 'pact.provider.branch', getGitBranch()
11531154
if (System.getProperty('pactPublishResults') == 'true') {
11541155
systemProperty 'pact.provider.version', getGitHash()
1155-
systemProperty 'pact.provider.tag', getGitBranch()
11561156
systemProperty 'pact.verifier.publishResults', 'true'
11571157
}
11581158
}

consumer/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pact {
7272
pactBrokerUrl = 'http://localhost:8000/'
7373
pactBrokerUsername = 'pact_workshop'
7474
pactBrokerPassword = 'pact_workshop'
75-
tags = [getGitBranch(), 'test', 'prod']
75+
consumerBranch = getGitBranch()
7676
consumerVersion = getGitHash()
7777
}
7878
}

provider/build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
plugins {
22
id 'org.springframework.boot' version '3.2.2'
33
id 'io.spring.dependency-management' version '1.1.4'
4-
// id 'io.spring.dependency-management' version '1.1.4'
54
}
65

76
group = 'au.com.dius.pactworkshop'
@@ -40,9 +39,9 @@ def getGitBranch = { ->
4039
test {
4140
useJUnitPlatform()
4241

42+
systemProperty 'pact.provider.branch', getGitBranch()
4343
if (System.getProperty('pactPublishResults') == 'true') {
4444
systemProperty 'pact.provider.version', getGitHash()
45-
systemProperty 'pact.provider.tag', getGitBranch()
4645
systemProperty 'pact.verifier.publishResults', 'true'
4746
}
4847
}

provider/src/test/java/au/com/dius/pactworkshop/provider/ProductPactProviderTest.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import au.com.dius.pact.provider.junitsupport.State;
88
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
99
import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth;
10-
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
10+
import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder;
11+
// import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
1112
import org.apache.hc.core5.http.HttpRequest;
1213
import org.junit.jupiter.api.BeforeEach;
1314
import org.junit.jupiter.api.TestTemplate;
@@ -33,10 +34,18 @@
3334
port = "8000",
3435
authentication = @PactBrokerAuth(username = "pact_workshop", password = "pact_workshop")
3536
)
37+
3638
@ExtendWith(SpringExtension.class)
3739
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
3840
public class ProductPactProviderTest {
39-
41+
@au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors
42+
public static SelectorBuilder consumerVersionSelectors() {
43+
// Select Pacts for consumers deployed to production with branch from CI build
44+
return new SelectorBuilder()
45+
.deployedOrReleased()
46+
.mainBranch()
47+
.branch("dep_update");
48+
}
4049
@LocalServerPort
4150
int port;
4251

0 commit comments

Comments
 (0)