Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Test some of the JS examples #4

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/run-tests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { readFileSync } from 'node:fs';
import { execSync } from 'node:child_process';

const exampleDir = process.argv[2];

function runCommand(command) {
console.log("::group::" + command)
execSync(command, {
cwd: exampleDir,
stdio: "inherit",
});
console.log("::endgroup::");
}

const config = JSON.parse(readFileSync(exampleDir + '/.tbd-example.json', 'utf8'));

runCommand(config.install || "npm install");

if (config.tests && config.tests.pre) {
for (const cmd of config.tests.pre) {
runCommand(cmd);
}
}

var testCommand = "npm test";
if (config.tests && config.tests.command) {
testCommand = config.tests.command;
}

runCommand(testCommand);
42 changes: 42 additions & 0 deletions .github/workflows/javascript-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: JavaScript Tests

on: [push]

jobs:
list-projects:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.result }}
steps:
- uses: actions/checkout@v2
- name: discover all examples
id: build-matrix
uses: actions/github-script@v7
with:
script: |
const { readdirSync, existsSync } = require('node:fs');
const projects = [];

const language = 'javascript';
for (const project of readdirSync(language)) {
if (existsSync(language + '/' + project + '/.tbd-example.json')) {
projects.push(language + '/' + project);
}
}

return projects;

test-javascript:
needs: list-projects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.list-projects.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: '20.4.0'
- name: Run tests
run: node .github/run-tests.mjs ${{ matrix.project }}
68 changes: 66 additions & 2 deletions javascript/book-reviews/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
node_modules/
DATA/
# Dependencies
**/node_modules/
.nuxt
.next

# Production
/site/build
examples/web5-quickstart-widgets/bundle.js
/site/.env

# Generated files
.docusaurus
.cache-loader
/site/snippets

# IDE autogenerated
**/.idea
**/.vscode

# Maven target dir
**/target

# Maven binary Wrapper (we use source)
**/.mvn/wrapper/maven-wrapper.jar

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
/storybook-static
/src/pages/projects/tbdex-protocol/README.md
/src/pages/projects/tbdex-protocol/pfi-mock-impl/README.md
/src/pages/projects/tbdex-protocol/pfi-mock-impl/CONTRIBUTING.md
/src/pages/projects/tbdex-protocol/lib/README.md
/src/pages/projects/tbdex-protocol/did/README.md
/src/pages/projects/ssi-service/README.md
/src/pages/projects/ssi-sdk/README.md
/src/pages/projects/dwn-sdk-js/README.md

# Local Netlify folder
.netlify

# Ignore Web5 generated files for testing
/site/data
/site/DATASTORE
/site/EVENTLOG
/site/INDEX
/site/MESSAGESTORE

data
DATA
DATASTORE
EVENTLOG
INDEX
MESSAGESTORE
.vercel
temp

playwright-report
test-results
7 changes: 7 additions & 0 deletions javascript/dinger-completed/.tbd-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Dinger (completed)",
"tests": {
"pre": ["npx playwright install --with-deps"],
"command": "npm run test:browser"
}
}
Loading
Loading