Skip to content

Commit

Permalink
Auto format workflow (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpaul authored Nov 28, 2023
1 parent 58dc76e commit fa0c336
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Go Format

on:
push:
branches:
- 'sdk-automation/models'

jobs:
format:
if: ! startsWith(github.event.head_commit.message, 'style(fmt)')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-go@v4
with:
go-version: 1.18
- run: make fmt
- run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "style(fmt): code formatted"
git push
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
goimports:=$(shell go env GOPATH)/bin/goimports

build:
@echo "Building Adyen Go API library"
go build -o bin/main main.go
Expand All @@ -10,6 +12,13 @@ test:
@echo "Testing Adyen Go API library"
go test ./...

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

fmt: $(goimports)
$(goimports) -w src

verify: build run test

## Automation
Expand All @@ -18,7 +27,6 @@ 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:=balancecontrol balanceplatform acswebhook configurationwebhook reportwebhook transferwebhook binlookup checkout legalentity management managementwebhook payments payout posterminalmanagement recurring storedvalue transfers dataprotection
Expand Down Expand Up @@ -104,10 +112,6 @@ $(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
Expand Down

0 comments on commit fa0c336

Please sign in to comment.