Skip to content

chore: update dashboard functions #9504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/dashboard/functions/functions.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export {payloadGithubStatus} from './payload-github-status';
export {pullRequestsWithConflicts} from './pull-requests-with-conflicts';
13 changes: 1 addition & 12 deletions tools/dashboard/functions/github/github-api.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import {GraphQLClient} from 'graphql-request';
import {config} from 'firebase-functions';
import * as GithubApi from 'github';
import * as GithubApi from '@octokit/rest';

/** API token for the Github repository. Required to set the github status on commits and PRs. */
const githubAccessToken = config().secret.github;

/** API Endpoint for the Github API v4 using GraphQL. */
const githubApiV4Endpoint = 'https://api.github.com/graphql';

/** Export the GitHub V3 API instance that is authenticated. */
export const githubApiV3 = new GithubApi();

/** Export the GraphQL client that can be used to query the Github API v4. */
export const githubApiV4 = new GraphQLClient(githubApiV4Endpoint, {
headers: {
Authorization: `Bearer ${githubAccessToken}`,
}
});

// Authenticate the Github API package with the user token.
githubApiV3.authenticate({type: 'token', token: githubAccessToken});
43 changes: 0 additions & 43 deletions tools/dashboard/functions/github/github-graphql-queries.ts

This file was deleted.

20 changes: 10 additions & 10 deletions tools/dashboard/functions/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "material2-board-functions",
"version": "0.0.1",
"version": "0.0.0",
"main": "index.js",
"dependencies": {
"@types/jsonwebtoken": "^7.2.1",
"firebase-admin": "~4.2.1",
"firebase-functions": "^0.5.7",
"github": "^10.0.0",
"graphql-request": "^1.3.4",
"jsonwebtoken": "^7.4.1",
"request": "^2.81.0",
"ts-node": "^3.0.6",
"typescript": "^2.3.4"
"@firebase/app-types": "^0.1.1",
"@octokit/rest": "^14.0.4",
"@types/jsonwebtoken": "^7.2.5",
"firebase-admin": "^5.8.1",
"firebase-functions": "^0.8.1",
"jsonwebtoken": "^8.1.0",
"request": "^2.83.0",
"ts-node": "^4.1.0",
"typescript": "^2.6.2"
}
}
19 changes: 12 additions & 7 deletions tools/dashboard/functions/payload-github-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ export const payloadGithubStatus = https.onRequest(async (request, response) =>
const diffFormatted = Math.abs(packageDiff).toFixed(2);
const packageSizeFormatted = packageSize.toFixed(2);

await setGithubStatus(commitSha, {
result: true,
name: `${capitalizeFirstLetter(packageName)} Payload Size`,
description: `${packageSizeFormatted}kb / ${diffFormatted}kb ${diffMessage} (ES2015 bundle)`
});

response.json({message: 'Payload Github status successfully set.'});
try {
await setGithubStatus(commitSha, {
result: true,
name: `${capitalizeFirstLetter(packageName)} Payload Size`,
description: `${packageSizeFormatted}kb / ${diffFormatted}kb ${diffMessage} (ES2015 bundle)`
});

response.json({message: 'Payload Github status successfully set.'});
} catch (e) {
response.json({message: 'An error occurred while setting the GitHub status.'});
console.error('An error occurred while setting Github status.', e);
}
});

/** Capitalizes the first letter of a string. */
Expand Down
13 changes: 0 additions & 13 deletions tools/dashboard/functions/pull-requests-with-conflicts.ts

This file was deleted.