Skip to content

Commit

Permalink
Merge branch 'main' into #11443-fixing-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
devkthines authored Aug 29, 2024
2 parents 0957323 + 088c4a2 commit 8d2151c
Show file tree
Hide file tree
Showing 843 changed files with 40,938 additions and 18,146 deletions.
25 changes: 0 additions & 25 deletions .eslintignore

This file was deleted.

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

This file was deleted.

28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Report a bug
description: Let us know so we can fix it!
labels: ["needs triage", "type - bug"]
body:
- type: markdown
attributes:
value: |
Thanks for helping us improve CesiumJS! Please describe what the expected behavior is vs what actually happens.
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
validations:
required: true
- type: textarea
id: repro
attributes:
label: Reproduction steps
description: "How do you trigger this bug? Please walk us through it step by step."
value: |
1.
2.
3.
...
- type: input
id: sandcastle
attributes:
label: Sandcastle example
description: Creating a Sandcastle example (https://sandcastle.cesium.com) that reproduces the issue helps us a lot in tracking down bugs. Paste the link you get from the "Share" button in Sandcastle below.
placeholder: ex. https://sandcastle.cesium.com/...
validations:
required: false
- type: textarea
id: environment
attributes:
label: Environment
description: What Browsers, OS, and CesiumJS version are you experiencing this issue on?
value: |
Browser:
CesiumJS Version:
Operating System:
- type: markdown
attributes:
value: |
If you can also contribute a fix, we'd absolutely appreciate it! Fixing a bug in CesiumJS often means fixing a bug for thousands of applications and millions of end users.
Check out the contributor guide to get started: [CONTRIBUTING.md](https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTING.md)
Just let us know you're working on it and we'd be happy to provide advice and feedback.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Ask a question
url: https://community.cesium.com/c/cesiumjs/5
about: CesiumJS is a big project, so we use GitHub for feature requests and bug tracking exclusively. Please use the community forum for general questions. The Cesium team and community actively monitor it and love seeing what people are working on!
14 changes: 0 additions & 14 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Request a feature
description: New ideas & improvements to CesiumJS are always welcome.
labels: ["needs triage", "type - enhancement"]
body:
- type: markdown
attributes:
value: |
Thanks for helping make CesiumJS better!
When suggesting an idea, give examples of the intended use case. Features that benefit the wider community are more likely to be prioritized.
- type: textarea
id: new-feature
attributes:
label: Feature
validations:
required: true
- type: markdown
attributes:
value: |
The best way to get your ideas into CesiumJS is to help us! We love contributions and are always happy to be provide feedback and advice. Check out the contributor guide to get started: [CONTRIBUTING.md](https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTING.md)
6 changes: 0 additions & 6 deletions .github/ISSUE_TEMPLATE/question.md

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
158 changes: 158 additions & 0 deletions .github/actions/check-for-CLA/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
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,
owner: process.env.GITHUB_REPOSITORY.split("/")[0],
repoName: process.env.GITHUB_REPOSITORY.split("/")[1],
username: process.env.GITHUB_ACTOR,
gitHubToken: process.env.GITHUB_TOKEN,
};

const GOOGLE_SHEETS_INFO = {
APIKeys: process.env.GOOGLE_KEYS,
individualCLASheetId: process.env.INDIVIDUAL_CLA_SHEET_ID,
corporateCLASheetId: process.env.CORPORATE_CLA_SHEET_ID,
};

const CONTRIBUTORS_URL =
"https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTORS.md";

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

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

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

const getValuesFromGoogleSheet = async (sheetId, cellRanges) => {
const googleSheetsApi = await getGoogleSheetsApiClient();

return googleSheetsApi.spreadsheets.values.get({
spreadsheetId: sheetId,
range: cellRanges,
});
};

const checkIfIndividualCLAFound = async () => {
const response = await getValuesFromGoogleSheet(
GOOGLE_SHEETS_INFO.individualCLASheetId,
"D2:D"
);

const rows = response.data.values;
for (let i = 0; i < rows.length; i++) {
if (rows[i].length === 0) {
continue;
}

const rowUsername = rows[i][0].toLowerCase();
if (PULL_REQUST_INFO.username.toLowerCase() === rowUsername) {
return true;
}
}

return false;
};

const checkIfCorporateCLAFound = async () => {
const response = await getValuesFromGoogleSheet(
GOOGLE_SHEETS_INFO.corporateCLASheetId,
"H2:H"
);

const rows = response.data.values;
for (let i = 0; i < rows.length; i++) {
if (rows[i].length === 0) {
continue;
}

// We're more lenient with the ScheduleA username check since it's an unformatted text field.
let rowScheduleA = rows[i][0].toLowerCase();
rowScheduleA = rowScheduleA.replace(/\n/g, " ");
const words = rowScheduleA.split(" ");

for (let j = 0; j < words.length; j++) {
// Checking for substrings because many GitHub usernames added as "github.com/username".
if (words[j].includes(PULL_REQUST_INFO.username.toLowerCase())) {
return true;
}
}
}

return false;
};

const checkIfUserHasSignedAnyCLA = async () => {
const foundIndividualCLA = await checkIfIndividualCLAFound();
if (foundIndividualCLA) {
return true;
}

const foundCorporateCLA = await checkIfCorporateCLAFound();
return foundCorporateCLA;
};

const getCommentBody = (hasSignedCLA, errorFoundOnCLACheck) => {
const commentTemplate = fs.readFileSync(
join(
dirname(fileURLToPath(import.meta.url)),
"templates/pullRequestComment.hbs"
),
"utf-8"
);

const getCommentFromTemplate = Handlebars.compile(commentTemplate);
const commentBody = getCommentFromTemplate({
errorCla: errorFoundOnCLACheck,
hasCla: hasSignedCLA,
username: PULL_REQUST_INFO.username,
contributorsUrl: CONTRIBUTORS_URL,
});

return commentBody;
};

const postCommentOnPullRequest = async (hasSignedCLA, errorFoundOnCLACheck) => {
const octokit = new Octokit();

return octokit.request(
`POST /repos/${PULL_REQUST_INFO.owner}/${PULL_REQUST_INFO.repoName}/issues/${PULL_REQUST_INFO.id}/comments`,
{
owner: PULL_REQUST_INFO.username,
repo: PULL_REQUST_INFO.repoName,
issue_number: PULL_REQUST_INFO.id,
body: getCommentBody(hasSignedCLA, errorFoundOnCLACheck),
headers: {
authorization: `bearer ${PULL_REQUST_INFO.gitHubToken}`,
accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
}
);
};

const main = async () => {
let hasSignedCLA;
let errorFoundOnCLACheck;

try {
hasSignedCLA = await checkIfUserHasSignedAnyCLA();
} catch (error) {
errorFoundOnCLACheck = error.toString();
}

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"
}
}
20 changes: 20 additions & 0 deletions .github/actions/check-for-CLA/templates/pullRequestComment.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{#if errorCla}}
:red_circle: There was an error checking the CLA! If this is your first contribution, please send in a [Contributor License Agreement](https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTING.md#contributor-license-agreement-cla).
```
{{ errorCla }}
```
{{else}}
{{#if hasCla}}
Thank you for the pull request, @{{ username }}!

:white_check_mark: We can confirm we have a CLA on file for you.
{{else}}
Thank you for the pull request, @{{ username }}! Welcome to the Cesium community!

In order for us to review your PR, please complete the following steps:
- [ ] Send in a [Contributor License Agreement](https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTING.md#contributor-license-agreement-cla) (CLA)
- [ ] Add yourself to the [contributors]({{ contributorsUrl }}) file

Review [Pull Request Guidelines](https://github.com/CesiumGS/cesium/blob/main/CONTRIBUTING.md#pull-request-guidelines) to make sure your PR gets accepted quickly.
{{/if}}
{{/if}}
7 changes: 7 additions & 0 deletions .github/actions/verify-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: verify node package
description: verifies Node.js use of the npm package
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/script.sh
shell: bash
Loading

0 comments on commit 8d2151c

Please sign in to comment.