Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Automation: update Go generation (sync models and services) #33

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ To generate all services in all libraries, run:
```
*Note:* Ensure that the service is in the following list: [`adyen.sdk-automation-conventions.gradle`](/buildSrc/src/main/groovy/adyen.sdk-automation-conventions.gradle).

For all services in a library, run:

```
./gradlew :go:services

```

For a single specific service:

Expand Down
44 changes: 40 additions & 4 deletions go/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ services.each { Service svc ->
dependsOn generateTask
outputs.upToDateWhen { false }

// delete existing services and models
doFirst {
delete layout.projectDirectory.dir("repo/src/$svc.id")
}

from layout.buildDirectory.dir("services/$svc.id")
include "**/*.go"
include "**/*"
into layout.projectDirectory.dir("repo/src/$svc.id")
}

Expand Down Expand Up @@ -94,10 +99,17 @@ tasks.named('deployPayment', Copy) {
into layout.projectDirectory.dir("repo/src/payments")
}

// These don't need a "index"
services.findAll({ it.small || it.name.endsWith('Webhooks') }).each { Service svc ->
// Small services (skip client.go as single class service does not need an "index" to group multiple tags)
services.findAll({ it.small }).each { Service svc ->
tasks.named("deploy${svc.name}", Copy) {
exclude 'client.go'
}
}

// Webhooks (skip client.go and copy models only)
services.findAll({ it.name.endsWith('Webhooks') }).each { Service svc ->
tasks.named("deploy${svc.name}", Copy) {
exclude 'client.go', 'api_default.go'
exclude 'client.go'
}
}

Expand All @@ -107,3 +119,27 @@ services.findAll({ it.small || it.name.endsWith('Webhooks') }).each { Service sv
additionalProperties.put('hasRestServiceError', 'true')
}
}

// Test small services
tasks.named('binlookup') {
doLast {
assert file("${layout.projectDirectory}/repo/src/binlookup/model_amount.go").exists()
assert !file("${layout.projectDirectory}/repo/src/binlookup/api_default.go").exists()
assert file("${layout.projectDirectory}/repo/src/binlookup/api_general.go").exists()
}
}
// Test services
tasks.named('checkout') {
doLast {
assert file("${layout.projectDirectory}/repo/src/checkout/model_amount.go").exists()
assert !file("${layout.projectDirectory}/repo/src/checkout/api_default.go").exists()
assert file("${layout.projectDirectory}/repo/src/checkout/api_donations.go").exists()
}
}
// Test webhooks
tasks.named('acswebhooks') {
doLast {
assert file("${layout.projectDirectory}/repo/src/acswebhook/model_amount.go").exists()
assert !file("${layout.projectDirectory}/repo/src/checkout/api_default.go").exists()
}
}