Skip to content

Commit ea66a4b

Browse files
committed
Merge branch 'master' into CLOUDP-333877
2 parents 790b073 + e84041f commit ea66a4b

File tree

6 files changed

+67
-96
lines changed

6 files changed

+67
-96
lines changed

.github/workflows/breaking-changes.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ jobs:
77
breaking-changes-manifest:
88
name: Generate Breaking Changes Manifest
99
runs-on: ubuntu-latest
10-
outputs:
11-
breaking-changes: ${{ steps.breakvalidator.outputs.JSON }}
1210
steps:
1311
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1412
with:
@@ -24,7 +22,6 @@ jobs:
2422
- name: Install dependencies
2523
run: go mod download
2624
- name: Run breaking changes validator
27-
id: breakvalidator
2825
run: |
2926
set -e
3027
go run ./tools/cmd/breakvalidator generate > main.json
@@ -51,7 +48,6 @@ jobs:
5148
uses: actions/download-artifact@v4
5249
with:
5350
name: breaking-changes-manifest
54-
path: main.json
5551
- name: Run breaking changes validator
5652
run: |
5753
set -e

.github/workflows/code-health.yml

Lines changed: 24 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ${{ matrix.os }}
3535
steps:
3636
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
37-
if: ${{ matrix.os=='ubuntu-latest' }}
37+
if: matrix.os == 'ubuntu-latest'
3838
with:
3939
config: ${{ vars.PERMISSIONS_CONFIG }}
4040
- name: Checkout repository
@@ -45,108 +45,40 @@ jobs:
4545
uses: actions/setup-go@v5
4646
with:
4747
go-version-file: 'go.mod'
48-
- run: go install gotest.tools/gotestsum@latest
48+
- run: |
49+
go install gotest.tools/gotestsum@v1.12.3
50+
go install github.com/mattn/goveralls@v0.0.12
4951
- run: make unit-test
52+
- name: Send coverage
53+
env:
54+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
55+
run: goveralls -parallel -coverprofile="$COVERAGE" -ignore=test/* -service=github
5056
- name: Test Summary
5157
id: test_summary
5258
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
5359
with:
5460
paths: unit-tests.xml
5561
if: always() && matrix.os == 'ubuntu-latest'
56-
- name: Upload coverage file
57-
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
58-
uses: actions/upload-artifact@v4
59-
with:
60-
name: coverage-file
61-
path: coverage.out
6262

63-
code-coverage:
64-
permissions:
65-
pull-requests: write # Required to comment on PRs
66-
needs: unit-tests
67-
if: github.event_name == 'pull_request'
63+
coverage:
6864
runs-on: ubuntu-latest
65+
needs: [unit-tests, e2e-tests]
6966
steps:
7067
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
7168
with:
7269
config: ${{ vars.PERMISSIONS_CONFIG }}
7370
- name: Checkout repository
7471
uses: actions/checkout@v4
75-
with:
76-
fetch-depth: 0
77-
- name: Get merge base
78-
id: merge_base
79-
run: |
80-
MERGE_BASE=$(git merge-base "${{ github.event.pull_request.head.sha }}" "${{ github.event.pull_request.base.sha }}")
81-
echo "merge_base=$MERGE_BASE" >> "$GITHUB_OUTPUT"
82-
echo "Checking coverage against: $MERGE_BASE"
8372
- name: Install Go
8473
uses: actions/setup-go@v5
8574
with:
8675
go-version-file: 'go.mod'
87-
- name: Download coverage file
88-
uses: actions/download-artifact@v4
89-
with:
90-
name: coverage-file
91-
- name: Check coverage cache
92-
id: cache-coverage
93-
uses: actions/cache@v4
94-
with:
95-
path: coverage.base.out
96-
key: coverage-${{ steps.merge_base.outputs.merge_base }}
97-
- name: Generate base coverage
98-
if: steps.cache-coverage.outputs.cache-hit != 'true'
99-
run: |
100-
# Get coverage from base branch
101-
git checkout ${{ steps.merge_base.outputs.merge_base }}
102-
COVERAGE=coverage.base.out make unit-test
103-
- name: Save coverage to cache
104-
if: steps.cache-coverage.outputs.cache-hit != 'true'
105-
uses: actions/cache/save@v4
106-
with:
107-
path: coverage.base.out
108-
key: coverage-${{ steps.merge_base.outputs.merge_base }}
109-
- name: Compare coverage
110-
id: compare
76+
- name: Install goveralls
77+
run: go install github.com/mattn/goveralls@v0.0.12
78+
- name: Send coverage
11179
env:
112-
BASE_REF: ${{ github.base_ref }}
113-
HEAD_REF: ${{ github.head_ref }}
114-
run: |
115-
# use go tool cover to calculate coverage percentage
116-
base_coverage=$(go tool cover -func=coverage.base.out | grep total: | awk '{print $3}' | sed 's/%//')
117-
pr_coverage=$(go tool cover -func=coverage.out | grep total: | awk '{print $3}' | sed 's/%//')
118-
119-
# Calculate difference
120-
diff=$(echo "$pr_coverage - $base_coverage" | bc)
121-
echo "diff=$diff" >> "$GITHUB_OUTPUT"
122-
123-
# Create comment content
124-
if (( $(echo "$diff >= 0" | bc -l) )); then
125-
trend="📈"
126-
else
127-
trend="📉"
128-
fi
129-
130-
{
131-
echo "Coverage Report $trend"
132-
echo "| Branch | Commit | Coverage |"
133-
echo "|--------|--------|----------|"
134-
echo "| ${BASE_REF} | ${{ steps.merge_base.outputs.merge_base }} | ${base_coverage}% |"
135-
echo "| ${HEAD_REF} | ${{ github.event.pull_request.head.sha }} | ${pr_coverage}% |"
136-
echo "| | Difference | ${diff}% |"
137-
} > comment.md
138-
cat "comment.md" >> "$GITHUB_STEP_SUMMARY"
139-
- name: Comment PR
140-
uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943
141-
if: github.event.pull_request.head.repo.full_name == github.repository
142-
with:
143-
recreate: true
144-
path: comment.md
145-
- name: Check coverage threshold
146-
run: |
147-
if (( $(echo "${{ steps.compare.outputs.diff }} < 0" | bc -l) )); then
148-
echo "Error: Coverage difference (${{ steps.compare.outputs.diff }}%) is negative"
149-
fi
80+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
81+
run: goveralls -parallel-finish -ignore=test/* -service=github
15082

15183
libraryOwners:
15284
runs-on: ubuntu-latest
@@ -390,7 +322,9 @@ jobs:
390322
uses: actions/setup-go@v5
391323
with:
392324
go-version-file: 'go.mod'
393-
- run: go install gotest.tools/gotestsum@latest
325+
- run: |
326+
go install gotest.tools/gotestsum@v1.12.3
327+
go install github.com/mattn/goveralls@v0.0.12
394328
- name: set Apix Bot token
395329
id: app-token
396330
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42
@@ -401,6 +335,12 @@ jobs:
401335
env:
402336
GH_TOKEN: ${{ steps.app-token.outputs.token }}
403337
TEST_CMD: gotestsum --junitfile e2e-tests.xml --format standard-verbose --
338+
COVERAGE: coverage.out
339+
- name: Send coverage
340+
env:
341+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
342+
COVERAGE: coverage.out
343+
run: goveralls -parallel -coverprofile="$COVERAGE" -ignore=test/* -service=github
404344
- name: Test Summary
405345
if: always()
406346
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86

CONTRIBUTING.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ If you need a new mock please update or add the `//go:generate` instruction to t
8282

8383
#### Compilation in VSCode
8484

85-
Please add the following line to your settings.json file :
86-
```
85+
Please add the following line to your `.vscode/settings.json` file :
86+
```json
87+
{
8788
"go.buildTags": "unit,e2e",
8889
"go.testTags": "unit,e2e"
90+
}
8991
```
9092

9193
This will enable compilation for unit and end-to-end tests.
@@ -95,7 +97,7 @@ This will enable compilation for unit and end-to-end tests.
9597
To debug in VSCode, you must create a debug configuration for the command with the required arguments.
9698
Run the following commands to create a new launch.json file for the debugger:
9799

98-
```
100+
```shell
99101
touch .vscode/launch.json
100102
```
101103
Then put the following example configuration into the file.
@@ -125,6 +127,36 @@ Review and replace the command name and arguments depending on the command you w
125127
}
126128
```
127129

130+
To debug e2e tests.
131+
132+
```shell
133+
touch .vscode/settings.json
134+
```
135+
136+
Then put the following example configuration into the file.
137+
Review and replace the atlas settings.
138+
139+
```json
140+
{
141+
"go.buildTags": "unit,e2e",
142+
"go.testTags": "unit,e2e",
143+
"go.testEnvVars": {
144+
"ATLAS_E2E_BINARY": "${workspaceFolder}/bin/atlas",
145+
"UPDATE_SNAPSHOTS": "skip",
146+
"SNAPSHOTS_DIR": "${workspaceFolder}/test/e2e/testdata/.snapshots",
147+
"GOCOVERDIR": "${workspaceFolder}/cov",
148+
"DO_NOT_TRACK": "1",
149+
"E2E_SKIP_CLEANUP": "false",
150+
"MONGODB_ATLAS_ORG_ID": "<default org id>",
151+
"MONGODB_ATLAS_PROJECT_ID": "<default project id>",
152+
"MONGODB_ATLAS_PRIVATE_API_KEY": "<private key>",
153+
"MONGODB_ATLAS_PUBLIC_API_KEY": "<public key>",
154+
"MONGODB_ATLAS_OPS_MANAGER_URL": "https://cloud.mongodb.com/",
155+
"MONGODB_ATLAS_SERVICE": "cloud",
156+
}
157+
}
158+
```
159+
128160
### Contributing New Command Group
129161

130162
`Atlas CLI` uses the [Cobra Framework](https://umarcor.github.io/cobra/).

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ e2e-test: build-debug ## Run E2E tests
181181
.PHONY: e2e-test-snapshots
182182
e2e-test-snapshots: build-debug ## Run E2E tests
183183
UPDATE_SNAPSHOTS=false E2E_SKIP_CLEANUP=true DO_NOT_TRACK=1 $(TEST_CMD) -v -timeout $(E2E_TIMEOUT) -tags="e2eSnap" ${E2E_TEST_PACKAGES}. $(E2E_EXTRA_ARGS)
184+
go tool covdata textfmt -i $(GOCOVERDIR) -o $(COVERAGE)
184185

185186
.PHONY: unit-test
186187
unit-test: build-debug ## Run unit-tests

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Coverage Status](https://coveralls.io/repos/github/mongodb/mongodb-atlas-cli/badge.svg?branch=master)](https://coveralls.io/github/mongodb/mongodb-atlas-cli?branch=master)
2+
13
## MongoDB Atlas CLI
24

35
The MongoDB Atlas CLI is a modern command line interface that enables you to manage MongoDB Atlas from the terminal.

tools/cmd/breakvalidator/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import (
2121
)
2222

2323
type flagData struct {
24-
Type string `json:"type"`
25-
Default string `json:"default"`
26-
Short string `json:"short"`
24+
Type string `json:"type,omitempty"`
25+
Default string `json:"default,omitempty"`
26+
Short string `json:"short,omitempty"`
2727
}
2828

2929
type cmdData struct {
30-
Aliases []string `json:"aliases"`
31-
Flags map[string]flagData `json:"flags"`
30+
Aliases []string `json:"aliases,omitempty"`
31+
Flags map[string]flagData `json:"flags,omitempty"`
3232
}
3333

3434
func buildRootCmd() *cobra.Command {

0 commit comments

Comments
 (0)