Skip to content

Commit 91c015e

Browse files
authored
Merge pull request #3 from gregoranders/development
Development
2 parents 7230163 + f3812bc commit 91c015e

28 files changed

+399
-156
lines changed

.github/actions/build-info/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"esModuleInterop": true,
77
"noImplicitAny": true,
88
"sourceMap": true,
9+
"strict": true,
910
"outDir": "./",
1011
},
1112
"include": [

.github/actions/create-release/index.ts

+19-33
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,36 @@ import { context, GitHub } from "@actions/github";
33

44
import * as Octokit from "@octokit/rest";
55

6+
type IResponse = Octokit.Response<Octokit.ReposGetLatestReleaseResponse | Octokit.ReposCreateReleaseResponse>;
7+
68
async function run(): Promise<void> {
7-
const tag: string = core.getInput("tag", {required: true});
8-
const name: string = core.getInput("name", {required: true});
9+
const tag: string = core.getInput("tag", { required: true });
10+
const name: string = core.getInput("name", { required: true });
911
const body: string = core.getInput("body");
1012
const draft: boolean = core.getInput("draft") === "true";
1113
const prerelease: boolean = core.getInput("prerelease") === "true";
1214
const target_commitish: string = core.getInput("target");
1315

1416
const { owner, repo } = context.repo;
1517

18+
if (!process.env.GITHUB_TOKEN) {
19+
core.setFailed("Missing GitHub token");
20+
return;
21+
}
22+
1623
const github: GitHub = new GitHub(process.env.GITHUB_TOKEN);
1724

18-
let releaseID: number = -1;
19-
let releaseURL: string = "";
20-
let releaseUploadURL: string = "";
25+
let response: undefined | IResponse;
2126

2227
try {
23-
const response: Octokit.Response<Octokit.ReposGetLatestReleaseResponse> = await github.repos.getReleaseByTag({
28+
response = await github.repos.getReleaseByTag({
2429
owner,
2530
repo,
2631
tag,
2732
});
28-
releaseID = response.data.id;
29-
releaseURL = response.data.html_url;
30-
releaseUploadURL = response.data.upload_url;
3133
} catch (error) {
3234
try {
33-
const response: Octokit.Response<Octokit.ReposCreateReleaseResponse> = await github.repos.createRelease({
35+
response = await github.repos.createRelease({
3436
body,
3537
draft,
3638
name,
@@ -40,34 +42,18 @@ async function run(): Promise<void> {
4042
tag_name: tag,
4143
target_commitish,
4244
});
43-
44-
releaseID = response.data.id;
45-
releaseURL = response.data.html_url;
46-
releaseUploadURL = response.data.assets_url;
4745
} catch (createError) {
48-
core.setFailed("Error");
49-
return;
46+
core.setFailed("Error: " + JSON.stringify(createError));
5047
}
5148
}
5249

53-
if (releaseID < 0) {
54-
core.setFailed("Invalid release id " + releaseID);
55-
return;
50+
if (response) {
51+
core.setOutput("id", response.data.id.toString());
52+
core.setOutput("url", response.data.html_url);
53+
core.setOutput("upload_url", response.data.upload_url);
54+
} else {
55+
core.setFailed("Invalid release");
5656
}
57-
58-
if (!releaseURL || !releaseURL.length) {
59-
core.setFailed("Invalid release URL");
60-
return;
61-
}
62-
63-
if (!releaseUploadURL || !releaseUploadURL.length) {
64-
core.setFailed("Invalid release URL");
65-
return;
66-
}
67-
68-
core.setOutput("id", releaseID.toString());
69-
core.setOutput("url", releaseURL);
70-
core.setOutput("upload_url", releaseUploadURL);
7157
}
7258

7359
run();

.github/actions/create-release/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"esModuleInterop": true,
77
"noImplicitAny": true,
88
"sourceMap": true,
9+
"strict": true,
910
"outDir": "./",
1011
},
1112
"include": [

.github/actions/gulpfile.ts

+8-19
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,16 @@ import * as ncc from "@zeit/ncc";
1010

1111
const basePath: fs.PathLike = fs.realpathSync(path.resolve(__dirname, "../.."));
1212

13-
interface INCCCompileOptions {
14-
cache?: boolean;
15-
debugLog?: boolean;
16-
externals?: string[];
17-
filterAssetBase?: string;
18-
minify?: boolean;
19-
quiet?: boolean;
20-
v8cache?: boolean;
21-
}
22-
23-
function nccCompile(options?: INCCCompileOptions): any {
13+
function nccCompile(): any {
2414
return through.obj((chunk: any, encoding: string, callback: through.TransformCallback): any => {
2515
if (chunk.isBuffer()) {
26-
ncc(chunk.path, Object.assign(options, {
16+
ncc(chunk.path, {
17+
cache: false,
18+
minify: false,
19+
quiet: false,
2720
sourceMap: false,
2821
sourceMapRegister: false,
29-
})).then((result: any): void => {
22+
}).then((result: any): void => {
3023
chunk.path = chunk.path.replace(".ts", ".js");
3124
chunk.contents = Buffer.from(result.code);
3225
callback(undefined, chunk);
@@ -38,11 +31,7 @@ function nccCompile(options?: INCCCompileOptions): any {
3831
}
3932

4033
gulp.task("default", (): NodeJS.ReadWriteStream => {
41-
return gulp.src(path.join(basePath, ".github/actions/**/*.ts"))
42-
.pipe(nccCompile({
43-
cache: false,
44-
minify: false,
45-
quiet: false,
46-
}))
34+
return gulp.src(path.join(basePath, ".github/actions/**/index.ts"))
35+
.pipe(nccCompile())
4736
.pipe(gulp.dest(path.resolve(basePath, ".github/actions/")));
4837
});

.github/actions/prepare-release/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"esModuleInterop": true,
77
"noImplicitAny": true,
88
"sourceMap": true,
9+
"strict": true,
910
"outDir": "./",
1011
},
1112
"include": [

.github/actions/upload-asset/index.ts

+25-14
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,33 @@ import * as fs from "fs";
77
import { getType } from "mime";
88
import * as path from "path";
99

10+
async function upload(github: GitHub, filePath: fs.PathLike,
11+
name: string, url: string): Promise<Octokit.ReposUploadReleaseAssetResponseValue> {
12+
const headers: Octokit.ReposUploadReleaseAssetParamsHeaders = {
13+
"content-length": fs.statSync(filePath).size,
14+
"content-type": getType(filePath.toString()) || "application/zip",
15+
};
16+
17+
const response: Octokit.Response<Octokit.ReposUploadReleaseAssetResponse> = await github.repos.uploadReleaseAsset({
18+
file: fs.readFileSync(filePath),
19+
headers,
20+
name,
21+
url,
22+
});
23+
24+
return response.data as any;
25+
}
26+
1027
async function run(): Promise<void> {
1128
const assetUploadURL: string = core.getInput("url", {required: true});
1229
const assetName: string = core.getInput("name", {required: true});
1330
const assetPath: string = core.getInput("path", {required: true});
1431

32+
if (!process.env.GITHUB_TOKEN) {
33+
core.setFailed("Missing GitHub token");
34+
return;
35+
}
36+
1537
const github: GitHub = new GitHub(process.env.GITHUB_TOKEN);
1638

1739
const fullPathChecked: fs.PathLike = path.resolve(fs.realpathSync(assetPath));
@@ -21,21 +43,10 @@ async function run(): Promise<void> {
2143
}
2244

2345
try {
24-
const headers: Octokit.ReposUploadReleaseAssetParamsHeaders = {
25-
"content-length": fs.statSync(fullPathChecked).size,
26-
"content-type": getType(fullPathChecked),
27-
};
28-
29-
const response: Octokit.Response<Octokit.ReposUploadReleaseAssetResponse> = await github.repos.uploadReleaseAsset({
30-
file: fs.readFileSync(fullPathChecked),
31-
headers,
32-
name: assetName,
33-
url: assetUploadURL,
34-
});
35-
36-
console.log(response.data);
46+
const data: Octokit.ReposUploadReleaseAssetResponseValue
47+
= await upload(github, fullPathChecked, assetName, assetUploadURL);
3748

38-
core.setOutput("url", "abc");
49+
core.setOutput("url", data.browser_download_url);
3950
} catch (error) {
4051
core.setFailed("Error");
4152
return;

.github/actions/upload-asset/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"esModuleInterop": true,
77
"noImplicitAny": true,
88
"sourceMap": true,
9+
"strict": true,
910
"outDir": "./",
1011
},
1112
"include": [

.github/workflows/development.yml

+13
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,23 @@ jobs:
3939
npm run build
4040
npm test
4141
npm run dist
42+
- name: test coverage
43+
uses: coverallsapp/github-action@master
44+
with:
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
path-to-lcov: ./coverage/lcov.info
4247
env:
4348
CI: true
4449
GITHUB_CONTEXT: ${{ toJson(github) }}
4550
GITHUB_BRANCH: ${{ github.ref }}
4651
GITHUB_HEAD_REF: ${{ github.head_ref }}
4752
GITHUB_BASE_REF: ${{ github.base_ref }}
4853
GITHUB_COMMIT: ${{ github.sha }}
54+
- name: publish code coverage to code climate
55+
if: matrix.os == 'ubuntu-latest'
56+
uses: paambaati/[email protected]
57+
env:
58+
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE }}
59+
with:
60+
coverageCommand: npm run test
61+
debug: true

.github/workflows/master.yml

+20
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ jobs:
4646
GITHUB_HEAD_REF: ${{ github.head_ref }}
4747
GITHUB_BASE_REF: ${{ github.base_ref }}
4848
GITHUB_COMMIT: ${{ github.sha }}
49+
- name: test coverage
50+
uses: coverallsapp/github-action@master
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
path-to-lcov: ./coverage/lcov.info
54+
env:
55+
CI: true
56+
GITHUB_CONTEXT: ${{ toJson(github) }}
57+
GITHUB_BRANCH: ${{ github.ref }}
58+
GITHUB_HEAD_REF: ${{ github.head_ref }}
59+
GITHUB_BASE_REF: ${{ github.base_ref }}
60+
GITHUB_COMMIT: ${{ github.sha }}
61+
- name: publish code coverage to code climate
62+
if: matrix.os == 'ubuntu-latest'
63+
uses: paambaati/[email protected]
64+
env:
65+
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE }}
66+
with:
67+
coverageCommand: npm run test
68+
debug: true
4969
- name: release
5070
id: release
5171
uses: ./.github/actions/create-release

.github/workflows/release.yml

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ jobs:
4646
GITHUB_HEAD_REF: ${{ github.head_ref }}
4747
GITHUB_BASE_REF: ${{ github.base_ref }}
4848
GITHUB_COMMIT: ${{ github.sha }}
49+
- name: test coverage
50+
uses: coverallsapp/github-action@master
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
path-to-lcov: ./coverage/lcov.info
4954
- name: prepare release
5055
id: prepare
5156
uses: ./.github/actions/prepare-release

.vscode/settings.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"workbench.colorTheme": "Electron Highlighter",
88
"workbench.iconTheme": "material-icon-theme",
99
"terminal.integrated.copyOnSelection": true,
10-
"jest.pathToJest": "node_modules/.bin/jest",
10+
"jest.pathToJest": "npm test --",
1111
"jest.showCoverageOnLoad": true,
1212
"git.alwaysSignOff": true,
1313
"git.autofetch": true,
1414
"git.enableCommitSigning": true,
15-
"git.fetchOnPull": true
15+
"git.fetchOnPull": true,
16+
"jest.runAllTestsFirst": false,
17+
"jest.enableInlineErrorMessages": true
1618
}

.vscode/workspace.code-workspace

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"settings": {
88
"workbench.colorTheme": "Nord",
99
"workbench.iconTheme": "material-icon-theme",
10-
"terminal.integrated.copyOnSelection": true
10+
"terminal.integrated.copyOnSelection": true,
11+
"jest.enableInlineErrorMessages": true,
12+
"jest.rootPath": "./src",
13+
"jest.showCoverageOnLoad": true
1114
},
1215
"extensions": {
1316
"recommendations": [
@@ -20,4 +23,4 @@
2023
"visualstudioexptteam.vscodeintellicode"
2124
]
2225
}
23-
}
26+
}

0 commit comments

Comments
 (0)