diff --git a/scaffold/cmd/source.go b/scaffold/cmd/source.go index f974fe14c0ffad..c3d905fc013a7f 100644 --- a/scaffold/cmd/source.go +++ b/scaffold/cmd/source.go @@ -35,9 +35,11 @@ func newCmdScaffoldSource() *cobra.Command { var scaffoldTemplates = map[string]string{ "release.yaml.tpl": ".github/workflows/release.yaml", + "test.yaml.tpl": ".github/workflows/test.yaml", ".goreleaser.yaml.tpl": ".goreleaser.yaml", "go.mod.tpl": "go.mod", "main.go.tpl": "main.go", + "Makefile.tpl": "Makefile", "README.md.tpl": "README.md", "client.go.tpl": "client/client.go", "spec.go.tpl": "client/spec.go", diff --git a/scaffold/cmd/templates/source/.github/workflows/test.yaml.tpl b/scaffold/cmd/templates/source/.github/workflows/test.yaml.tpl new file mode 100644 index 00000000000000..f0a9a195d593b4 --- /dev/null +++ b/scaffold/cmd/templates/source/.github/workflows/test.yaml.tpl @@ -0,0 +1,38 @@ +name: test + +on: + push: + branches: + - main + pull_request: + branches: [main] + +jobs: + test: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + cache: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.50.1 + - name: Get dependencies + run: go get -t -d ./... + - name: Build + run: go build . + - name: Test + run: make test + - name: gen + if: github.event_name == 'pull_request' + run: make gen + - name: Fail if generation updated files + if: github.event_name == 'pull_request' + run: test "$(git status -s | wc -l)" -eq 0 || (git status -s; exit 1) diff --git a/scaffold/cmd/templates/source/Makefile.tpl b/scaffold/cmd/templates/source/Makefile.tpl new file mode 100644 index 00000000000000..963c91fd8f7ecb --- /dev/null +++ b/scaffold/cmd/templates/source/Makefile.tpl @@ -0,0 +1,16 @@ +.PHONY: test +test: + go test -timeout 3m ./... + +.PHONY: lint +lint: + @golangci-lint run --timeout 10m + +.PHONY: gen-docs +gen-docs: + rm -rf ./docs/tables/* + go run main.go doc ./docs/tables + +# All gen targets +.PHONY: gen +gen: gen-docs \ No newline at end of file diff --git a/scaffold/cmd/templates/source/README.md.tpl b/scaffold/cmd/templates/source/README.md.tpl index 3af66399a8ff89..1975c951dc0c0f 100644 --- a/scaffold/cmd/templates/source/README.md.tpl +++ b/scaffold/cmd/templates/source/README.md.tpl @@ -1 +1,48 @@ # CloudQuery {{.Name}} Source Plugin + +[![test](https://github.com/{{.Org}}/cq-source-{{.Name}}/actions/workflows/test.yaml/badge.svg)](https://github.com/{{.Org}}/cq-source-{{.Name}}/actions/workflows/test.yaml) +[![Go Report Card](https://goreportcard.com/badge/github.com/{{.Org}}/cq-source-{{.Name}})](https://goreportcard.com/report/github.com/{{.Org}}/cq-source-{{.Name}}) + +A {{.Name}} source plugin for CloudQuery that loads data from {{.Name}} to any database, data warehouse or data lake supported by [CloudQuery](https://www.cloudquery.io/), such as PostgreSQL, BigQuery, Athena, and many more. + +## Links + + - [CloudQuery Quickstart Guide](https://www.cloudquery.io/docs/quickstart) + - [Supported Tables](docs/tables/README.md) + + +## Configuration + +The following source configuration file will sync to a PostgreSQL database. See [the CloudQuery Quickstart](https://www.cloudquery.io/docs/quickstart) for more information on how to configure the source and destination. + +```yaml +kind: source +spec: + name: "{{.Name}}" + path: "{{.Org}}/{{.Name}}" + version: "${VERSION}" + destinations: + - "postgresql" + spec: + # plugin spec section +``` + +## Development + +### Run tests + +```bash +make test +``` + +### Run linter + +```bash +make lint +``` + +### Generate docs + +```bash +make gen-docs +``` \ No newline at end of file