You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replaced the start-gitlab.sh script with a docker-compose.yml file
- Optimized the testing section of the README for common use cases
- Made it so make testacc works by default, without needing to set GITLAB_TOKEN or GITLAB_BASE_URL. (These variables are still configurable.)
- Removed references to the "license" directory, which does not work on MacOS due to the conflict with the LICENSE file. The license is now expected to be in the project root and named Gitlab-license.txt.
2. Build the provider with `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
36
32
37
-
Using the provider
38
-
----------------------
33
+
```sh
34
+
$ make build
35
+
```
39
36
40
-
#Developing the Provider
37
+
### Running Tests
41
38
42
-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.14+ is *required*).
39
+
The acceptance tests can run against a Gitlab instance where you have a token with administrator permissions (likely not gitlab.com).
43
40
44
-
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
41
+
#### Option 1: Run tests against a local Gitlab container with docker-compose
45
42
46
-
```sh
47
-
$ make build
48
-
...
49
-
$ $GOPATH/bin/terraform-provider-gitlab
50
-
...
51
-
```
43
+
This option is the easiest and requires [docker-compose](https://docs.docker.com/compose/install/) (version 1.13+) to be installed on your machine.
44
+
45
+
1. Start the Gitlab container. It will take about 5 minutes for the container to become healthy.
46
+
47
+
```sh
48
+
$ make testacc-up
49
+
```
52
50
53
-
### Running tests
51
+
2. Run the acceptance tests. The full suite takes 10-20 minutes to run.
54
52
55
-
The Terraform Provider only has acceptance tests, these can run against a gitlab instance where you have a token with administrator permissions (likely not gitlab.com).
56
-
There is excellent documentation on [how to run gitlab from docker at gitlab.com](https://docs.gitlab.com/omnibus/docker/)
53
+
```sh
54
+
$ make testacc
55
+
```
57
56
58
-
In order to run the full suite of acceptance tests, export the environment variables:
57
+
3. Stop the Gitlab container.
59
58
60
-
-`GITLAB_TOKEN` //token for account with admin priviliges
61
-
-`GITLAB_BASE_URL` //URL with api part e.g. `http://localhost:8929/api/v4/`
59
+
```sh
60
+
$ make testacc-down
61
+
```
62
62
63
-
and run `make testacc`.
63
+
#### Option 2: Run tests against your own Gitlab instance
64
+
65
+
If you have your own hosted Gitlab instance, you can run the tests against it directly.
64
66
65
67
```sh
66
-
$ make testacc
68
+
$ make testacc GITLAB_TOKEN=example123 GITLAB_BASE_URL=https://example.com/api/v4
67
69
```
68
70
69
-
### Gitlab Community Edition and Gitlab Entreprise Edition
71
+
`GITLAB_TOKEN` must be a valid token for an account with admin privileges.
72
+
73
+
#### Testing Tips
74
+
75
+
***Gitlab Community Edition and Gitlab Enterprise Edition:**
76
+
77
+
This module supports both Gitlab CE and Gitlab EE. We run tests on Gitlab EE,
78
+
but can't run them on pull requests from forks.
79
+
80
+
Features that only work on one flavour can use the following helpers as
81
+
SkipFunc: `isRunningInEE` and `isRunningInCE`. You can see an example of this
82
+
for [gitlab_project_level_mr_approvals](gitlab/resource_gitlab_project_level_mr_approvals_test.go)
83
+
tests.
84
+
85
+
***Run EE tests:**
86
+
87
+
If you have a `Gitlab-license.txt` you can run Gitlab EE, which will enable the full suite of tests:
88
+
89
+
```sh
90
+
$ make testacc-up SERVICE=gitlab-ee
91
+
```
92
+
93
+
***Run a single test:**
94
+
95
+
You can pass a pattern to the `RUN` variable to run a reduced number of tests. For example:
96
+
97
+
```sh
98
+
$ make testacc RUN=TestAccGitlabGroup
99
+
```
100
+
101
+
...will run all tests for the `gitlab_group` resource.
102
+
103
+
***Debug a test in an IDE:**
104
+
105
+
First start the Gitlab container with `make testacc-up`.
106
+
Then run the desired Go test as you would normally from your IDE, but configure your run configuration to set these environment variables:
107
+
108
+
```
109
+
GITLAB_TOKEN=ACCTEST
110
+
GITLAB_BASE_URL=http://127.0.0.1:8080/api/v4
111
+
TF_ACC=1
112
+
```
70
113
71
-
This module supports both Gitlab CE and Gitlab EE. We run tests on Gitlab EE,
72
-
but can't run them on pull requests from forks.
114
+
***Useful HashiCorp documentation:**
73
115
74
-
Features that only work on one flavour can use the following helpers as
75
-
SkipFunc: `isRunningInEE` and `isRunningInCE`. You can see an example of this
76
-
for [gitlab_project_push_rules](gitlab/resource_gitlab_project_push_rules_test.go)
77
-
tests.
116
+
Refer to [HashiCorp's testing guide](https://www.terraform.io/docs/extend/testing/index.html)
117
+
and [HashiCorp's testing best practices](https://www.terraform.io/docs/extend/best-practices/testing.html).
0 commit comments