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
If you get an error like `command not found: atlantis`, ensure that `$GOPATH/bin` is in your `$PATH`.
49
-
50
-
## Running Atlantis With Local Changes
51
-
Docker compose is set up to start an atlantis container and ngrok container in the same network in order to expose the atlantis instance to the internet. In order to do this, create a file in the repository called `atlantis.env` and add the required env vars for the atlantis server configuration.
52
-
53
-
e.g.
54
-
55
-
```sh
56
-
NGROK_AUTH=1234567890
57
-
58
-
ATLANTIS_GH_APP_ID=123
59
-
ATLANTIS_GH_APP_KEY_FILE="/.ssh/somekey.pem"
60
-
ATLANTIS_GH_WEBHOOK_SECRET=12345
61
-
```
62
-
63
-
Note: `~/.ssh` is mounted to allow for referencing any local ssh keys.
64
-
65
-
Following this just run:
66
-
67
-
```sh
68
-
make build-service
69
-
docker-compose up --detach
70
-
docker-compose logs --follow
71
-
```
72
-
73
-
### Rebuilding
74
-
If the ngrok container is restarted, the url will change which is a hassle. Fortunately, when we make a code change, we can rebuild and restart the atlantis container easily without disrupting ngrok.
75
-
76
-
e.g.
77
-
78
-
```sh
79
-
make build-service
80
-
docker-compose up --detach --build
81
-
```
82
-
83
-
## Running Tests Locally
84
-
`make test`. If you want to run the integration tests that actually run real `terraform` commands, run `make test-all`.
85
-
86
-
## Running Tests In Docker
87
-
```sh
88
-
docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis ghcr.io/runatlantis/testing-env:latest make test
89
-
```
90
-
91
-
Or to run the integration tests
92
-
93
-
```sh
94
-
docker run --rm -v $(pwd):/go/src/github.com/runatlantis/atlantis -w /go/src/github.com/runatlantis/atlantis ghcr.io/runatlantis/testing-env:latest make test-all
95
-
```
96
-
97
-
## Calling Your Local Atlantis From GitHub
98
-
- Create a test terraform repository in your GitHub.
99
-
- Create a personal access token for Atlantis. See [Create a GitHub token](https://github.com/runatlantis/atlantis/tree/main/runatlantis.io/docs/access-credentials.md#generating-an-access-token).
- Download ngrok from https://ngrok.com/download. This will enable you to expose Atlantis running on your laptop to the internet so GitHub can call it.
105
-
- When you've downloaded and extracted ngrok, run it on port `4141`:
106
-
```sh
107
-
ngrok http 4141
108
-
```
109
-
- Create a Webhook in your repo and use the `https` url that `ngrok` printed out after running `ngrok http 4141`. Be sure to append `/events` so your webhook url looks something like `https://efce3bcd.ngrok.io/events`. See [Add GitHub Webhook](https://github.com/runatlantis/atlantis/blob/main/runatlantis.io/docs/configuring-webhooks.md#configuring-webhooks).
110
-
- Create a pull request and type `atlantis help`. You should see the request in the `ngrok` and Atlantis logs and you should also see Atlantis comment back.
111
-
112
-
## Code Style
113
-
114
-
### Logging
115
-
- `ctx.Log` should be available in most methods. If not, pass it down.
116
-
- levels:
117
-
- debug is for developers of atlantis
118
-
- info is for users (expected that people run on info level)
119
-
- warn is for something that might be a problem but we're not sure
120
-
- error is for something that's definitely a problem
121
-
- **ALWAYS** logs should be all lowercase (when printed, the first letter of each line will be automatically capitalized)
122
-
- **ALWAYS** quote any string variables using %q in the fmt string, ex. `ctx.Log.Info("cleaning clone dir %q", dir)` => `Cleaning clone directory "/tmp/atlantis/lkysow/atlantis-terraform-test/3"`
123
-
- **NEVER** use colons "`:`" in a log since that's used to separate error descriptions and causes
124
-
- if you need to have a breakin your log, either use `-` or `,` ex. `failed to clean directory, continuing regardless`
125
-
126
-
### Errors
127
-
- **ALWAYS** use lowercase unless the word requires it
128
-
- **ALWAYS** use `errors.Wrap(err, "additional context...")"` instead of `fmt.Errorf("additional context: %s", err)`
129
-
because it is less likely to result in mistakes and gives us the ability to trace call stacks
130
-
- **NEVER** use the words "error occurred when...", or "failed to..." or "unable to...", etc. Instead, describe what was occurring at
131
-
time of the error, ex. "cloning repository", "creating AWS session". This will prevent errors from looking like
132
-
```
133
-
Error setting up workspace: failed to run git clone: could find git
134
-
```
135
-
136
-
and will instead look like
137
-
```
138
-
Error: setting up workspace: running git clone: no executable "git"
139
-
```
140
-
This is easier to read and more consistent
141
-
142
-
### Testing
143
-
- place tests under `{package under test}_test` to enforce testing the external interfaces
144
-
- if you need to test internally i.e. access non-exported stuff, call the file `{file under test}_internal_test.go`
145
-
- use our testing utility for easier-to-read assertions: `import ."github.com/runatlantis/atlantis/testing"` and then use `Assert()`, `Equals()` and `Ok()`
146
-
147
-
### Mocks
148
-
We use [pegomock](https://github.com/petergtz/pegomock) for mocking. If you're
149
-
modifying any interfaces that are mocked, you'll need to regen the mocks for that
150
-
interface.
151
-
152
-
Install using `go install github.com/petergtz/pegomock/v4/pegomock@latest`
To regen the mock, run `go generate` on that file, e.g.
173
-
```sh
174
-
go generate server/events/project_command_builder.go
175
-
```
176
-
177
-
Alternatively, you can run `make go-generate` to execute `go generate` across all packages
178
-
179
-
180
-
# Backporting Fixes
181
-
Atlantis now uses a [cherry-pick-bot](https://github.com/googleapis/repo-automation-bots/tree/main/packages/cherry-pick-bot) from Google. The bot assists in maintaining changes across releases branches by easily cherry-picking changes via pull requests.
182
-
183
-
Maintainers and Core Contributors can add a comment to a pull request:
184
-
185
-
```sh
186
-
/cherry-pick target-branch-name
187
-
```
188
-
189
-
target-branch-name is the branch to cherry-pick to. cherry-pick-bot will cherry-pick the merged commit to a new branch (created from the target branch) and open a new pull request to the target branch.
190
-
191
-
The bot will immediately try to cherry-pick a merged PR. On unmerged pull request, it will not do anything immediately, but wait until merge. You can comment multiple times on a PR for multiple release branches.
192
-
193
-
## Manual Backporting Fixes
194
-
The bot will fail to cherry-pick if the feature branches' git history is not linear (merge commits instead of rebase). In that case, you will need to manually cherry-pick the squashed merged commit from main to the release branch
195
-
196
-
1. Switch to the release branch intended for the fix.
197
-
1. Run `git cherry-pick <sha>` with the commit hash from the main branch.
198
-
1. Push the newly cherry-picked commit up to the remote release branch.
199
-
200
-
# Creating a New Release
201
-
1. (Major/Minor release only) Create a new release branch `release-x.y`
202
-
1. Go to https://github.com/runatlantis/atlantis/releases and click "Draft a new release"
203
-
1. Prefix version with `v` and increment based on last release.
204
-
1. The title of the release is the same as the tag (ex. v0.2.2)
205
-
1. Fill in description by clicking on the "Generate Release Notes" button.
206
-
1. You may have to manually move around some commit titles as they are determined by PR labels (see .github/labeler.yml & .github/release.yml)
207
-
1. (Latest Major/Minor branches only) Make sure the release is set as latest
208
-
1. Don't set "latest release" for patches on older release branches.
209
-
1. Check and update the default version in `Chart.yaml` in [the official Helm chart](https://github.com/runatlantis/helm-charts/blob/main/charts/atlantis/values.yaml) as needed.
0 commit comments