Skip to content

Commit

Permalink
use getMultilineInput
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauorriols committed Nov 28, 2023
1 parent 8ecc1c8 commit c7cfd18
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 7 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ jobs:
uses: ./
with:
project: happy-rat-64
root: examples
root: action/tests
entrypoint: hello.ts
import-map: ./import_map.json
- name: Deploy with single include
uses: ./
with:
project: happy-rat-64
root: action/tests
entrypoint: include_exclude.ts
include: include_exclude.ts
- name: Deploy with comma-separated exclude
uses: ./
with:
project: happy-rat-64
root: action/tests
entrypoint: include_exclude.ts
exclude: import_bomb1.ts, import_bomb2.ts
- name: Deploy with multiline exclude
uses: ./
with:
project: happy-rat-64
root: action/tests
entrypoint: include_exclude.ts
exclude: |
import_bomb1.ts
import_bomb2.ts
4 changes: 2 additions & 2 deletions action/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2584,10 +2584,10 @@ async function calculateGitSha1(bytes) {
return hashHex;
}
function include(path, include, exclude) {
if (include && !include.some((pattern)=>path.startsWith(pattern))) {
if (include.length && !include.some((pattern)=>path.startsWith(pattern))) {
return false;
}
if (exclude && exclude.some((pattern)=>path.startsWith(pattern))) {
if (exclude.length && exclude.some((pattern)=>path.startsWith(pattern))) {
return false;
}
return true;
Expand Down
8 changes: 4 additions & 4 deletions action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ async function main() {
const projectId = core.getInput("project", { required: true });
const entrypoint = core.getInput("entrypoint", { required: true });
const importMap = core.getInput("import-map", {});
const include = core.getInput("include", {});
const exclude = core.getInput("exclude", {});
const include = core.getMultilineInput("include", {});
const exclude = core.getMultilineInput("exclude", {});
const cwd = resolve(process.cwd(), core.getInput("root", {}));

if (github.context.eventName === "pull_request") {
Expand Down Expand Up @@ -75,8 +75,8 @@ async function main() {
core.debug(`Discovering assets in "${cwd}"`);
const assets = new Map();
const entries = await walk(cwd, cwd, assets, {
include: include ? include.split(",").map(pattern => normalize(pattern)): undefined,
exclude: exclude ? exclude.split(",").map(pattern => normalize(pattern)): undefined,
include: include.split(",").map(pattern => normalize(pattern)),
exclude: exclude.split(",").map(pattern => normalize(pattern)),
});
core.debug(`Discovered ${assets.size} assets`);

Expand Down
11 changes: 11 additions & 0 deletions action/tests/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { serve } from "std/http/server.ts";

async function handler(_req: Request) {
const text = await Deno.readTextFile(new URL(import.meta.url));
return new Response(text, {
headers: { "content-type": "text/plain; charset=utf8" },
});
}

console.log("Listening on http://localhost:8000");
serve(handler);
1 change: 1 addition & 0 deletions action/tests/import_bomb1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error("BOOM!");
1 change: 1 addition & 0 deletions action/tests/import_bomb2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error("BOOM!");
5 changes: 5 additions & 0 deletions action/tests/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"std/": "https://deno.land/[email protected]/"
}
}
15 changes: 15 additions & 0 deletions action/tests/include_exclude.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
try {
const q = await import("./import_bomb1.ts");
} catch (e) {
if (!(e instanceof Deno.errors.NotFound)) {
throw e;
}
}
try {
const q = await import("./import_bomb2.ts");
} catch (e) {
if (!(e instanceof Deno.errors.NotFound)) {
throw e;
}
}
Deno.serve(() => new Response("Hello World"));

0 comments on commit c7cfd18

Please sign in to comment.