Skip to content

Commit 4bc015c

Browse files
authored
Add workflow to update API reports automatically (#5196)
* save * Add GHA to update api reports * push to remote using GHA * fix typo * add v * use head_ref * Trigger CI * update job name * debug * debug again * checkout head commit * use GHA to commit and push * add description * use PAT in order to trigger workflow * use github_actor as the author * use google-oss-bot * test * Update API reports Co-authored-by: Feiyang1 <[email protected]>
1 parent 16958be commit 4bc015c

File tree

4 files changed

+96
-7
lines changed

4 files changed

+96
-7
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Update API reports
2+
3+
on: pull_request
4+
5+
jobs:
6+
update_api_reports:
7+
name: Update API reports
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# checkout HEAD commit instead of merge commit
15+
ref: ${{ github.event.pull_request.head.sha }}
16+
token: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
17+
- name: Set up Node (14)
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 14.x
21+
- name: Yarn install
22+
run: yarn
23+
- name: Update API reports
24+
run: yarn ts-node-script scripts/exp/update-api-reports.ts
25+
id: update-api-reports
26+
- name: Commit & Push changes
27+
uses: EndBug/add-and-commit@v7
28+
with:
29+
add: 'common/api-review/*'
30+
message: 'Update API reports'
31+
default_author: github_actor

common/api-review/app-check-exp.api.md

-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,4 @@ export function setTokenAutoRefreshEnabled(appCheckInstance: AppCheck, isTokenAu
8787
export { Unsubscribe }
8888

8989

90-
// (No @packageDocumentation comment for this package)
91-
9290
```

common/api-review/database.api.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { FirebaseApp } from '@firebase/app';
1010
// @public
1111
export function child(parent: DatabaseReference, path: string): DatabaseReference;
1212

13+
// @public
14+
export function connectDatabaseEmulator(db: Database, host: string, port: number, options?: {
15+
mockUserToken?: EmulatorMockTokenOptions;
16+
}): void;
17+
1318
// @public
1419
export class Database {
1520
readonly app: FirebaseApp;
@@ -23,11 +28,6 @@ export interface DatabaseReference extends Query {
2328
readonly root: DatabaseReference;
2429
}
2530

26-
// @public
27-
export function connectDatabaseEmulator(db: FirebaseDatabase, host: string, port: number, options?: {
28-
mockUserToken?: EmulatorMockTokenOptions;
29-
}): void;
30-
3131
// @public
3232
export class DataSnapshot {
3333
child(path: string): DataSnapshot;

scripts/exp/update-api-reports.ts

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import { spawn } from 'child-process-promise';
18+
import simpleGit from 'simple-git/promise';
19+
import { projectRoot } from '../utils';
20+
21+
const git = simpleGit(projectRoot);
22+
23+
async function updateApiReports() {
24+
/** API reports are generated as part of the builds */
25+
// TODO: change yarn command once exp packages become official
26+
await spawn('yarn', ['lerna', 'run', '--scope', '@firebase/*-exp', 'build'], {
27+
stdio: 'inherit'
28+
});
29+
30+
// build storage-exp
31+
await spawn(
32+
'yarn',
33+
['lerna', 'run', '--scope', '@firebase/storage', 'build:exp'],
34+
{
35+
stdio: 'inherit'
36+
}
37+
);
38+
39+
// build database-exp
40+
await spawn(
41+
'yarn',
42+
['lerna', 'run', '--scope', '@firebase/database', 'build:exp'],
43+
{
44+
stdio: 'inherit'
45+
}
46+
);
47+
48+
// generate public typings for firestore
49+
await spawn(
50+
'yarn',
51+
['lerna', 'run', '--scope', '@firebase/firestore', 'prebuild'],
52+
{
53+
stdio: 'inherit'
54+
}
55+
);
56+
57+
// Committing and Pushing to the remote branch is done in the GHA workflow, see .github/workflows/update-api-reports.yml
58+
}
59+
60+
updateApiReports();

0 commit comments

Comments
 (0)