Skip to content

Commit a3af93b

Browse files
authored
GH Actions & Pull request template (JaylyDev#182)
* tsconfig stuff weird * Update cl.yml * Update packageReadme.ts * a * Revert "Update cl.yml" This reverts commit dacafcb. * Update packageReadme.ts * update editor API. * Update index.d.ts * Tsconfig update * Update jsconfig.json * Update index.js * not using dependabot * e * typo * Update dependency-update.yml * Update dependency-update.yml * Update dependency-update.yml * Create pr instead of push commit * Update packageReadme.ts * Update testScriptChecks.ts * Create pull_request_template.md * schedule only * Update pull_request_template.md * Update cl.yml * Update headerChecks.ts * enable ci for all branches * fix typo * Update pull_request_template.md
1 parent bfbee35 commit a3af93b

6 files changed

Lines changed: 59 additions & 19 deletions

File tree

.github/pull_request_template.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Checklist
2+
3+
Please fill in the checklist. To mark a task as complete, replace `[ ]` with `[x]`.
4+
5+
- [ ] Use a meaningful title for the pull request. Include the name of the script(s) modified.
6+
- [ ] Test your code locally prior to submission.
7+
- [ ] Explain what this pull request make changes on in the description.
8+
9+
### Changes to Scripts:
10+
11+
<!-- Comment out this section if your pull request does not changes script examples. -->
12+
13+
- [ ] Code is up-to-date with latest **beta** version of Script API modules in **latest Minecraft Preview**.
14+
15+
Adding new script examples:
16+
17+
- [ ] Add a README to explain what the scripts do.
18+
- [ ] Add `tests.js` or `tests.ts` file to test against your main script (optional).
19+
- [ ] Add code header in `index.js` or `index.ts` file in your package:
20+
21+
```js
22+
// Script example for ScriptAPI
23+
// Author: Alice <url>
24+
// Bob <url>
25+
// Steve <url>
26+
// Project: https://github.com/JaylyDev/ScriptAPI
27+
```
28+
29+
## Description
30+
31+
<!-- A simple description of what this pull request make changes on. -->
32+

.github/workflows/cl.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
75
pull_request:
86
schedule:
97
## run action every sunday at 20:00 UTC
@@ -32,12 +30,14 @@ jobs:
3230
env:
3331
event_name: ${{ github.event_name }}
3432

35-
- name: Commit Changes
33+
- name: Create Pull Request
3634
if: ${{ github.event_name == 'schedule' }}
37-
uses: EndBug/add-and-commit@v9
35+
uses: peter-evans/create-pull-request@v4
3836
with:
39-
add: ./scripts
40-
message: 'Upload generated files.'
41-
default_author: github_actions
42-
pull: '-v'
43-
force: true
37+
commit-message: Upload generated files
38+
title: Upload generated files for scripts
39+
body: Transpiled TypeScript files and created README files, please review.
40+
labels: scripts
41+
branch: scripts/update
42+
base: main
43+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

.github/workflows/dependency-update.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ jobs:
2929
- name: Create Pull Request
3030
uses: peter-evans/create-pull-request@v4
3131
with:
32-
commit-message: Update package.json
33-
title: Update package.json
32+
commit-message: Update package.json and package-lock.json
33+
title: Update npm packages
3434
body: Updated NPM packages in package.json, please review.
3535
labels: dependencies
3636
branch: dependency/update
3737
base: main
38+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

tools/headerChecks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function checkScripts () {
3232
hasError = true;
3333
}
3434
else if (!!parseError && isEmittedFile) {
35-
errorMessages.push(`${printFilePath(fullpath)} ${renderParseError(parseError)}. Adding header fro ${file} from index.ts`);
35+
errorMessages.push(`${printFilePath(fullpath)} ${renderParseError(parseError)}. Adding header from index.ts to ${file}`);
3636
const fullTspath = path.resolve(scriptPath, tsSourceFilename);
3737
const tsFile = fs.readFileSync(fullTspath).toString();
3838

tools/packageReadme.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@ function isValidHttpUrl(string: string) {
1515

1616
function makeReadme (script: string) {
1717
const indexJs = path.resolve(scriptsPath, script, 'index.js');
18+
const indexTs = path.resolve(scriptsPath, script, 'index.ts');
1819
const readmePath = path.resolve(scriptsPath, script, 'README.md');
1920
const readmeDefault = [
2021
'# ' + script,
2122
'',
2223
'## Description',
23-
'',
24+
'> This README is auto generated, Edit the README so that users know what this package does.',
2425
'',
2526
'## Credits',
2627
'',
2728
''
2829
];
29-
if (!existsSync(indexJs)) {
30-
console.error(script, "missing index.js");
30+
if (!existsSync(indexJs) && !existsSync(indexTs)) {
31+
console.error(script, "missing index.js and index.ts");
3132
writeFileSync(readmePath, readmeDefault.join('\n'));
3233
return;
3334
};
35+
36+
const indexfile = existsSync(indexTs) ? indexTs : indexJs;
3437

3538
/**
3639
* header
3740
*/
38-
const header = parseHeader(readFileSync(indexJs).toString());
41+
const header = parseHeader(readFileSync(indexfile).toString());
3942
if ('contributors' in header) {
4043
const credits = "These scripts were written by " + header.contributors.map((v) => {
4144
if (isValidHttpUrl(v.url)) return `[${v.name}](${v.url})`;
@@ -48,7 +51,7 @@ function makeReadme (script: string) {
4851
writeFileSync(readmePath, readmeDefault.join('\n'));
4952
}
5053
else {
51-
console.error(script, "doesn't have header in index.js");
54+
console.error(script, "doesn't have header in index file");
5255
writeFileSync(readmePath, readmeDefault.join('\n'));
5356
}
5457
}

tools/testScriptChecks.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { printFilePath, scripts, scriptsPath } from "./utils";
44

55
const testFilenames = ['tests', 'tests.js', 'tests.ts'];
66

7-
export function execute (): 0 {
7+
export function execute (): 0 {
8+
const noTestScripts: string[] = [];
9+
810
for (const scriptName of scripts) {
911
const scriptPath = path.resolve(scriptsPath, scriptName);
1012
const files = readdirSync(scriptPath);
1113
const testFiles = files.filter(x => testFilenames.includes(x));
1214

13-
if (testFiles.length <= 0) console.warn(`${printFilePath(scriptPath)} does not have any unit test scripts.`);
15+
if (testFiles.length <= 0) noTestScripts.push(scriptPath);
1416
else {
1517
for (const file of testFiles) {
1618
const filepath = path.resolve(scriptPath, file)
@@ -28,5 +30,7 @@ export function execute (): 0 {
2830
}
2931
};
3032

33+
if (noTestScripts.length > 0) console.warn(`There are ${noTestScripts.length} package(s) do not have any unit test scripts:\n${noTestScripts.map(script => printFilePath(script)).join(', ')} `);
34+
3135
return 0;
3236
}

0 commit comments

Comments
 (0)