From 5a55cad7c3c312c28ee0ef3bb126c05b2d7b47df Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 7 Sep 2022 15:15:23 +0200 Subject: [PATCH] Ensure Go code is formatted (#37) --- .github/workflows/push.yml | 21 +++++++++++++++++++++ .vscode/settings.json | 6 ++++++ python/wheel.go | 6 +++--- terraform/runner.go | 27 ++++++++++++++------------- 4 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 5272a5d417..6fb903d5aa 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -48,3 +48,24 @@ jobs: - name: Run tests run: make test + + fmt: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v1 + with: + go-version: 1.18.x + + - name: Run gofmt + run: | + # -l: list files that were reformatted + # -w: write back formatted files to disk + gofmt -l -w ./ + + - name: Fail on differences + run: | + # Exit with status code 1 if there are differences (i.e. unformatted files) + git diff --exit-code diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..6a32fe0a14 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "[go]": { + "editor.insertSpaces": false, + "editor.formatOnSave": true + } +} diff --git a/python/wheel.go b/python/wheel.go index 508355fcf2..68026b06c5 100644 --- a/python/wheel.go +++ b/python/wheel.go @@ -42,9 +42,9 @@ const DBFSWheelLocation = "dbfs:/FileStore/wheels/simple" // or do we bypass the environment variable into terraform deployer. And make a decision. // // Whatever this method gets refactored to is intended to be used for two purposes: -// - uploading project's wheel archives: one per project or one per project/developer, depending on isolation -// - synchronising enterprise artifactories, jfrogs, azdo feeds, so that we fix the gap of private code artifact -// repository integration. +// - uploading project's wheel archives: one per project or one per project/developer, depending on isolation +// - synchronising enterprise artifactories, jfrogs, azdo feeds, so that we fix the gap of private code artifact +// repository integration. func UploadWheelToDBFSWithPEP503(ctx context.Context, dir string) (string, error) { wheel, err := BuildWheel(ctx, dir) if err != nil { diff --git a/terraform/runner.go b/terraform/runner.go index 4357b104b4..06fc052c0a 100644 --- a/terraform/runner.go +++ b/terraform/runner.go @@ -10,13 +10,14 @@ Solve the following adoption slowers: - users won't have to copy-paste these into their configs: ```hcl -terraform { - required_providers { - databricks = { - source = "databrickslabs/databricks" - } - } -} + + terraform { + required_providers { + databricks = { + source = "databrickslabs/databricks" + } + } + } provider "databricks" { } @@ -25,12 +26,12 @@ provider "databricks" { Terraform Plugin SDK v2 is using similar techniques for testing providers. One may find details in github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/plugin.go. In short: -- init provider isntance -- start terraform plugin GRPC server -- "reattach" providers and specify the `tfexec.Reattach` options, which essentially - forward GRPC address to terraform subprocess. -- this can be done by either adding a source depenency on Databricks provider - or adding a special launch mode to it. + - init provider isntance + - start terraform plugin GRPC server + - "reattach" providers and specify the `tfexec.Reattach` options, which essentially + forward GRPC address to terraform subprocess. + - this can be done by either adding a source depenency on Databricks provider + or adding a special launch mode to it. For now ---