forked from JeremyHeleine/Photo-Sphere-Viewer
-
-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,553 additions
and
137 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
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,55 @@ | ||
name: setup | ||
|
||
inputs: | ||
turbo-cache: | ||
default: True | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: data | ||
id: data | ||
shell: bash | ||
run: | | ||
echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
- name: yarn cache | ||
uses: actions/cache@v4 | ||
if: ${{ !startsWith(github.ref_name, 'dependabot') }} | ||
with: | ||
key: yarn-${{ hashFiles('yarn.lock') }} | ||
path: ${{ steps.data.outputs.YARN_CACHE_DIR }} | ||
|
||
- name: yarn cache ro | ||
uses: actions/cache/restore@v4 | ||
if: ${{ startsWith(github.ref_name, 'dependabot') }} | ||
with: | ||
key: yarn-${{ hashFiles('yarn.lock') }} | ||
path: ${{ steps.data.outputs.YARN_CACHE_DIR }} | ||
|
||
- name: turbo cache | ||
uses: actions/cache@v4 | ||
if: ${{ inputs.turbo-cache && !startsWith(github.ref_name, 'dependabot') }} | ||
with: | ||
path: .turbo | ||
key: turbo-${{ github.sha }} | ||
restore-keys: | | ||
turbo- | ||
- name: turbo cache ro | ||
uses: actions/cache/restore@v4 | ||
if: ${{ inputs.turbo-cache && startsWith(github.ref_name, 'dependabot') }} | ||
with: | ||
path: .turbo | ||
key: turbo-${{ github.sha }} | ||
restore-keys: | | ||
turbo- | ||
- name: install | ||
shell: bash | ||
run: yarn install |
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ docs/.vitepress/.temp | |
!docs/.typedoc | ||
dist | ||
/public | ||
reports | ||
cypress/screenshots |
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,5 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
reporter: path.join(__dirname, 'build/mocha-reporter.js'), | ||
}; |
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,111 @@ | ||
const BaseReporter = require('mocha/lib/reporters/base'); | ||
const SpecReporter = require('mocha/lib/reporters/spec'); | ||
const JsonReporter = require('mocha/lib/reporters/json'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
module.exports = class MultiReporter extends BaseReporter { | ||
constructor(runner, options) { | ||
super(runner, options); | ||
|
||
new SpecReporter(runner, {}); | ||
|
||
if (options.reporterOptions?.cypress) { | ||
new CypressJsonReporter(runner, { | ||
reporterOption: { | ||
output: 'cypress/reports/e2e.json', | ||
}, | ||
}); | ||
} else { | ||
new JsonReporter(runner, { | ||
reporterOption: { | ||
output: `reports/mocha.json`, | ||
}, | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
// custom json reporter for cypress (for some reason, calling JsonReporter does not work) | ||
// - write the results to a json file | ||
// - fill the "file" property of each test | ||
function CypressJsonReporter(runner, options) { | ||
BaseReporter.call(this, runner, options); | ||
|
||
const tests = []; | ||
const pending = []; | ||
const failures = []; | ||
const passes = []; | ||
|
||
runner.on('test end', function (test) { | ||
tests.push(test); | ||
}); | ||
|
||
runner.on('pass', function (test) { | ||
passes.push(test); | ||
}); | ||
|
||
runner.on('fail', function (test) { | ||
failures.push(test); | ||
}); | ||
|
||
runner.on('pending', function (test) { | ||
pending.push(test); | ||
}); | ||
|
||
runner.once('end', () => { | ||
const obj = { | ||
stats: this.stats, | ||
tests: tests.map(clean), | ||
pending: pending.map(clean), | ||
failures: failures.map(clean), | ||
passes: passes.map(clean) | ||
}; | ||
const json = JSON.stringify(obj, null, 2); | ||
const output = options.reporterOption.output; | ||
fs.mkdirSync(path.dirname(output), { recursive: true }); | ||
fs.writeFileSync(output, json); | ||
}); | ||
|
||
function clean(test) { | ||
let err = test.err || {}; | ||
if (err instanceof Error) { | ||
err = errorJSON(err); | ||
} | ||
|
||
return { | ||
title: test.title, | ||
fullTitle: test.fullTitle(), | ||
file: test.invocationDetails.absoluteFile, | ||
duration: test.duration, | ||
currentRetry: test.currentRetry(), | ||
speed: test.speed, | ||
err: cleanCycles(err) | ||
}; | ||
} | ||
|
||
function cleanCycles(obj) { | ||
let cache = []; | ||
return JSON.parse( | ||
JSON.stringify(obj, (key, value) => { | ||
if (typeof value === 'object' && value !== null) { | ||
if (cache.indexOf(value) !== -1) { | ||
// Instead of going in a circle, we'll print [object Object] | ||
return '' + value; | ||
} | ||
cache.push(value); | ||
} | ||
|
||
return value; | ||
}) | ||
); | ||
} | ||
|
||
function errorJSON(err) { | ||
let res = {}; | ||
Object.getOwnPropertyNames(err).forEach((key) => { | ||
res[key] = err[key]; | ||
}, err); | ||
return res; | ||
} | ||
} |
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,20 @@ | ||
import { spawn } from 'child_process'; | ||
|
||
const SERVE_SCRIPT = process.argv[2]; | ||
const TEST_SCRIPT = process.argv[3]; | ||
|
||
const serveProcess = spawn('yarn', SERVE_SCRIPT.split(' '), { | ||
stdio: 'inherit', | ||
cwd: process.cwd(), | ||
shell: true, | ||
}); | ||
|
||
const testProcess = spawn('yarn', TEST_SCRIPT.split(' '), { | ||
stdio: 'inherit', | ||
cwd: process.cwd(), | ||
shell: true, | ||
}); | ||
|
||
testProcess.on('exit', () => { | ||
serveProcess.kill(); | ||
}); |
Oops, something went wrong.