Skip to content

Commit b0d8742

Browse files
authored
chore: revamp gha workflows (#137)
1 parent 78db85b commit b0d8742

File tree

8 files changed

+197
-70
lines changed

8 files changed

+197
-70
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "npm"
4-
directory: "/"
5-
schedule:
6-
interval: "weekly"
7-
- package-ecosystem: "github-actions"
8-
directory: "/"
9-
schedule:
10-
interval: "weekly"
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/code_health.yaml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,13 @@ on:
55
branches:
66
- main
77
pull_request:
8-
jobs:
9-
check-style:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-node@v4
15-
with:
16-
node-version-file: package.json
17-
cache: "npm"
18-
- name: Install dependencies
19-
run: npm ci
20-
- name: Run style check
21-
run: npm run check
228

23-
check-generate:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-node@v4
29-
with:
30-
node-version-file: package.json
31-
cache: "npm"
32-
- name: Install dependencies
33-
run: npm ci
34-
- run: npm run generate
9+
permissions: {}
3510

11+
jobs:
3612
run-tests:
13+
name: Run MongoDB tests
14+
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
3715
strategy:
3816
matrix:
3917
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -59,6 +37,8 @@ jobs:
5937
path: coverage/lcov.info
6038

6139
run-atlas-tests:
40+
name: Run Atlas tests
41+
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
6242
runs-on: ubuntu-latest
6343
steps:
6444
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
@@ -81,10 +61,12 @@ jobs:
8161
with:
8262
name: atlas-test-results
8363
path: coverage/lcov.info
64+
8465
coverage:
66+
name: Run MongoDB tests
67+
if: always() && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
8568
runs-on: ubuntu-latest
8669
needs: [run-tests, run-atlas-tests]
87-
if: always()
8870
steps:
8971
- uses: actions/checkout@v4
9072
- uses: actions/setup-node@v4
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Code Health (fork)
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
permissions: {}
9+
10+
jobs:
11+
run-tests:
12+
name: Run MongoDB tests
13+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version-file: package.json
21+
cache: "npm"
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Run tests
25+
run: npm test
26+
- name: Upload test results
27+
if: always()
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: test-results
31+
path: coverage/lcov.info
32+
33+
run-atlas-tests:
34+
name: Run Atlas tests
35+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version-file: package.json
43+
cache: "npm"
44+
- name: Install dependencies
45+
run: npm ci
46+
- name: Run tests
47+
env:
48+
MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }}
49+
MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }}
50+
MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }}
51+
run: npm test -- --testPathIgnorePatterns "tests/integration/tools/mongodb" --testPathIgnorePatterns "tests/integration/[^/]+\.ts"
52+
- name: Upload test results
53+
uses: actions/upload-artifact@v4
54+
if: always()
55+
with:
56+
name: atlas-test-results
57+
path: coverage/lcov.info
58+
59+
coverage:
60+
name: Report Coverage
61+
if: always() && github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
62+
runs-on: ubuntu-latest
63+
needs: [run-tests, run-atlas-tests]
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-node@v4
67+
with:
68+
node-version-file: package.json
69+
cache: "npm"
70+
- name: Install dependencies
71+
run: npm ci
72+
- name: Download test results
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: test-results
76+
path: coverage/mongodb
77+
- name: Download atlas test results
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: atlas-test-results
81+
path: coverage/atlas
82+
- name: Merge coverage reports
83+
run: |
84+
npx -y [email protected] "coverage/*/lcov.info" "coverage/lcov.info"
85+
- name: Coveralls GitHub Action
86+
uses: coverallsapp/[email protected]
87+
with:
88+
file: coverage/lcov.info
89+
git-branch: ${{ github.head_ref || github.ref_name }}
90+
git-commit: ${{ github.event.pull_request.head.sha || github.sha }}
91+
92+
merge-dependabot-pr:
93+
name: Merge Dependabot PR
94+
if: github.event.pull_request.user.login == 'dependabot[bot]'
95+
runs-on: ubuntu-latest
96+
permissions:
97+
pull-requests: write
98+
contents: write
99+
needs:
100+
- coverage
101+
steps:
102+
- name: Enable auto-merge for Dependabot PRs
103+
run: gh pr merge --auto --squash "$PR_URL"
104+
env:
105+
PR_URL: ${{github.event.pull_request.html_url}}
106+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/codeql.yml

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
name: "CodeQL Advanced"
22

33
on:
4-
push:
5-
branches: ["main"]
6-
pull_request:
7-
branches: ["main"]
8-
schedule:
9-
- cron: "35 4 * * 4"
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
schedule:
9+
- cron: "35 4 * * 4"
1010

1111
jobs:
12-
analyze:
13-
name: Analyze (${{ matrix.language }})
14-
runs-on: ubuntu-latest
15-
permissions:
16-
security-events: write
17-
packages: read
18-
actions: read
19-
contents: read
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
2017

21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
language:
25-
- actions
26-
- javascript-typescript
27-
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v4
30-
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@v3
32-
with:
33-
languages: ${{ matrix.language }}
34-
- name: Perform CodeQL Analysis
35-
uses: github/codeql-action/analyze@v3
36-
with:
37-
category: "/language:${{matrix.language}}"
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
language:
22+
- actions
23+
- javascript-typescript
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v3
29+
with:
30+
languages: ${{ matrix.language }}
31+
- name: Perform CodeQL Analysis
32+
uses: github/codeql-action/analyze@v3
33+
with:
34+
category: "/language:${{matrix.language}}"

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Lint
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
check-style:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version-file: package.json
20+
cache: "npm"
21+
- name: Install dependencies
22+
run: npm ci
23+
- name: Run style check
24+
run: npm run check
25+
26+
check-generate:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version-file: package.json
34+
cache: "npm"
35+
- name: Install dependencies
36+
run: npm ci
37+
- run: npm run generate

.github/workflows/prepare_release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
required: true
1111
default: "patch"
1212

13+
permissions: {}
14+
1315
jobs:
1416
create-pr:
1517
runs-on: ubuntu-latest

.github/workflows/publish.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
push:
55
branches:
66
- main
7-
permissions:
8-
contents: write
7+
98
jobs:
109
check:
1110
runs-on: ubuntu-latest
11+
permissions: {}
1212
outputs:
1313
VERSION_EXISTS: ${{ steps.check-version.outputs.VERSION_EXISTS }}
1414
VERSION: ${{ steps.get-version.outputs.VERSION }}
@@ -45,7 +45,10 @@ jobs:
4545
publish:
4646
runs-on: ubuntu-latest
4747
environment: Production
48-
needs: check
48+
permissions:
49+
contents: write
50+
needs:
51+
- check
4952
if: needs.check.outputs.VERSION_EXISTS == 'false'
5053
steps:
5154
- uses: GitHubSecurityLab/actions-permissions/monitor@v1

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
},
2929
{
30-
"files": "*.yaml",
30+
"files": ["*.yaml", "*.yml"],
3131
"options": {
3232
"tabWidth": 2,
3333
"printWidth": 80

0 commit comments

Comments
 (0)