Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 762618c
Showing
51 changed files
with
6,030 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extends: | ||
- "@commitlint/config-conventional" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
indent_brace_style = K&R | ||
|
||
[*.{yml,yaml,dart}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: cancel-redundant | ||
description: "Cancels redundant workflows, ie: all previous workflows for the same branch or PR" | ||
runs: | ||
using: node12 | ||
main: ./dist/main.js | ||
inputs: | ||
token: | ||
description: The GITHUB_TOKEN secret of this github workflow | ||
required: true |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"private": true, | ||
"name": "cancel-redundant", | ||
"dependencies": { | ||
"@actions/core": "^1.2.3", | ||
"@actions/github": "^2.1.1", | ||
"encoding": "^0.1.12", | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@rollup/plugin-typescript": "^4.0.0", | ||
"@types/node": "^13.9.0", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup": "^2.0.2", | ||
"typescript": "^3.8.3" | ||
}, | ||
"scripts": { | ||
"build": "tsc --target ES6 --moduleResolution node rollup.config.ts && rollup --config" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { RollupOptions } from "rollup"; | ||
import { terser } from "rollup-plugin-terser"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import json from "@rollup/plugin-json"; | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
|
||
const nodeJsBuiltInModules = [ | ||
"assert", | ||
"buffer", | ||
"child_process", | ||
"cluster", | ||
"crypto", | ||
"dgram", | ||
"dns", | ||
"domain", | ||
"events", | ||
"fs", | ||
"http", | ||
"https", | ||
"net", | ||
"os", | ||
"path", | ||
"punycode", | ||
"querystring", | ||
"readline", | ||
"stream", | ||
"string_decoder", | ||
"timers", | ||
"tls", | ||
"tty", | ||
"url", | ||
"util", | ||
"v8", | ||
"vm", | ||
"zlib", | ||
]; | ||
|
||
export default { | ||
input: "./src/main.ts", | ||
output: { | ||
file: "./dist/main.js", | ||
format: "cjs", | ||
}, | ||
treeshake: true, | ||
external: [...nodeJsBuiltInModules], | ||
plugins: [ | ||
json(), | ||
typescript(), | ||
resolve({ preferBuiltins: true }), | ||
commonjs(), | ||
terser(), | ||
], | ||
onwarn(error, warn) { | ||
if (error.code !== "CIRCULAR_DEPENDENCY") { | ||
warn(error); | ||
} | ||
}, | ||
} as RollupOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import * as core from "@actions/core"; | ||
import * as github from "@actions/github"; | ||
|
||
(async function main(argv: string[]): Promise<void> { | ||
// Create a new instance of the Github REST client | ||
const octokit = new github.GitHub(core.getInput("token")); | ||
|
||
// Bail out early if it's not a push or a pr | ||
const event = process.env["GITHUB_EVENT_NAME"]; | ||
if (!["push", "pull_request"].includes(event)) { | ||
core.info("Skipping unsupported event"); | ||
return; | ||
} | ||
|
||
// Determine the branch we are running on | ||
const branchPrefix = "refs/heads/"; | ||
const tagPrefix = "refs/tags/"; | ||
const pullRequest = "pull_request" === event; | ||
const fqBranch = pullRequest | ||
? process.env["GITHUB_HEAD_REF"] | ||
: process.env["GITHUB_REF"]; | ||
if (!pullRequest && !fqBranch.startsWith(branchPrefix)) { | ||
if (fqBranch.startsWith(tagPrefix)) { | ||
core.info("Skipping tag build"); | ||
return; | ||
} | ||
throw new Error( | ||
`${fqBranch} was not an expected branch ref (refs/heads/).` | ||
); | ||
} | ||
const branch = fqBranch.replace(branchPrefix, ""); | ||
|
||
// Get the workflow id | ||
const runId = process.env["GITHUB_RUN_ID"]; | ||
const repository = process.env["GITHUB_REPOSITORY"]; | ||
const [owner, repo] = repository.split("/"); | ||
const reply = await octokit.actions.getWorkflowRun({ | ||
owner, | ||
repo, | ||
run_id: Number.parseInt(runId), | ||
}); | ||
const workFlowId = reply.data.workflow_url.split("/").pop() || ""; | ||
if (!(workFlowId.length > 0)) { | ||
throw new Error("Could not resolve workflow"); | ||
} | ||
core.info( | ||
JSON.stringify( | ||
{ | ||
owner, | ||
repo, | ||
branch, | ||
runId, | ||
workFlowId, | ||
}, | ||
undefined, | ||
4 | ||
) | ||
); | ||
|
||
// Find all workflow runs that can be canceled | ||
for (const status of ["queued", "in_progress"]) { | ||
const listRuns = octokit.actions.listWorkflowRuns.endpoint.merge({ | ||
owner, | ||
repo, | ||
workflow_id: workFlowId, | ||
status, | ||
branch, | ||
event, | ||
}); | ||
|
||
for await (const item of octokit.paginate.iterator(listRuns)) { | ||
// There is some sort of bug where the pagination URLs point to a | ||
// different endpoint URL which trips up the resulting representation | ||
// In that case, fallback to the actual REST 'workflow_runs' property | ||
const runs = | ||
item.data.length === undefined | ||
? item.data.workflow_runs | ||
: item.data; | ||
|
||
for (const run of runs) { | ||
// Make sure we don't cancel ourselves | ||
if (run.id === parseInt(runId)) { | ||
continue; | ||
} | ||
try { | ||
const reply = await octokit.actions.cancelWorkflowRun({ | ||
owner, | ||
repo, | ||
run_id: run.id, | ||
}); | ||
core.info( | ||
`Previous run (id ${run.id}) cancelled, status = ${reply.status}` | ||
); | ||
} catch (error) { | ||
core.info( | ||
`[warn] Could not cancel run (id ${run.id}): [${error.status}] ${error.message}` | ||
); | ||
} | ||
} | ||
} | ||
} | ||
})(process.argv) | ||
.then(() => { | ||
process.exit(0); | ||
}) | ||
.catch(e => { | ||
if (e["message"] !== undefined) { | ||
core.setFailed(e.message); | ||
} | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: search-replace-file | ||
description: Replaces text in a file | ||
runs: | ||
using: node12 | ||
main: ./dist/main.js | ||
inputs: | ||
files: | ||
description: File glob | ||
required: true | ||
from: | ||
description: The text to replace or regular expression | ||
required: false | ||
to: | ||
description: The replacement text | ||
required: true |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"private": true, | ||
"name": "search-replace-file", | ||
"dependencies": { | ||
"@actions/core": "^1.2.3", | ||
"replace-in-file": "^5.0.2", | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@rollup/plugin-typescript": "^4.0.0", | ||
"@types/node": "^13.9.0", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup": "^2.0.2", | ||
"typescript": "^3.8.3" | ||
}, | ||
"scripts": { | ||
"build": "tsc --target ES6 --moduleResolution node rollup.config.ts && rollup --config" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { RollupOptions } from "rollup"; | ||
import { terser } from "rollup-plugin-terser"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import json from "@rollup/plugin-json"; | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
|
||
const nodeJsBuiltInModules = [ | ||
"assert", | ||
"buffer", | ||
"child_process", | ||
"cluster", | ||
"crypto", | ||
"dgram", | ||
"dns", | ||
"domain", | ||
"events", | ||
"fs", | ||
"http", | ||
"https", | ||
"net", | ||
"os", | ||
"path", | ||
"punycode", | ||
"querystring", | ||
"readline", | ||
"stream", | ||
"string_decoder", | ||
"timers", | ||
"tls", | ||
"tty", | ||
"url", | ||
"util", | ||
"v8", | ||
"vm", | ||
"zlib", | ||
]; | ||
|
||
export default { | ||
input: "./src/main.ts", | ||
output: { | ||
file: "./dist/main.js", | ||
format: "cjs", | ||
}, | ||
treeshake: true, | ||
external: [...nodeJsBuiltInModules], | ||
plugins: [ | ||
json(), | ||
typescript(), | ||
resolve({ preferBuiltins: true }), | ||
commonjs(), | ||
terser(), | ||
], | ||
onwarn(error, warn) { | ||
if (error.code !== "CIRCULAR_DEPENDENCY") { | ||
warn(error); | ||
} | ||
}, | ||
} as RollupOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as core from "@actions/core"; | ||
import replaceInFile from "replace-in-file"; | ||
|
||
(async function main(argv: string[]): Promise<void> { | ||
const from = core.getInput("from", { required: true }); | ||
const expressionParts = from.split("/"); | ||
const result = await replaceInFile({ | ||
files: core.getInput("files", { required: true }), | ||
from: new RegExp(expressionParts[1], expressionParts[2]), | ||
to: core.getInput("to", { required: true }), | ||
}); | ||
core.info(JSON.stringify(result, undefined, 4)); | ||
})(process.argv) | ||
.then(() => { | ||
process.exit(0); | ||
}) | ||
.catch(e => { | ||
if (e["message"] !== undefined) { | ||
core.setFailed(e.message); | ||
} | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: setup-dart | ||
description: Installs the Dart SDK | ||
runs: | ||
using: node12 | ||
main: ./dist/main.js | ||
inputs: | ||
version: | ||
description: The version of dart to install. | ||
required: false | ||
outputs: | ||
dart-sdk: | ||
description: Path to the installed Dart SDK folder. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"private": true, | ||
"name": "setup-dart", | ||
"dependencies": { | ||
"@actions/core": "^1.2.3", | ||
"@actions/tool-cache": "^1.3.2", | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@rollup/plugin-typescript": "^4.0.0", | ||
"@types/node": "^13.9.0", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup": "^2.0.2", | ||
"typescript": "^3.8.3" | ||
}, | ||
"scripts": { | ||
"build": "tsc --target ES6 --moduleResolution node rollup.config.ts && rollup --config" | ||
} | ||
} |
Oops, something went wrong.