Skip to content

Commit

Permalink
ci: debug windows ci permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 9, 2023
1 parent 07092c4 commit c742f6b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 174 deletions.
163 changes: 4 additions & 159 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,15 @@ env:
PUPPETEER_DOWNLOAD_PATH: ${{ github.workspace }}/.cache/Puppeteer

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache

- name: Install
run: pnpm i

- name: Lint
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache

- name: Install
run: pnpm i

- name: Build
run: pnpm run build

- name: Typecheck
run: pnpm run typecheck

test:
runs-on: ${{ matrix.os }}

timeout-minutes: 30

strategy:
matrix:
os: [ubuntu-latest]
node_version: [16, 18]
include:
- os: macos-latest
node_version: 18
- os: windows-latest
node_version: 18
os: [windows-latest]
node_version: [18]
fail-fast: false

steps:
Expand All @@ -79,126 +45,5 @@ jobs:
run: pnpm run build

- name: Test
run: pnpm run test:ci

- name: Test Single Thread
run: pnpm run test:ci:single-thread

test-ui:
runs-on: ubuntu-latest

timeout-minutes: 10

steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache
with:
node-version: 16.16

- name: Install
run: pnpm i

- name: Test UI
run: pnpm run ui:test

test-browser:
runs-on: ubuntu-latest
strategy:
matrix:
browser: [[chrome, chromium], [firefox, firefox], [edge, webkit]]

timeout-minutes: 30

env:
BROWSER: ${{ matrix.browser[0] }}
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache
with:
node-version: 18

- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-firefox@v1
- uses: browser-actions/setup-edge@v1

- name: Install
run: pnpm i

- name: Install Playwright Dependencies
run: pnpx playwright install-deps

- name: Build
run: pnpm run build

- name: Test Browser (webdriverio)
run: pnpm run test:browser:webdriverio

- name: Test Browser (playwright)
run: pnpm run test:browser:playwright
env:
BROWSER: ${{ matrix.browser[1] }}

test-browser-windows:
runs-on: windows-latest
strategy:
matrix:
browser: [[chrome, chromium], [edge, webkit]]

timeout-minutes: 30

env:
BROWSER: ${{ matrix.browser[0] }}
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache
with:
node-version: 18

- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-edge@v1

- name: Install
run: pnpm i

- name: Install Playwright Dependencies
run: pnpx playwright install-deps

- name: Build
run: pnpm run build

- name: Test Browser (webdriverio)
run: pnpm run test:browser:webdriverio

- name: Test Browser (playwright)
run: pnpm run test:browser:playwright
env:
BROWSER: ${{ matrix.browser[1] }}

test-browser-safari:
runs-on: macos-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-and-cache
with:
node-version: 18

- name: Install
run: sudo pnpm i --frozen-lockfile

- name: Build
run: sudo pnpm run build

- name: Enable
run: sudo safaridriver --enable

- name: Test Browser (webdriverio)
run: sudo BROWSER=safari pnpm run test:browser:webdriverio

- name: Test Browser (playwright)
run: sudo BROWSER=webkit pnpm run test:browser:playwright
working-directory: test/coverage-test
run: pnpm run test
19 changes: 16 additions & 3 deletions packages/coverage-c8/src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, promises as fs } from 'node:fs'
import { existsSync, promises as fs, readdirSync } from 'node:fs'
import _url from 'node:url'
import type { Profiler } from 'node:inspector'
import MagicString from 'magic-string'
Expand Down Expand Up @@ -61,8 +61,21 @@ export class C8CoverageProvider extends BaseCoverageProvider implements Coverage
}

async clean(clean = true) {
if (clean && existsSync(this.options.reportsDirectory))
await fs.rm(this.options.reportsDirectory, { recursive: true, force: true, maxRetries: 10 })
if (clean && existsSync(this.options.reportsDirectory)) {
this.ctx.logger.log('Cleaning:', this.options.reportsDirectory)

try {
await fs.rm(this.options.reportsDirectory, { recursive: true, force: true, maxRetries: 10 })
}
catch (e) {
console.error('Failed to rm reports directory', e)
throw e
}

const exists = existsSync(this.options.reportsDirectory)
const contents = readdirSync('./')
this.ctx.logger.log('Cleaned. Exists:', exists, 'Cwd contents:', contents.join(','))
}

this.coverages = []
}
Expand Down
15 changes: 7 additions & 8 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,13 @@ export class Vitest {
return
}

try {
await this.initCoverageProvider()
await this.coverageProvider?.clean(this.config.coverage.clean)
await this.initBrowserProviders()
}
finally {
await this.report('onInit', this)
}
await this.initCoverageProvider()
await this.coverageProvider?.clean(this.config.coverage.clean)
await this.initBrowserProviders()

await this.report('onInit', this).catch((e) => {
console.error('onInit failed too', e.message)
})

const files = await this.filterTestsBySource(
await this.globTestFiles(filters),
Expand Down
30 changes: 26 additions & 4 deletions packages/vitest/src/node/reporters/junit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, promises as fs } from 'node:fs'
import { existsSync, promises as fs, readdirSync } from 'node:fs'
import { hostname } from 'node:os'
import { dirname, relative, resolve } from 'pathe'

Expand Down Expand Up @@ -75,6 +75,7 @@ export class JUnitReporter implements Reporter {
private baseLog!: (text: string) => Promise<void>
private logger!: IndentedLogger<Promise<void>>
private _timeStart = new Date()
private fileFd?: fs.FileHandle

async onInit(ctx: Vitest): Promise<void> {
this.ctx = ctx
Expand All @@ -85,12 +86,31 @@ export class JUnitReporter implements Reporter {
this.reportFile = resolve(this.ctx.config.root, outputFile)

const outputDirectory = dirname(this.reportFile)
if (!existsSync(outputDirectory))
if (!existsSync(outputDirectory)) {
this.ctx.logger.log('Creating:', outputDirectory)
await fs.mkdir(outputDirectory, { recursive: true })
}
else {
this.ctx.logger.log('Exists already:', outputDirectory)
}

try {
const fileFd = await fs.open(this.reportFile, 'w+')
this.fileFd = fileFd

this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`)
}
catch (e) {
this.ctx.logger.error(`Failed to open JUnit report file "${this.reportFile}" - ${(e as any).message}`)

const exists = existsSync(outputDirectory)
this.ctx.logger.log('Exists:', exists)

const fileFd = await fs.open(this.reportFile, 'w+')
const contents = readdirSync(outputDirectory)
this.ctx.logger.log('Contents:', contents.join(', '))

this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`)
throw e
}
}
else {
this.baseLog = async (text: string) => this.ctx.logger.log(text)
Expand Down Expand Up @@ -244,5 +264,7 @@ export class JUnitReporter implements Reporter {

if (this.reportFile)
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`)

await this.fileFd?.close()
}
}

0 comments on commit c742f6b

Please sign in to comment.