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

Refactor generated code check #552

Closed
wants to merge 2 commits into from
Closed
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
31 changes: 2 additions & 29 deletions .github/actions/go_init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,8 @@ runs:
check-latest: true
cache: ${{ inputs.cache }}

- name: Checkout
uses: actions/checkout@v4
with:
repository: overmindtech/aws-source
path: ./aws-source

- name: Checkout
uses: actions/checkout@v4
with:
repository: overmindtech/k8s-source
path: ./k8s-source

- name: Move sources in place
shell: bash
run: |
rm -rf ../aws-source
rm -rf ../k8s-source
mv -v aws-source ..
mv -v k8s-source ..
- name: Go Generate
- name: Get deps and refresh generated code
shell: bash
run: |
go get -v -t -d ./...
go generate ./...
if [ -z "$(git status --porcelain)" ]; then
echo "No pending changes from 'go generate'"
else
echo "Pending changes from 'go generate' found, please run 'go generate ./...' and commit the changes"
git status
exit 1
fi
cat cmd/commit.txt
2 changes: 0 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
- name: Build the binary
run: |
set -xe
go get -v -t -d ./...
go build -o overmind main.go
- name: Run E2E Tests
Expand Down Expand Up @@ -121,7 +120,6 @@ jobs:
- name: Build the binary
run: |
set -xe
go get -v -t -d ./...
go build -o overmind main.go
- name: Run E2E Tests
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ jobs:
- name: Go Init
uses: ./.github/actions/go_init

- name: Get dependencies
run: |
go get -v -t -d ./...

- name: Go Test
run: |
go run main.go --version
Expand All @@ -38,6 +34,10 @@ jobs:
- name: Go Init
uses: ./.github/actions/go_init

- name: Check go generate output is clean
run: |
git diff --exit-code

# get .golangci.yml from github.com/overmindtech/golangci-lint_config
- name: Get .golangci.yml from github.com/overmindtech/golangci-lint_configs
run: |
Expand All @@ -48,4 +48,3 @@ jobs:
with:
version: v1.60.1
args: --timeout 3m
skip-pkg-cache: true # golangci-lint-action caching conflicts with the setup-go cache and `go get` above. See https://github.com/golangci/golangci-lint-action/issues/23
7 changes: 4 additions & 3 deletions extractmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"html/template"
"os"
"path/filepath"
"strings"
)

Expand All @@ -17,7 +18,7 @@ type Args struct {
}

func main() {
fmt.Printf("Running %s go on %s\n", os.Args[0], os.Getenv("GOFILE"))
fmt.Printf("Running %s from %s\n", os.Args[0], os.Getenv("GOFILE"))

cwd, err := os.Getwd()
if err != nil {
Expand All @@ -35,9 +36,9 @@ func main() {
}

args := Args{
Source: os.Args[1],
Source: filepath.Base(os.Args[1]),
SourceMunged: strings.ReplaceAll(os.Args[1], "-", ""),
Data: dataFromFiles(fmt.Sprintf("../sources/%v/docs-data", os.Args[1])),
Data: dataFromFiles(fmt.Sprintf("%v/docs-data", os.Args[1])),
}

funcMap := template.FuncMap{
Expand Down
1 change: 0 additions & 1 deletion sources/aws-source

This file was deleted.

1 change: 0 additions & 1 deletion sources/k8s-source

This file was deleted.

4 changes: 2 additions & 2 deletions tfutils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/overmindtech/sdp-go"
)

//go:generate go run ../extractmaps.go aws-source
//go:generate go run ../extractmaps.go k8s-source
//go:generate bash -c "go run ../extractmaps.go $(go list -m -f '{{.Dir}}' github.com/overmindtech/aws-source)"
//go:generate bash -c "go run ../extractmaps.go $(go list -m -f '{{.Dir}}' github.com/overmindtech/k8s-source)"

type TfMapData struct {
// The overmind type name
Expand Down
Loading