Skip to content

Commit 9b981f9

Browse files
authored
Merge branch 'main' into skip_clone_no_changes_fork_prs
2 parents 64b8bb2 + 693c092 commit 9b981f9

15 files changed

+573
-41
lines changed

.github/workflows/atlantis-image.yml

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ jobs:
241241
strategy:
242242
matrix:
243243
image_type: [alpine, debian]
244+
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
244245
runs-on: ubuntu-24.04
245246
steps:
246247
- run: 'echo "No build required"'

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
go-version-file: go.mod
5656

5757
- name: golangci-lint
58-
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6
58+
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6
5959
with:
6060
# renovate: datasource=github-releases depName=golangci/golangci-lint
6161
version: v1.62.2

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
if: needs.changes.outputs.should-run-tests == 'true'
4949
name: Tests
5050
runs-on: ubuntu-24.04
51-
container: ghcr.io/runatlantis/testing-env:latest@sha256:45ec58ba11af5196fb70ced526ccb1996f0e58a7dbd93f7dcba96eed49209583
51+
container: ghcr.io/runatlantis/testing-env:latest@sha256:3d7b17d02ced2cb68ecc9d2ea3d2bef61fe8da52cf1631e4dff4de6503cb7237
5252
steps:
5353
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
5454

Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ ARG DEBIAN_TAG=12.8-slim@sha256:d365f4920711a9074c4bcd178e8f457ee59250426441ab2a
55
ARG GOLANG_TAG=1.23.4-alpine@sha256:c23339199a08b0e12032856908589a6d41a0dab141b8b3b21f156fc571a3f1d3
66

77
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
8-
ARG DEFAULT_TERRAFORM_VERSION=1.10.3
8+
ARG DEFAULT_TERRAFORM_VERSION=1.10.4
99
# renovate: datasource=github-releases depName=opentofu/opentofu versioning=hashicorp
1010
ARG DEFAULT_OPENTOFU_VERSION=1.8.8
1111
# renovate: datasource=github-releases depName=open-policy-agent/conftest
1212
ARG DEFAULT_CONFTEST_VERSION=0.56.0
1313

1414
# Stage 1: build artifact and download deps
1515

16-
FROM golang:${GOLANG_TAG} AS builder
16+
FROM --platform=$BUILDPLATFORM golang:${GOLANG_TAG} AS builder
17+
18+
# These are automatically populated by Docker
19+
ARG TARGETOS
20+
ARG TARGETARCH
1721

1822
ARG ATLANTIS_VERSION=dev
1923
ENV ATLANTIS_VERSION=${ATLANTIS_VERSION}
@@ -42,7 +46,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
4246
COPY . /app
4347
RUN --mount=type=cache,target=/go/pkg/mod \
4448
--mount=type=cache,target=/root/.cache/go-build \
45-
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X 'main.version=${ATLANTIS_VERSION}' -X 'main.commit=${ATLANTIS_COMMIT}' -X 'main.date=${ATLANTIS_DATE}'" -v -o atlantis .
49+
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags "-s -w -X 'main.version=${ATLANTIS_VERSION}' -X 'main.commit=${ATLANTIS_COMMIT}' -X 'main.date=${ATLANTIS_DATE}'" -v -o atlantis .
4650

4751
FROM debian:${DEBIAN_TAG} AS debian-base
4852

package-lock.json

+3-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/controllers/events/events_controller_e2e_test.go

+33-3
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,25 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) {
948948
{"exp-output-merge.txt"},
949949
},
950950
},
951+
{
952+
Description: "1 failing policy and 1 passing policy with --quiet-policy-checks",
953+
RepoDir: "policy-checks-multi-projects",
954+
ModifiedFiles: []string{"dir1/main.tf,", "dir2/main.tf"},
955+
PolicyCheck: true,
956+
ExpAutoplan: true,
957+
ExpPolicyChecks: true,
958+
ExpQuietPolicyChecks: true,
959+
ExpQuietPolicyCheckFailure: true,
960+
Comments: []string{
961+
"atlantis apply",
962+
},
963+
ExpReplies: [][]string{
964+
{"exp-output-autoplan.txt"},
965+
{"exp-output-auto-policy-check-quiet.txt"},
966+
{"exp-output-apply.txt"},
967+
{"exp-output-merge.txt"},
968+
},
969+
},
951970
{
952971
Description: "failing policy without policies passing using extra args",
953972
RepoDir: "policy-checks-extra-args",
@@ -1183,7 +1202,7 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) {
11831202
userConfig.EnablePolicyChecksFlag = c.PolicyCheck
11841203
userConfig.QuietPolicyChecks = c.ExpQuietPolicyChecks
11851204

1186-
ctrl, vcsClient, githubGetter, atlantisWorkspace := setupE2E(t, c.RepoDir, setupOption{})
1205+
ctrl, vcsClient, githubGetter, atlantisWorkspace := setupE2E(t, c.RepoDir, setupOption{userConfig: userConfig})
11871206

11881207
// Set the repo to be cloned through the testing backdoor.
11891208
repoDir, headSHA := initializeRepo(t, c.RepoDir)
@@ -1274,13 +1293,13 @@ type setupOption struct {
12741293
allowCommands []command.Name
12751294
disableAutoplan bool
12761295
disablePreWorkflowHooks bool
1296+
userConfig server.UserConfig
12771297
}
12781298

12791299
func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers.VCSEventsController, *vcsmocks.MockClient, *mocks.MockGithubPullGetter, *events.FileWorkspace) {
12801300
allowForkPRs := false
12811301
discardApprovalOnPlan := true
12821302
dataDir, binDir, cacheDir := mkSubDirs(t)
1283-
12841303
// Mocks.
12851304
e2eVCSClient := vcsmocks.NewMockClient()
12861305
e2eStatusUpdater := &events.DefaultCommitStatusUpdater{Client: e2eVCSClient}
@@ -1493,7 +1512,18 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers
14931512
pullUpdater := &events.PullUpdater{
14941513
HidePrevPlanComments: false,
14951514
VCSClient: e2eVCSClient,
1496-
MarkdownRenderer: events.NewMarkdownRenderer(false, false, false, false, false, false, "", "atlantis", false),
1515+
MarkdownRenderer: events.NewMarkdownRenderer(
1516+
false, // gitlabSupportsCommonMark
1517+
false, // disableApplyAll
1518+
false, // disableApply
1519+
false, // disableMarkdownFolding
1520+
false, // disableRepoLocking
1521+
false, // enableDiffMarkdownFormat
1522+
"", // markdownTemplateOverridesDir
1523+
"atlantis", // executableName
1524+
false, // hideUnchangedPlanComments
1525+
opt.userConfig.QuietPolicyChecks, // quietPolicyChecks
1526+
),
14971527
}
14981528

14991529
autoMerger := &events.AutoMerger{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Ran Policy Check for 2 projects:
2+
3+
1. dir: `dir1` workspace: `default`
4+
1. dir: `dir2` workspace: `default`
5+
---
6+
7+
### 2. dir: `dir2` workspace: `default`
8+
**Policy Check Failed**: Some policy sets did not pass.
9+
#### Policy Set: `test_policy`
10+
```diff
11+
FAIL - <redacted plan file> - main - WARNING: Forbidden Resource creation is prohibited.
12+
13+
1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions
14+
15+
```
16+
17+
18+
#### Policy Approval Status:
19+
```
20+
policy set: test_policy: requires: 1 approval(s), have: 0.
21+
```
22+
* :heavy_check_mark: To **approve** this project, comment:
23+
```shell
24+
atlantis approve_policies -d dir2
25+
```
26+
* :put_litter_in_its_place: To **delete** this plan and lock, click [here](lock-url)
27+
* :repeat: To re-run policies **plan** this project again by commenting:
28+
```shell
29+
atlantis plan -d dir2
30+
```
31+
32+
---
33+
* :heavy_check_mark: To **approve** all unapplied plans from this Pull Request, comment:
34+
```shell
35+
atlantis approve_policies
36+
```
37+
* :put_litter_in_its_place: To **delete** all plans and locks from this Pull Request, comment:
38+
```shell
39+
atlantis unlock
40+
```
41+
* :repeat: To re-run policies **plan** this project again by commenting:
42+
```shell
43+
atlantis plan
44+
```

server/events/command_runner_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.Mock
126126
pullUpdater = &events.PullUpdater{
127127
HidePrevPlanComments: false,
128128
VCSClient: vcsClient,
129-
MarkdownRenderer: events.NewMarkdownRenderer(false, false, false, false, false, false, "", "atlantis", false),
129+
MarkdownRenderer: events.NewMarkdownRenderer(false, false, false, false, false, false, "", "atlantis", false, false),
130130
}
131131

132132
autoMerger = &events.AutoMerger{

server/events/markdown_renderer.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type MarkdownRenderer struct {
5757
markdownTemplates *template.Template
5858
executableName string
5959
hideUnchangedPlanComments bool
60+
quietPolicyChecks bool
6061
}
6162

6263
// commonData is data that all responses have.
@@ -72,6 +73,7 @@ type commonData struct {
7273
EnableDiffMarkdownFormat bool
7374
ExecutableName string
7475
HideUnchangedPlanComments bool
76+
QuietPolicyChecks bool
7577
VcsRequestType string
7678
}
7779

@@ -131,11 +133,12 @@ type policyCheckResultsData struct {
131133
}
132134

133135
type projectResultTmplData struct {
134-
Workspace string
135-
RepoRelDir string
136-
ProjectName string
137-
Rendered string
138-
NoChanges bool
136+
Workspace string
137+
RepoRelDir string
138+
ProjectName string
139+
Rendered string
140+
NoChanges bool
141+
IsSuccessful bool
139142
}
140143

141144
// Initialize templates
@@ -149,6 +152,7 @@ func NewMarkdownRenderer(
149152
markdownTemplateOverridesDir string,
150153
executableName string,
151154
hideUnchangedPlanComments bool,
155+
quietPolicyChecks bool,
152156
) *MarkdownRenderer {
153157
var templates *template.Template
154158
templates, _ = template.New("").Funcs(sprig.TxtFuncMap()).ParseFS(templatesFS, "templates/*.tmpl")
@@ -166,6 +170,7 @@ func NewMarkdownRenderer(
166170
markdownTemplates: templates,
167171
executableName: executableName,
168172
hideUnchangedPlanComments: hideUnchangedPlanComments,
173+
quietPolicyChecks: quietPolicyChecks,
169174
}
170175
}
171176

@@ -192,6 +197,7 @@ func (m *MarkdownRenderer) Render(ctx *command.Context, res command.Result, cmd
192197
EnableDiffMarkdownFormat: m.enableDiffMarkdownFormat,
193198
ExecutableName: m.executableName,
194199
HideUnchangedPlanComments: m.hideUnchangedPlanComments,
200+
QuietPolicyChecks: m.quietPolicyChecks,
195201
VcsRequestType: vcsRequestType,
196202
}
197203

@@ -224,9 +230,10 @@ func (m *MarkdownRenderer) renderProjectResults(ctx *command.Context, results []
224230

225231
for _, result := range results {
226232
resultData := projectResultTmplData{
227-
Workspace: result.Workspace,
228-
RepoRelDir: result.RepoRelDir,
229-
ProjectName: result.ProjectName,
233+
Workspace: result.Workspace,
234+
RepoRelDir: result.RepoRelDir,
235+
ProjectName: result.ProjectName,
236+
IsSuccessful: result.IsSuccessful(),
230237
}
231238
if result.PlanSuccess != nil {
232239
result.PlanSuccess.TerraformOutput = strings.TrimSpace(result.PlanSuccess.TerraformOutput)

0 commit comments

Comments
 (0)