Skip to content

Commit fd875ee

Browse files
committed
Rework CI automation with doc generation
- New make target "reviewable" which is the default - New make target "generate" for generaring provider docs - Remove tool dependencies from go.mod and go.sum - Move tool dependencies into /tools directory as a separate Go module to be maintained by dependabot - Consolidate GitHub Actions for PRs to one file test.yml - Cache go modules and tools in CI workflows - Add linters and formatters for examples
1 parent bc15e66 commit fd875ee

20 files changed

+1826
-254
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ updates:
66
schedule:
77
interval: weekly
88

9+
- package-ecosystem: gomod
10+
directory: /tools
11+
schedule:
12+
interval: weekly
13+
914
- package-ecosystem: github-actions
1015
directory: /
1116
schedule:

.github/pull_request_template.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
<!-- For a smooth review process, please run through this checklist before submitting a PR. -->
88

99
- [ ] Resource attributes match 1:1 the names and structure of the API resource in [the GitLab API documentation](https://docs.gitlab.com/ee/api/).
10-
- [ ] Docs are updated with any new resources or attributes, including how to import the resource.
11-
- [ ] New resources should have at minimum a basic test with three steps:
10+
- [ ] [Examples](/examples) are updated with:
11+
- A \*.tf file for the resource/s with at least one usage example
12+
- A \*.sh file for the resource/s with an import example (if applicable)
13+
- [ ] New resources have at minimum a basic test with three steps:
1214
- Create the resource
1315
- Update the attributes
1416
- Import the resource

.github/workflows/acceptance-tests.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/golangci-lint.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/markdown-lint.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,22 @@ jobs:
1818
goreleaser:
1919
runs-on: ubuntu-latest
2020
steps:
21-
-
22-
name: Checkout
23-
uses: actions/checkout@v2
24-
-
25-
name: Unshallow
26-
run: git fetch --prune --unshallow
27-
-
28-
name: Set up Go
29-
uses: actions/[email protected]
21+
- uses: actions/setup-go@v2
3022
with:
3123
go-version: 1.16
32-
-
33-
name: Import GPG key
24+
- uses: actions/checkout@v2
25+
- uses: actions/cache@v2
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}-no-tools
29+
- name: Unshallow
30+
run: git fetch --prune --unshallow
31+
- uses: paultyng/[email protected]
3432
id: import_gpg
35-
uses: paultyng/[email protected]
3633
env:
3734
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3835
PASSPHRASE: ${{ secrets.PASSPHRASE }}
39-
-
40-
name: Run GoReleaser
41-
uses: goreleaser/goreleaser-action@v2
36+
- uses: goreleaser/goreleaser-action@v2
4237
with:
4338
version: latest
4439
args: release --rm-dist

.github/workflows/test.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: test
2+
on: [push,pull_request]
3+
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
target:
11+
- lint-golangci
12+
- lint-tfprovider
13+
- lint-examples-tf
14+
- lint-examples-sh
15+
steps:
16+
- uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.16
19+
- uses: actions/checkout@v2
20+
- uses: actions/cache@v2
21+
with:
22+
path: |
23+
~/go/pkg/mod
24+
bin
25+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}-include-tools
26+
- run: make ${{ matrix.target }}
27+
28+
unit-test:
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
go: [1.16]
34+
os: [ubuntu-latest, macos-latest, windows-latest]
35+
steps:
36+
- uses: actions/setup-go@v2
37+
with:
38+
go-version: ${{ matrix.go }}
39+
- uses: actions/checkout@v2
40+
- uses: actions/cache@v2
41+
with:
42+
path: ~/go/pkg/mod
43+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}-no-tools
44+
- run: make test
45+
46+
generate-check:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/setup-go@v2
50+
with:
51+
go-version: 1.16
52+
- uses: actions/checkout@v2
53+
- uses: actions/cache@v2
54+
with:
55+
path: |
56+
~/go/pkg/mod
57+
bin
58+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}-include-tools
59+
- run: make generate
60+
- name: Check generated files
61+
run: |
62+
[ -z "$(git status --short)" ] || { echo "Error: Files should have been generated:"; git status --short; echo "Diff:"; git diff HEAD; exit 1; }
63+
64+
acceptance-ce:
65+
timeout-minutes: 60
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/setup-go@v2
69+
with:
70+
go-version: 1.16
71+
- uses: actions/checkout@v2
72+
- uses: actions/cache@v2
73+
with:
74+
path: ~/go/pkg/mod
75+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}-no-tools
76+
- run: make testacc-up
77+
- run: make testacc
78+
79+
acceptance-ee:
80+
timeout-minutes: 60
81+
runs-on: ubuntu-latest
82+
if: github.event_name == 'push' && github.repository_owner == 'gitlabhq'
83+
steps:
84+
- uses: actions/setup-go@v2
85+
with:
86+
go-version: 1.16
87+
- uses: actions/checkout@v2
88+
- uses: actions/cache@v2
89+
with:
90+
path: ~/go/pkg/mod
91+
key: ${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}-no-tools
92+
- run: |
93+
openssl version
94+
openssl enc -d -aes-256-cbc -pbkdf2 -iter 20000 -in Gitlab-license.encrypted -out Gitlab-license.txt -pass "pass:${{ secrets.LICENSE_ENCRYPTION_PASSWORD }}"
95+
- run: make testacc-up SERVICE=gitlab-ee
96+
- run: make testacc

.github/workflows/tfproviderlint.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ website/.vagrant
2929
website/build
3030
website/node_modules
3131
website/vendor
32+
/tmp

.markdownlint.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ Use HashiCorp's [Plugin Development](https://www.terraform.io/plugin) guide as a
1010

1111
See the [Developing The Provider](#developing-the-provider) section below for specifics about this GitLab provider.
1212

13-
## PR Checklist
13+
## Before Committing
14+
15+
Run `make reviewable` and include any generated files in your commit. This will help ensure your PR passes automated checks.
16+
17+
**Tip:** If you have issues passing the automated checks, try deleting your project-local `bin` directory and re-run `make reviewable`.
18+
19+
### PR Checklist
1420

1521
<!--
1622
These are the most common issues in PRs which we have not automated.
1723
-->
1824

19-
For a smooth review process, please run through this checklist before submitting a PR.
25+
For a smooth review process, please run through this checklist before submitting a PR.
2026

2127
1. Resource attributes match 1:1 the names and structure of the API resource in the [GitLab API documentation](https://docs.gitlab.com/ee/api/api_resources.html).
22-
1. [Docs](/docs) are updated with any new resources or attributes, including how to import the resource.
23-
1. New resources should have at minimum a basic test with three steps:
28+
1. [Examples](/examples) are updated with:
29+
1. A \*.tf file for the resource/s with at least one usage example
30+
1. A \*.sh file for the resource/s with an import example (if applicable)
31+
1. New resources have at minimum a basic test with three steps:
2432
1. Create the resource
2533
1. Update the attributes
2634
1. Import the resource
@@ -50,11 +58,11 @@ See the [importer state function docs](https://www.terraform.io/plugin/sdkv2/res
5058

5159
#### Documentation
5260

53-
At the moment, documentation is handcrafted. Doc pages are located in [/docs](/docs). Please follow the [Terraform doc formatting guidelines](https://www.terraform.io/registry/providers/docs#format) for these pages. The [Terraform doc preview tool](https://registry.terraform.io/tools/doc-preview) is very helpful for previewing the markdown.
61+
Documentation in [/docs](/docs) is auto-generated by [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) based on code descriptions and [examples](/examples). Generation runs during `make reviewable`. You can use the [Terraform doc preview tool](https://registry.terraform.io/tools/doc-preview) if you would like to preview the generated documentation.
5462

5563
## Developing The Provider
5664

57-
You'll first need [Go](http://www.golang.org) installed on your machine (version 1.14+ is *required*).
65+
You'll first need [Go](http://www.golang.org) installed on your machine (version 1.16+ is *required*).
5866

5967
1. Clone the git repository.
6068

0 commit comments

Comments
 (0)