-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monorepo (& Tx, VM): Examples scripts in CI (#1658)
* chore(examples): examples added to ci * chore(examples-ci): remove script from VM (for now) & rename examples workflow file * chore(ci): new script formwatted with prettier & example workflow changes to run with non-test branches Co-authored-by: Holger Drewes <Holger.Drewes@gmail.com>
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 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,22 @@ | ||
name: Packages examples | ||
on: | ||
push: | ||
branches: [master, develop] | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
test-examples: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
cache: 'npm' | ||
|
||
- run: npm i | ||
- run: npm run examples |
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { extname, join } from 'path' | ||
import { readdir } from 'fs' | ||
|
||
const pkg = process.argv[3] | ||
if (!pkg) { | ||
throw new Error('Package argument must be passed') | ||
} | ||
|
||
const examplesPath = `../packages/${pkg}/examples/` | ||
const path = join(__dirname, examplesPath) | ||
|
||
readdir(path, async (err, files) => { | ||
if (err) { | ||
throw new Error('Error loading examples directory: ' + err.message) | ||
} | ||
|
||
const getTsFiles = (fileName: string): Promise<NodeModule> | undefined => { | ||
if (extname(fileName) === '.ts') { | ||
return import(examplesPath + fileName) | ||
} | ||
} | ||
|
||
const importedFiles = files.map(getTsFiles).filter((file) => file) | ||
|
||
await Promise.all(importedFiles) | ||
}) |