From 4983aa19edb2dedf5dabd136a94f4b54aefaa92c Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Fri, 27 Jan 2023 12:55:05 -0500 Subject: [PATCH] misc ci cleanup --- .github/workflows/test.yml | 5 ++--- _tasks/test_examples.ts | 24 +++++++++++++----------- deno.jsonc | 3 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e3ed53ca..9fa1d2b3c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,5 @@ jobs: binary-version: v1.3.18 binary-github: https://github.com/paritytech/zombienet - run: deno lint - - run: deno task star - - run: deno task test:ci - - run: deno task test:ci _tasks/test_examples.ts -- examples + - run: deno task test -r=http://localhost:4646 + - run: deno task test -r=http://localhost:4646 _tasks/test_examples.ts diff --git a/_tasks/test_examples.ts b/_tasks/test_examples.ts index 67a9af30f..bee40ec77 100644 --- a/_tasks/test_examples.ts +++ b/_tasks/test_examples.ts @@ -1,17 +1,22 @@ +// TODO: rename this task + +import { parse } from "../deps/std/flags.ts" import { Buffer, readLines } from "../deps/std/io.ts" import * as path from "../deps/std/path.ts" import { writeAll } from "../deps/std/streams.ts" import { assert } from "../deps/std/testing/asserts.ts" -const examplesDir = Deno.args[0] -if (!examplesDir) { - throw new Error("specify examples directory as first CLI argument") -} +const { dir } = parse(Deno.args, { + string: ["dir"], + default: { + dir: "examples", + }, +}) -const ignoreFile = await Deno.readTextFile(path.join(examplesDir, ".ignore")) +const ignoreFile = await Deno.readTextFile(path.join(dir, ".ignore")) const ignoredFiles = new Set(ignoreFile.split("\n")) -const exampleFileNames = Array.from(Deno.readDirSync(examplesDir)) +const exampleFileNames = Array.from(Deno.readDirSync(dir)) .filter((e) => e.name.match(/^.*\.ts$/g) && e.isFile && !ignoredFiles.has(e.name)) .map((f) => f.name) @@ -21,7 +26,7 @@ Deno.test("examples", async (t) => { name: fileName, async fn() { const task = Deno.run({ - cmd: ["deno", "run", "-A", "-r=http://localhost:4646/", `${examplesDir}/${fileName}`], + cmd: ["deno", "run", "-A", "-r=http://localhost:4646/", `${dir}/${fileName}`], stdout: "piped", stderr: "piped", }) @@ -29,10 +34,7 @@ Deno.test("examples", async (t) => { try { const out = new Buffer() - await Promise.all([ - pipeThrough(task.stdout, out), - pipeThrough(task.stderr, out), - ]) + await Promise.all([pipeThrough(task.stdout, out), pipeThrough(task.stderr, out)]) const status = await task.status() diff --git a/deno.jsonc b/deno.jsonc index 641fe2b50..43b912ce2 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -35,8 +35,7 @@ "debug": "deno run -A --inspect-brk", "udd": "deno task star && deno run -A https://deno.land/x/udd@0.5.0/main.ts target/star.ts", "dnt": "deno run -A _tasks/dnt.ts", - "test:ci": "deno test -A -L=info --ignore=target --parallel", - "test": "deno task ctx -- deno task test:ci -r=http://localhost:4646/", + "test": "deno task ctx -- deno test -A -L=info --ignore=target --parallel", "test:update": "deno task test -- --update", "moderate": "deno run -A https://deno.land/x/moderate@0.0.5/mod.ts && dprint fmt", "dev": "deno run -A --watch=deno.jsonc,docs/ main.ts --serve",