This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate examples as deno tests for ci
- Loading branch information
1 parent
cbc8b44
commit 7fcaec1
Showing
12 changed files
with
90 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
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
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
"star": "deno task run _tasks/star.ts && deno cache --check target/star.ts", | ||
"codegen": "deno task run cache.ts examples/mod.ts", | ||
"test": "deno task run test_util/ctx.ts -- deno test -A -L=info --ignore=target --parallel", | ||
"test:ci": "ENV_TYPE_CI=1 deno task test", | ||
"test:update": "deno task test -- -- --update", | ||
"bench": "deno bench -A", | ||
"moderate": "deno task run https://deno.land/x/[email protected]/mod.ts && dprint fmt" | ||
|
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 @@ | ||
export * from "https://deno.land/x/[email protected]/mod.ts" |
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 @@ | ||
export * from "https://deno.land/[email protected]/io/mod.ts" |
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 @@ | ||
export * from "https://deno.land/[email protected]/streams/mod.ts" |
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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ mod.ts | |
multisig_transfer.ts | ||
smart_contract.ts | ||
xcm_teleport_assets.ts | ||
examples.test.ts |
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,13 @@ | ||
import { Keyring } from "https://deno.land/x/[email protected]/keyring/mod.ts" | ||
import { | ||
cryptoWaitReady, | ||
randomAsHex, | ||
} from "https://deno.land/x/[email protected]/util-crypto/mod.ts" | ||
|
||
const a = new Keyring() | ||
|
||
await cryptoWaitReady() | ||
|
||
const keyring = new Keyring({ type: "sr25519", ss58Format: 2 }) | ||
keyring.addFromUri(randomAsHex(32), { name: `testing` }) | ||
console.log(keyring.getPairs().map((kp) => kp.meta)) |
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,56 @@ | ||
import * as path from "http://localhost:5646/@local/deps/std/path.ts" | ||
import { makeRunWithLimit } from "../deps/run_with_limit.ts" | ||
import { readLines } from "../deps/std/io.ts" | ||
import { writeAll } from "../deps/std/streams.ts" | ||
import { assert } from "../deps/std/testing/asserts.ts" | ||
|
||
function getModuleDir(importMeta: ImportMeta): string { | ||
return path.resolve(path.dirname(path.fromFileUrl(importMeta.url))) | ||
} | ||
|
||
Deno.test({ | ||
name: "examples", | ||
ignore: Deno.env.get("ENV_TYPE_CI") ? false : true, | ||
async fn(t) { | ||
const { runWithLimit } = makeRunWithLimit<void>(navigator.hardwareConcurrency) | ||
|
||
const ignoreFile = await Deno.readTextFile(path.join(getModuleDir(import.meta), ".ignore")) | ||
const ignoredFiles = new Set(ignoreFile.split("\n")) | ||
|
||
const exampleFileNames = Array.from(Deno.readDirSync(getModuleDir(import.meta))) | ||
.filter((e) => e.name.match(/^.*\.ts$/g) && e.isFile && !ignoredFiles.has(e.name)) | ||
.map((f) => f.name) | ||
|
||
await Promise.all(exampleFileNames.map((fileName) => | ||
runWithLimit(async () => { | ||
const task = Deno.run({ | ||
cmd: ["deno", "task", "run", `${getModuleDir(import.meta)}/${fileName}`], | ||
stdout: "null", | ||
stderr: "piped", | ||
}) | ||
|
||
try { | ||
await t.step({ | ||
name: fileName, | ||
async fn() { | ||
const encoder = new TextEncoder() | ||
for await (const line of readLines(task.stderr)) { | ||
await writeAll(Deno.stdout, encoder.encode(`[examples/${fileName}] ${line}\n`)) | ||
} | ||
const status = await task.status() | ||
|
||
assert(status.code === 0, `task failed with status code: ${status.code}`) | ||
assert(status.success, `unsuccessful`) | ||
}, | ||
sanitizeOps: false, | ||
sanitizeResources: false, | ||
sanitizeExit: false, | ||
}) | ||
} finally { | ||
task.stderr.close() | ||
task.close() | ||
} | ||
}) | ||
)) | ||
}, | ||
}) |
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,6 @@ | ||
/** | ||
* Minimum deposit amount to activate an account | ||
* | ||
* {@link https://support.polkadot.network/support/solutions/articles/65000168651-what-is-the-existential-deposit-#:~:text=On%20the%20Polkadot%20network%2C%20an,the%20Existential%20Deposit%20(ED) What is the Existential Deposit} | ||
*/ | ||
export const EXISTENTIAL_DEPOSIT_AMOUNT = 10_000_000_000n |
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