Commit 8eba6007 authored by Janka Uryga's avatar Janka Uryga

ci: fix mockSpan in next-stats-action and reuse it

parent 13cd9de2
......@@ -4,12 +4,9 @@ const { existsSync } = require('fs')
const exec = require('../util/exec')
const logger = require('../util/logger')
const execa = require('execa')
const mockSpan = require('../util/mock-trace')
const mockSpan = () => ({
traceAsyncFn: (fn) => fn(mockTrace()),
traceFn: (fn) => fn(mockTrace()),
traceChild: () => mockTrace(),
})
/** @typedef {import('../util/mock-trace').Span} Span */
module.exports = (actionInfo) => {
return {
......@@ -62,7 +59,7 @@ module.exports = (actionInfo) => {
},
/**
* Runs `pnpm pack` on each package in the `packages` folder of the provided `repoDir`
* @param {{ repoDir: string, nextSwcVersion: null | string }} options Required options
* @param {{ repoDir: string, nextSwcVersion: null | string, parentSpan?: Span }} options Required options
* @returns {Promise<Map<string, string>>} List packages key is the package name, value is the path to the packed tar file.'
*/
async linkPackages({ repoDir, nextSwcVersion, parentSpan }) {
......
/** @returns {Span} */
const createMockSpan = () => ({
traceAsyncFn: (fn) => fn(createMockSpan()),
traceFn: (fn) => fn(createMockSpan()),
traceChild: () => createMockSpan(),
})
/** @typedef {{
* traceAsyncFn: <T>(fn: (span: Span) => Promise<T>) => Promise<T>,
* traceFn: <T>(fn: (span: Span) => T) => T,
* traceChild: (id: string, data?: Record<string, any>) => Span,
* }} Span */
module.exports = createMockSpan
......@@ -14,6 +14,7 @@ const glob = promisify(_glob)
const exec = promisify(execOrig)
const core = require('@actions/core')
const { getTestFilter } = require('./test/get-test-filter')
const mockSpan = require('./.github/actions/next-stats-action/src/util/mock-trace')
let argv = require('yargs/yargs')(process.argv.slice(2))
.string('type')
......@@ -78,12 +79,6 @@ const testFilters = {
e2e: 'test/e2e/',
}
const mockTrace = () => ({
traceAsyncFn: (fn) => fn(mockTrace()),
traceFn: (fn) => fn(mockTrace()),
traceChild: () => mockTrace(),
})
// which types we have configured to run separate
const configuredTestTypes = Object.values(testFilters)
const errorsPerTests = new Map()
......@@ -388,7 +383,7 @@ ${ENDGROUP}`)
console.log(`${GROUP}Creating Next.js install for isolated tests`)
const reactVersion = process.env.NEXT_TEST_REACT_VERSION || 'latest'
const { installDir, pkgPaths, tmpRepoDir } = await createNextInstall({
parentSpan: mockTrace(),
parentSpan: mockSpan(),
dependencies: {
react: reactVersion,
'react-dom': reactVersion,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment