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

Commit

Permalink
Try specifying pre-test commands
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-block committed Jun 6, 2024
1 parent b8d8d7b commit e496877
Show file tree
Hide file tree
Showing 5 changed files with 2,419 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .github/run-tests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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("npm install");

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

runCommand("npm test");
27 changes: 10 additions & 17 deletions .github/workflows/javascript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,26 @@ jobs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: build-matrix
run: |
python -c '
import json
import os
projects = json.dumps([p for p in os.listdir("javascript") if os.path.isfile(f"javascript/{p}/package.json")])
print(f"matrix={projects}")
' | tee -a $GITHUB_OUTPUT
- name: discover all examples
id: build-matrix
uses: actions/github-script@v7
with:
script: |
const { globSync } = require('node:fs');
return globSync("javascript/*/.tbd-example.json").map(path.dirname);
test-javascript:
needs: list-projects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.list-projects.outputs.matrix) }}
project: ${{ needs.list-projects.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: '20.4.0'
- name: Install dependencies
run: npm install
working-directory: "javascript/${{ matrix.project }}"
- name: Install playwright
run: npx playwright install --with-deps
working-directory: "javascript/${{ matrix.project }}"
- name: Run tests
run: npm run test
working-directory: "javascript/${{ matrix.project }}"
run: |
node .github/run-tests.js ${{ matrix.project }}
6 changes: 6 additions & 0 deletions javascript/dinger-completed/.tbd-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Dinger (completed)",
"tests": {
"pre": ["npx playwright install --with-deps"]
}
}
Loading

0 comments on commit e496877

Please sign in to comment.