Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into cesium.com
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeshurun Hembd committed Jun 3, 2024
2 parents 883c523 + 082d5e3 commit 8c835b2
Show file tree
Hide file tree
Showing 213 changed files with 6,767 additions and 4,788 deletions.
23 changes: 0 additions & 23 deletions .eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .github/actions/check-for-CLA/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
94 changes: 48 additions & 46 deletions .github/actions/check-for-CLA/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Octokit } from "@octokit/core";
import { google } from "googleapis";
import Handlebars from "handlebars";
import fs from "fs-extra";
import { dirname, join } from "path";
import { fileURLToPath } from "url";

const PULL_REQUST_INFO = {
id: process.env.PULL_REQUEST_ID,
Expand All @@ -20,30 +22,26 @@ const GOOGLE_SHEETS_INFO = {
const CONTRIBUTORS_URL =
"https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTORS.md";

const main = async () => {
let hasSignedCLA;
let errorFoundOnCLACheck;
const getGoogleSheetsApiClient = async () => {
const googleConfigFilePath = "GoogleConfig.json";
fs.writeFileSync(googleConfigFilePath, GOOGLE_SHEETS_INFO.APIKeys);

try {
hasSignedCLA = await checkIfUserHasSignedAnyCLA();
} catch (error) {
errorFoundOnCLACheck = error.toString();
}
const auth = new google.auth.GoogleAuth({
keyFile: googleConfigFilePath,
scopes: ["https://www.googleapis.com/auth/spreadsheets"],
});
const googleAuthClient = await auth.getClient();

const response = await postCommentOnPullRequest(
hasSignedCLA,
errorFoundOnCLACheck
);
return google.sheets({ version: "v4", auth: googleAuthClient });
};

const checkIfUserHasSignedAnyCLA = async () => {
let foundIndividualCLA = await checkIfIndividualCLAFound();
if (foundIndividualCLA) {
return true;
}
const getValuesFromGoogleSheet = async (sheetId, cellRanges) => {
const googleSheetsApi = await getGoogleSheetsApiClient();

let foundCorporateCLA = await checkIfCorporateCLAFound();
return foundCorporateCLA;
return googleSheetsApi.spreadsheets.values.get({
spreadsheetId: sheetId,
range: cellRanges,
});
};

const checkIfIndividualCLAFound = async () => {
Expand Down Expand Up @@ -95,26 +93,34 @@ const checkIfCorporateCLAFound = async () => {
return false;
};

const getValuesFromGoogleSheet = async (sheetId, cellRanges) => {
const googleSheetsApi = await getGoogleSheetsApiClient();
const checkIfUserHasSignedAnyCLA = async () => {
const foundIndividualCLA = await checkIfIndividualCLAFound();
if (foundIndividualCLA) {
return true;
}

return googleSheetsApi.spreadsheets.values.get({
spreadsheetId: sheetId,
range: cellRanges,
});
const foundCorporateCLA = await checkIfCorporateCLAFound();
return foundCorporateCLA;
};

const getGoogleSheetsApiClient = async () => {
const googleConfigFilePath = "GoogleConfig.json";
fs.writeFileSync(googleConfigFilePath, GOOGLE_SHEETS_INFO.APIKeys);
const getCommentBody = (hasSignedCLA, errorFoundOnCLACheck) => {
const commentTemplate = fs.readFileSync(
join(
dirname(fileURLToPath(import.meta.url)),
"templates/pullRequestComment.hbs"
),
"utf-8"
);

const auth = new google.auth.GoogleAuth({
keyFile: googleConfigFilePath,
scopes: ["https://www.googleapis.com/auth/spreadsheets"],
const getCommentFromTemplate = Handlebars.compile(commentTemplate);
const commentBody = getCommentFromTemplate({
errorCla: errorFoundOnCLACheck,
hasCla: hasSignedCLA,
username: PULL_REQUST_INFO.username,
contributorsUrl: CONTRIBUTORS_URL,
});
const googleAuthClient = await auth.getClient();

return google.sheets({ version: "v4", auth: googleAuthClient });
return commentBody;
};

const postCommentOnPullRequest = async (hasSignedCLA, errorFoundOnCLACheck) => {
Expand All @@ -136,21 +142,17 @@ const postCommentOnPullRequest = async (hasSignedCLA, errorFoundOnCLACheck) => {
);
};

const getCommentBody = (hasSignedCLA, errorFoundOnCLACheck) => {
const commentTemplate = fs.readFileSync(
"./.github/actions/check-for-CLA/templates/pullRequestComment.hbs",
"utf-8"
);
const main = async () => {
let hasSignedCLA;
let errorFoundOnCLACheck;

const getCommentFromTemplate = Handlebars.compile(commentTemplate);
const commentBody = getCommentFromTemplate({
errorCla: errorFoundOnCLACheck,
hasCla: hasSignedCLA,
username: PULL_REQUST_INFO.username,
contributorsUrl: CONTRIBUTORS_URL,
});
try {
hasSignedCLA = await checkIfUserHasSignedAnyCLA();
} catch (error) {
errorFoundOnCLACheck = error.toString();
}

return commentBody;
await postCommentOnPullRequest(hasSignedCLA, errorFoundOnCLACheck);
};

main();
21 changes: 21 additions & 0 deletions .github/actions/check-for-CLA/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@cesium/check-for-cla",
"version": "0.1.0",
"main": "index.js",
"dependencies": {
"@octokit/core": "^6.1.2",
"fs-extra": "^11.2.0",
"googleapis": "^137.1.0",
"handlebars": "^4.7.8"
},
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/CesiumGS/cesium.git"
},
"license": "Apache-2.0",
"author": {
"name": "Cesium GS, Inc.",
"url": "https://cesium.com"
}
}
6 changes: 4 additions & 2 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ jobs:
with:
node-version: '20'
- name: install npm packages
run: npm install googleapis @octokit/core handlebars fs-extra
working-directory: ./.github/actions/check-for-CLA
run: npm install
- name: run script
run: node .github/actions/check-for-CLA/index.js
working-directory: ./.github/actions/check-for-CLA
run: node index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_ID: ${{ github.event.number }}
Expand Down
12 changes: 6 additions & 6 deletions .slackbot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
releaseSchedule:
- jjspace, 4/1/2024
- jjhembd, 5/1/2024
- ggetz, 6/1/2024
- ggetz, 5/1/2024
- jjhembd, 6/1/2024
- jjspace, 7/1/2024
- jjhembd, 8/1/2024
- ggetz, 9/1/2024
- ggetz, 8/1/2024
- jjhembd, 9/1/2024
- jjspace, 10/1/2024
- jjhembd, 11/1/2024
- ggetz, 12/1/2024
- ggetz, 11/1/2024
- jjhembd, 12/1/2024

3 changes: 0 additions & 3 deletions Apps/.eslintrc.json

This file was deleted.

30 changes: 0 additions & 30 deletions Apps/Sandcastle/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 8c835b2

Please sign in to comment.