Skip to content

Commit

Permalink
Merge pull request #33 from Adyen/go-generation-update
Browse files Browse the repository at this point in the history
SDK Automation: update Go generation (sync models and services)
  • Loading branch information
DjoykeAbyah authored Nov 12, 2024
2 parents 0bccb45 + b164e4a commit 685a4be
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
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()
}
}

0 comments on commit 685a4be

Please sign in to comment.