Skip to content

Commit 69155c6

Browse files
authored
Populate pull requests (#6)
* Update services * Register webhook modules * Java big services * Small services * Fixing tags and webhooks * Embed java generator config * Service renaming * Fix names * Rename ACS * Service renaming for PHP * Small PHP services * Deploy .NET * skip CI build for non formatted libs blocking concurrent workflow execution * global clean tasks Removed "skip ci" tag as it prevents auto formatting * Deploy Node.js * Deploy Python * Fix small services with tags * Deploy Ruby * Upgrade Gradle to latest version * Fix generator install for precompiled script * Register specific clean tasks * Conditional use of inlineSchemaNameMappings * Downgrade Node.js generator * Extract Service class * PR feedback
1 parent 27641cc commit 69155c6

File tree

23 files changed

+765
-90
lines changed

23 files changed

+765
-90
lines changed

.github/workflows/gradle.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
permissions:
99
contents: read
1010

11+
concurrency:
12+
group: ci-sdk-automation
13+
1114
jobs:
1215
generate:
1316
strategy:
@@ -27,10 +30,13 @@ jobs:
2730
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
2831
repository: Adyen/adyen-${{ matrix.project }}-api-library
2932
path: ${{ matrix.project }}/repo
30-
- name: Generate code for ${{ matrix.project }}
33+
- name: Setup Gradle
3134
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
32-
with:
33-
arguments: ${{ matrix.project }}:services
35+
- name: Override properties
36+
if: matrix.project == 'node'
37+
run: cp ${{ matrix.project }}/gradle.properties buildSrc
38+
- name: Generate code for ${{ matrix.project }}
39+
run: ./gradlew ${{ matrix.project }}:services
3440
- name: Set PR variables
3541
id: vars
3642
run: |
@@ -48,3 +54,5 @@ jobs:
4854
branch: sdk-automation/models
4955
title: ${{ steps.vars.outputs.pr_title }}
5056
body: ${{ steps.vars.outputs.pr_body }}
57+
commit-message: |
58+
${{ contains(fromJSON('["go", "php", "node"]'), matrix.project) && '[reformat]' }}[adyen-sdk-automation] automated change

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,28 @@ For a single specific service:
1414
./gradlew php:checkout
1515
```
1616

17-
To clean up *most* (except for `repo` folders) of the generated artifacts:
17+
To clean up spec patches:
1818

1919
```
20-
./gradlew clean
20+
./gradlew cleanSpecs
21+
```
22+
23+
To clean up all the generated artifacts and repository modifications:
24+
25+
```
26+
./gradlew cleanRepo
27+
```
28+
29+
Typical usage during development:
30+
31+
```
32+
./gradlew :dotnet:cleanRepo :dotnet:checkout
33+
```
34+
35+
For Node.js, set the generator version via CLI:
36+
37+
```
38+
./gradlew :node:cleanRepo :node:checkout -PopenapiGeneratorVersion=5.4.0
2139
```
2240

2341
### Development
@@ -29,4 +47,10 @@ For local testing of some library:
2947

3048
```shell
3149
rm -rf go/repo && ln -s ~/workspace/adyen-go-api-library go/repo
32-
```
50+
```
51+
52+
To run unit tests:
53+
54+
```
55+
./gradlew :buildSrc:test
56+
```

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import groovy.json.JsonSlurper
33

44
def uri = "https://github.com/Adyen/adyen-openapi.git"
55
def specsDir = "$projectDir/schema"
6-
def checkoutDir = "$projectDir/schema/json/CheckoutService-v70.json"
6+
def checkoutDir = "$projectDir/schema/json/CheckoutService-v71.json"
77

88
tasks.register('specs', Exec) {
9+
group 'setup'
910
description 'Clone OpenAPI spec (and apply local patches).'
1011
commandLine 'git', 'clone', '--depth', '1', uri, specsDir
1112
outputs.dir specsDir
@@ -36,6 +37,7 @@ tasks.register('specs', Exec) {
3637
}
3738

3839
tasks.register('pmTable', Task) {
40+
group 'specs'
3941
description 'Generate Checkout Payment Method Table'
4042
dependsOn('specs')
4143
onlyIf { file(checkoutDir).exists() }
@@ -75,6 +77,8 @@ tasks.register('pmTable', Task) {
7577
}
7678
}
7779

78-
tasks.register('clean', Delete) {
80+
tasks.register('cleanSpecs', Delete) {
81+
group 'clean'
82+
description 'Delete OpenAPI specifications'
7983
delete specsDir
8084
}

buildSrc/build.gradle

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1-
buildscript {
2-
repositories {
3-
mavenLocal()
4-
mavenCentral()
5-
// or, via Gradle Plugin Portal:
6-
// url "https://plugins.gradle.org/m2/"
7-
}
8-
dependencies {
9-
classpath "org.openapitools:openapi-generator-gradle-plugin:6.0.1"
10-
}
11-
}
12-
131
plugins {
142
// Support convention plugins written in Groovy. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
153
id 'groovy-gradle-plugin'
164
}
175

186
repositories {
7+
mavenCentral()
198
// Use the plugin portal to apply community plugins in convention plugins.
209
gradlePluginPortal()
2110
}
2211

2312
dependencies {
24-
implementation "org.openapitools:openapi-generator-gradle-plugin:6.0.1"
13+
implementation "org.openapitools:openapi-generator-gradle-plugin:${openapiGeneratorVersion}"
14+
testImplementation 'junit:junit:4.13'
2515
}

buildSrc/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openapiGeneratorVersion=6.0.1

buildSrc/settings.gradle

Whitespace-only changes.
Lines changed: 104 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,77 @@
1+
plugins {
2+
id 'org.openapi.generator'
3+
}
4+
5+
import com.adyen.sdk.Service
6+
import groovy.json.JsonOutput
7+
import groovy.json.JsonSlurper
18
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
29

310
repositories {
411
// Use Maven Central for resolving dependencies.
512
mavenCentral()
613
}
714

15+
List<Service> services = [
16+
// Payments
17+
new Service(name: 'Checkout', version: 71),
18+
new Service(name: 'Payout', version: 68),
19+
new Service(name: 'Recurring', version: 68, small: true),
20+
new Service(name: 'BinLookup', version: 54, small: true),
21+
// Point of Sale
22+
new Service(name: 'PosTerminalManagement', spec: 'TfmAPIService', version: 1, small: true),
23+
// Management
24+
new Service(name: 'Management', version: 3),
25+
new Service(name: 'BalanceControl', version: 1, small: true),
26+
// Adyen for Platforms
27+
new Service(name: 'LegalEntityManagement', spec: 'LegalEntityService', version: 3),
28+
new Service(name: 'BalancePlatform', version: 2),
29+
new Service(name: 'Transfers', spec: 'TransferService', version: 4),
30+
new Service(name: 'DataProtection', version: 1, small: true),
31+
// Classic Payments
32+
new Service(name: 'Payment', version: 68, small: true),
33+
// Others
34+
new Service(name: 'StoredValue', version: 46, small: true),
35+
new Service(name: 'Disputes', spec: 'DisputeService', version: 30, small: true),
36+
// Webhooks
37+
new Service(name: 'ConfigurationWebhooks', spec: 'BalancePlatformConfigurationNotification', version: 1),
38+
new Service(name: 'AcsWebhooks', spec: 'BalancePlatformAcsNotification', version: 1),
39+
new Service(name: 'ReportWebhooks', spec: 'BalancePlatformReportNotification', version: 1),
40+
new Service(name: 'TransferWebhooks', spec: 'BalancePlatformTransferNotification', version: 4),
41+
new Service(name: 'TransactionWebhooks', spec: 'BalancePlatformTransactionNotification', version: 4),
42+
new Service(name: 'ManagementWebhooks', spec: 'ManagementNotificationService', version: 3),
43+
]
44+
845
ext {
946
generator = project.name
1047
templates = 'templates'
11-
services = [
12-
// Payments
13-
new Service(name: 'Checkout', version: 71),
14-
new Service(name: 'Payout', version: 68),
15-
new Service(name: 'Recurring', version: 68),
16-
new Service(name: 'BinLookup', version: 54),
17-
// Point of Sale
18-
new Service(name: 'POSTerminalManagement', spec: 'TfmAPIService', version: 1),
19-
// Management
20-
new Service(name: 'Management', version: 3),
21-
new Service(name: 'BalanceControl', version: 1),
22-
// Adyen for Platforms
23-
new Service(name: 'LegalEntityManagement', spec: 'LegalEntityService', version: 3),
24-
new Service(name: 'BalancePlatform', version: 2),
25-
new Service(name: 'Transfers', spec: 'TransferService', version: 4),
26-
new Service(name: 'DataProtection', version: 1),
27-
// Classic Payments
28-
new Service(name: 'Payment', version: 68),
29-
// Others
30-
new Service(name: 'StoredValue', version: 46),
31-
// Webhooks
32-
new Service(name: 'ConfigurationWebhook', spec: 'BalancePlatformConfigurationNotification', version: 1),
33-
new Service(name: 'ACSWebhook', spec: 'BalancePlatformAcsNotification', version: 1),
34-
new Service(name: 'ReportWebhook', spec: 'BalancePlatformReportNotification', version: 1),
35-
new Service(name: 'TransferWebhook', spec: 'BalancePlatformTransferNotification', version: 4),
36-
new Service(name: 'TransactionWebhook', spec: 'BalancePlatformTransactionNotification', version: 4),
37-
new Service(name: 'ManagementWebhook', spec: 'ManagementNotificationService', version: 3),
38-
]
3948
serviceName = ''
40-
}
41-
42-
class Service {
43-
String name, spec
44-
int version
45-
46-
String getSpec() { spec ?: "${name}Service" }
47-
48-
String getId() { name.toLowerCase() }
49+
removeTags = true
50+
setProperty('services', services)
51+
smallServices = services.findAll { it.small }
52+
serviceNaming = services.collectEntries { [it.id, it.name] }
53+
serviceNamingCamel = services.collectEntries {
54+
[it.id, it.name.substring(0, 1).toLowerCase() + it.name.substring(1)]
55+
}
4956
}
5057

5158
// Generate a full client for each service
52-
project.ext.services.each { Service svc ->
59+
services.each { Service svc ->
5360
def generate = tasks.register("generate$svc.name", GenerateTask) {
61+
group 'generate'
5462
description "Generate a $project.name client for $svc.name."
55-
dependsOn 'clone'
63+
dependsOn 'cloneRepo'
5664
dependsOn ':specs'
5765

5866
// Current service being processed
67+
ext.serviceId = svc.id
5968
project.ext.serviceName = svc.name
6069

6170
generatorName.set(project.ext.generator as String)
62-
inputSpec.set("$rootDir/schema/json/${svc.spec}-v${svc.version}.json")
71+
inputSpec.set("$rootDir/schema/json/${svc.filename}")
6372
outputDir.set("$buildDir/services/${svc.id}")
6473
templateDir.set("$projectDir/repo/$project.ext.templates")
74+
engine.set('mustache')
6575
validateSpec.set(false)
6676
skipValidateSpec.set(true)
6777
reservedWordsMappings.set([
@@ -70,31 +80,41 @@ project.ext.services.each { Service svc ->
7080
additionalProperties.set([
7181
'serviceName': project.ext.serviceName,
7282
])
83+
globalProperties.set([
84+
'modelDocs' : 'false',
85+
'modelTests': 'false'
86+
])
7387

7488
if (project.ext.has('configFile')) {
7589
configFile.set("$projectDir/repo/$project.ext.configFile")
7690
}
7791
}
7892

7993
tasks.register(svc.id) {
94+
group 'service'
8095
description "Base task for $svc.name."
8196
dependsOn generate
8297
}
8398
}
8499

85100
tasks.register('services') {
86101
description 'Generate code for multiple services.'
87-
dependsOn project.ext.services.collect { it.id }
102+
dependsOn services.collect { it.id }
88103
}
89104

90105
tasks.named('generateCheckout', GenerateTask) {
106+
if (project.name == 'node') {
107+
// generator v5 does not support inlineSchemaNameMappings
108+
return
109+
}
91110
inlineSchemaNameMappings.set([
92111
'PaymentRequest_paymentMethod' : 'CheckoutPaymentMethod',
93112
'DonationPaymentRequest_paymentMethod': 'DonationPaymentMethod',
94113
])
95114
}
96115

97-
tasks.register('clone', Exec) {
116+
tasks.register('cloneRepo', Exec) {
117+
group 'setup'
98118
def uri = "https://github.com/Adyen/adyen-$project.name-api-library.git"
99119
def dest = 'repo'
100120
description "Clone this project's repository."
@@ -109,13 +129,51 @@ tasks.withType(GenerateTask).configureEach {
109129
outputs.cacheIf { false }
110130
}
111131

112-
tasks.register('clean', Delete) {
113-
delete buildDir
132+
tasks.register('cleanRepo', Delete) {
133+
group 'clean'
134+
description 'Clean this project state'
135+
delete layout.buildDirectory
136+
doLast {
137+
exec {
138+
// cleanTracked: discard changes to existing files
139+
commandLine 'git', 'checkout', '.'
140+
workingDir 'repo'
141+
}
142+
exec {
143+
// cleanUntracked: discard unknown files
144+
commandLine 'git', 'clean', '-f', '-d'
145+
workingDir 'repo'
146+
}
147+
}
114148
}
115149

116150
tasks.register('addPMTable', Copy) {
117-
dependsOn("clone")
151+
dependsOn("cloneRepo")
118152
dependsOn(":pmTable")
119153
from(rootProject.file('PaymentMethodOverview.md'))
120154
into layout.projectDirectory.dir("repo")
121-
}
155+
}
156+
157+
project.ext.smallServices.each { Service svc ->
158+
def ungroup = tasks.register("ungroup${svc.name}") {
159+
group 'specs'
160+
description "Remove tags from ${svc.name}"
161+
dependsOn ':specs'
162+
// The `removeTags` setting only works in isolation (e.g. CI). Locally, specs are shared between all projects.
163+
onlyIf { project.ext.removeTags }
164+
doLast {
165+
def specFile = file("$rootDir/schema/json/${svc.filename}")
166+
def json = new JsonSlurper().parse(specFile)
167+
168+
json["paths"].each { Map.Entry endpoint ->
169+
endpoint.value.each { Map.Entry httpMethod ->
170+
httpMethod.value.remove('tags')
171+
}
172+
}
173+
174+
specFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(json))
175+
}
176+
}
177+
178+
tasks.named("generate$svc.name") { dependsOn ungroup }
179+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.adyen.sdk
2+
3+
class Service {
4+
String name, spec
5+
int version
6+
boolean small
7+
8+
String getId() { name.toLowerCase() }
9+
10+
String getSpec() { spec ?: "${name}Service" }
11+
12+
String getFilename() { "${getSpec()}-v${version}.json" }
13+
14+
boolean isWebhook() { name.endsWith('Webhooks') }
15+
}

0 commit comments

Comments
 (0)