Skip to content

Commit

Permalink
Merge pull request #215 from Adyen/develop
Browse files Browse the repository at this point in the history
ITT-110: Release v7
  • Loading branch information
michaelpaul authored Jun 14, 2023
2 parents 835968e + bf7ea8b commit aa3a6a4
Show file tree
Hide file tree
Showing 1,096 changed files with 284,337 additions and 38,082 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @rikterbeek @gcatanese @AlexandrosMor @wboereboom @michaelpaul
* @rikterbeek @gcatanese @Adyen/api-libraries-reviewers
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand All @@ -26,15 +26,15 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -48,4 +48,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
steps:

- name: Set up Go 1.13
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get dependencies
run: |
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Go Models

on: [ workflow_dispatch ]

jobs:
generate:
runs-on: ubuntu-latest
name: Generate Models
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
id: go
- uses: actions/checkout@v3
- run: make models
- name: Set PR variables
id: vars
run: |
cd schema
echo ::set-output name=pr_title::"Update models"
echo ::set-output name=pr_body::"OpenAPI spec or templates produced new models on $(date +%d-%m-%Y) \
by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
- name: Create Pull Request
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5 # v5.0.0
with:
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
base: develop
branch: automation/models
title: ${{ steps.vars.outputs.pr_title }}
body: ${{ steps.vars.outputs.pr_body }}
add-paths: |
src
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.git
.idea/
bin/
.vscode/
# Test binary, built with `go test -c`
*.test

Expand All @@ -19,3 +20,4 @@ vendor/
.env
error.txt
/schema
src/*/.openapi-generator/FILES
2 changes: 1 addition & 1 deletion GENERATING_MODELS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ openapi-generator-cli generate \

**Step 2**: Remove the HTTP method(Post, Get, Put, Patch) suffix on API endpoint methods (Regex to find them `([A-Z][a-zA-Z0-9]*)Post\(request`)

**Step 3**: Add the new service to `APIClient` struct in `./src/api/api.go` and add import for the same
**Step 3**: Add the new service to `APIClient` struct in `src/adyen/api.go` and add import for the same

```go
type APIClient struct {
Expand Down
93 changes: 93 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,96 @@ test:
go test ./...

verify: build run test

## Automation

openapi-generator-version:=6.5.0
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
openapi-generator-jar:=bin/openapi-generator-cli.jar
openapi-generator-cli:=java -jar $(openapi-generator-jar)
goimports:=$(shell go env GOPATH)/bin/goimports

generator:=go
services:=balanceplatform configurationwebhook reportwebhook transferwebhook binlookup checkout legalentity management payments payout posterminalmanagement recurring storedvalue transfers
output:=src
templates:=templates/custom

# Generate models (for each service)
models: $(services)

balanceplatform: spec=BalancePlatformService-v2
balanceplatform: serviceName=BalancePlatform
balanceplatform: hasRestServiceError=true
configurationwebhook: spec=BalancePlatformConfigurationNotification-v1
reportwebhook: spec=BalancePlatformReportNotification-v1
transferwebhook: spec=BalancePlatformTransferNotification-v3
binlookup: spec=BinLookupService-v54
checkout: spec=CheckoutService-v70
checkout: serviceName=Checkout
legalentity: spec=LegalEntityService-v3
legalentity: serviceName=LegalEntity
payments: spec=PaymentService-v68
payout: spec=PayoutService-v68
recurring: spec=RecurringService-v68
storedvalue: spec=StoredValueService-v46
storedvalue: serviceName=StoredValue
transfers: spec=TransferService-v3
transfers: serviceName=Transfers
transfers: hasRestServiceError=true
management: spec=ManagementService-v1
management: serviceName=Management
management: hasRestServiceError=true
posterminalmanagement: spec=TfmAPIService-v1
posterminalmanagement: serviceName=PosTerminalManagementApi

# Generate a full client (models and service classes)
$(services): schema $(openapi-generator-jar) $(goimports)
GO_POST_PROCESS_FILE="$(goimports) -w" $(openapi-generator-cli) generate \
-i schema/json/$(spec).json \
-g $(generator) \
-t $(templates) \
-o $(output)/$(@) \
-p packageName=$(@) \
-c ./templates/config.yaml \
--global-property apis,models \
--global-property supportingFiles=client.go \
--global-property apiTests=false \
--global-property apiDocs=false \
--global-property modelDocs=false \
--skip-validate-spec \
--enable-post-process-file \
--inline-schema-name-mappings PaymentDonationRequest_paymentMethod=CheckoutPaymentMethod \
--additional-properties=serviceName=$(serviceName) \
--additional-properties=$(if $(hasRestServiceError),hasRestServiceError=true)
rm -rf $(output)/$(@)/go.{mod,sum}
rm -rf $(output)/$(@)/.openapi-generator/FILES

# Clone OpenAPI spec (and apply local patches)
schema:
git clone https://github.com/Adyen/adyen-openapi.git schema
perl -i -pe 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' schema/json/*.json
for json in schema/json/*.json; do \
jq -e 'if has("paths") then .paths[][] |= (.operationId = ."x-methodName") else . end' $$json > "$${json}.tmp"; \
mv "$${json}.tmp" $$json; \
done

# Extract templates (copy them for modifications)
templates: $(openapi-generator-jar)
$(openapi-generator-cli) author template -g $(generator) -o schema/templates

# Download the generator
$(openapi-generator-jar):
mkdir -p bin
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)

# Download the import optimizer (and code formatter)
$(goimports):
go install golang.org/x/tools/cmd/goimports@latest

# Discard generated artifacts and changed models
clean:
git checkout src
git clean -f -d src


.PHONY: templates models $(services)
2 changes: 1 addition & 1 deletion RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Releases are done on GitHub on the `main` branch. All development is done on the

**Step 4**: For patch and minor version releases go to step 6, For major version releases go to step 5

**Step 5**: Find and replace `github.com/adyen/adyen-go-api-library/v<current major version>` with `github.com/adyen/adyen-go-api-library/v<new major version>` throughout the project including test files and README. For example `github.com/adyen/adyen-go-api-library/v5` will become `github.com/adyen/adyen-go-api-library/v6`
**Step 5**: Find and replace `github.com/adyen/adyen-go-api-library/v<current major version>` with `github.com/adyen/adyen-go-api-library/v<new major version>` throughout the project including test files and README. For example `github.com/adyen/adyen-go-api-library/v3` will become `github.com/adyen/adyen-go-api-library/v4`

**Step 6**: create a PR form `develop` to `main` and wait for all tests to pass and for approvals

Expand Down
Loading

0 comments on commit aa3a6a4

Please sign in to comment.