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 174e272
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 173 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
10 changes: 8 additions & 2 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,9 +61,15 @@ export class C8CoverageProvider extends BaseCoverageProvider implements Coverage
}

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

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
26 changes: 22 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 @@ -85,12 +85,30 @@ 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)
}

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

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}`)

this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`)
const exists = existsSync(outputDirectory)
this.ctx.logger.log('Exists:', exists)

const contents = readdirSync(outputDirectory)
this.ctx.logger.log('Contents:', contents.join(', '))

throw e
}
}
else {
this.baseLog = async (text: string) => this.ctx.logger.log(text)
Expand Down

0 comments on commit 174e272

Please sign in to comment.