Skip to content

Commit 18708b3

Browse files
authored
feat: Adds new workflows for release and dependabot (#34)
* feat: Adds a new release workflow; tweaks test workflow; adds dependabot workflow; adds new script to copy /dist to a bucket; deletes superfluous test workflow."
1 parent 0740b3d commit 18708b3

File tree

8 files changed

+434
-168
lines changed

8 files changed

+434
-168
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 Google LLC
1+
# Copyright 2025 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

.github/workflows/dependabot.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Dependabot
16+
on: pull_request
17+
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
dependabot:
23+
runs-on: ubuntu-latest
24+
if: ${{ github.actor == 'dependabot[bot]' }}
25+
env:
26+
PR_URL: ${{ github.event.pull_request.html_url }}
27+
GITHUB_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
28+
steps:
29+
- name: approve
30+
run: gh pr review --approve "$PR_URL"
31+
- name: merge
32+
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
33+

.github/workflows/e2e.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: e2e
16+
on:
17+
pull_request:
18+
branches:
19+
- main
20+
pull_request_review:
21+
types: [submitted]
22+
push:
23+
branches:
24+
- main
25+
schedule:
26+
- cron: "0 12 * * *"
27+
concurrency:
28+
group: e2e-${{ github.ref }}
29+
cancel-in-progress: true
30+
jobs:
31+
build:
32+
if: >-
33+
github.event_name == 'schedule' ||
34+
(github.event_name == 'push' &&
35+
!contains(github.event.head_commit.message, 'chore: update dist folder')) ||
36+
(github.event_name == 'pull_request_review' &&
37+
github.event.review.state == 'approved')
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
shard: [1, 2, 3, 4, 5, 6, 7, 8]
42+
fail-fast: false
43+
steps:
44+
- uses: actions/checkout@v2
45+
with:
46+
lfs: true
47+
- uses: actions/cache@v2
48+
with:
49+
path: ~/.npm
50+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
51+
restore-keys: |
52+
${{ runner.os }}-node
53+
- uses: actions/cache@v2
54+
with:
55+
path: ~/.cache/ms-playwright
56+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-e2e
57+
restore-keys: |
58+
${{ runner.os }}-node-e2e
59+
- run: npm ci
60+
env:
61+
# https://playwright.dev/docs/installation/#skip-browser-downloads
62+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
63+
- run: npm run build
64+
- run: npx playwright install-deps
65+
- run: npx playwright install
66+
- run: npx playwright test -- --shard=${{matrix.shard}}/8
67+
env:
68+
CI: true
69+
- name: Push test report to artifacts
70+
uses: actions/upload-artifact@v4
71+
if: failure()
72+
with:
73+
name: Test Results
74+
path: test-results/

.github/workflows/playwright.yml

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
1-
name: Playwright Tests
1+
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Test
217
on:
318
push:
419
branches: [ main ]
520
pull_request:
621
branches: [ main ]
22+
types: [opened, synchronize, edited]
23+
concurrency:
24+
group: test-${{ github.ref }}
25+
cancel-in-progress: true
726
jobs:
827
test:
9-
timeout-minutes: 60
28+
if: github.event.pull_request.merged == false
1029
runs-on: ubuntu-latest
1130
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-node@v4
14-
with:
15-
node-version: lts/*
16-
- name: Install dependencies
17-
run: npm ci
18-
- name: Install Playwright Browsers
19-
run: npx playwright install --with-deps
20-
- name: Run Playwright tests
21-
run: npx playwright test
22-
- uses: actions/upload-artifact@v4
23-
if: ${{ !cancelled() }}
24-
with:
25-
name: playwright-report
26-
path: playwright-report/
27-
retention-days: 30
31+
- uses: actions/checkout@v4
32+
if: github.actor != 'dependabot[bot]'
33+
- uses: actions/checkout@v4
34+
if: github.actor == 'dependabot[bot]'
35+
- uses: actions/cache@v4
36+
with:
37+
path: ~/.npm
38+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
39+
restore-keys: |
40+
${{ runner.os }}-node
41+
- uses: actions/cache@v4 # Cache Playwright browsers
42+
with:
43+
path: ~/.cache/ms-playwright
44+
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }} # Cache key based on config files
45+
restore-keys: |
46+
${{ runner.os }}-playwright-
47+
- run: npm i
48+
- run: npx playwright install
49+
- run: npx playwright test
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
## Runs the release-please action for all new pushes to the main branch.
16+
## This will create new release-PRs, create GitHub releases, update
17+
## the CHANGELOG.md, and upload /dist to the Cloud bucket.
18+
19+
on:
20+
push:
21+
branches: [main]
22+
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
27+
name: Release Please
28+
29+
jobs:
30+
release-please:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- id: release
34+
name: Release Please
35+
uses: google-github-actions/release-please-action@v3
36+
with:
37+
release-type: node
38+
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
39+
package-name: "@googlemaps/js-api-samples"
40+
bump-minor-pre-major: true
41+
42+
- if: ${{ steps.release.outputs.release_created }}
43+
name: Checkout
44+
uses: actions/checkout@v3
45+
46+
- if: ${{ steps.release.outputs.release_created }}
47+
name: Setup Node
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: 20
51+
cache: 'npm' # Cache node_modules
52+
53+
- if: ${{ steps.release.outputs.release_created }}
54+
name: Install Dependencies
55+
run: npm ci
56+
57+
- if: ${{ steps.release.outputs.release_created }}
58+
name: Build
59+
run: npm run build
60+
61+
- if: ${{ steps.release.outputs.release_created }}
62+
name: Update dist
63+
run: |
64+
git config --global user.name 'googlemaps-bot'
65+
git config --global user.email '[email protected]'
66+
git add dist
67+
git commit -m "chore: update dist folder [skip ci]" || true
68+
git push origin
69+
70+
# Upload /dist to the Cloud bucket.
71+
- if: ${{ steps.release.outputs.release_created }}
72+
name: Upload to Cloud Bucket
73+
run: |
74+
bash ./upload-to-bucket.sh
75+
env:
76+
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_CREDENTIALS }}
77+
78+
# NPM Publishing (unchanged)
79+
- if: ${{ steps.release.outputs.release_created }}
80+
name: Setup Node for Publishing
81+
uses: actions/setup-node@v3
82+
with:
83+
node-version: 20
84+
registry-url: "https://wombat-dressing-room.appspot.com/"
85+
86+
- if: ${{ steps.release.outputs.release_created }}
87+
name: Publish
88+
run: npm publish
89+
env:
90+
NODE_AUTH_TOKEN: ${{ secrets.NPM_WOMBAT_TOKEN }}
91+
92+
- if: ${{ steps.release.outputs.release_created }}
93+
name: Upload to Cloud Bucket
94+
run: |
95+
bash ./upload-to-bucket.sh
96+
env:
97+
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_CREDENTIALS }}

.github/workflows/test.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)