Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: rework test matrix #912

Merged
merged 25 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 43 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@ on:
branches:
- main

# https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml
env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144

# Remove default permissions of GITHUB_TOKEN for security
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: ${{ github.event_name != 'push' }}

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [18]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 18
cache: "pnpm"

- name: Install dependencies
Expand All @@ -38,22 +47,17 @@ jobs:
uses: actions/cache@v3
with:
path: packages/*/dist
key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }}
key: ubuntu-latest-node-v18-${{ github.sha }}

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

strategy:
matrix:
os: [ubuntu-latest]
node: [20]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 20
danielroe marked this conversation as resolved.
Show resolved Hide resolved
cache: "pnpm"

- name: Install dependencies
Expand All @@ -71,66 +75,55 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [18]
env: ['dev', 'built']
builder: ['vite', 'webpack']
transpile: ['transpile', 'no-transpile']
compatibility: ['compatibility', 'no-compatibility']
resolve: ['resolve', 'no-resolve']
exclude:
- transpile: 'no-transpile'
builder: 'vite'
- compatibility: 'no-compatibility'
builder: 'vite'
- resolve: 'no-resolve'
builder: 'vite'
- compatibility: 'no-compatibility'
env: 'dev'

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Test (fixtures)
run: pnpm test:fixtures

- name: Test (fixtures with dev)
run: pnpm test:fixtures:dev
env:
TEST_ENV: ${{ matrix.env }}
TEST_BUILDER: ${{ matrix.builder }}
TEST_TRANSPILE: ${{ matrix.transpile || 'transpile' }}
TEST_COMPATIBILITY: ${{ matrix.compatibility || 'compatibility' }}
TEST_RESOLVE: ${{ matrix.resolve || 'resolve' }}
NODE_OPTIONS: --max-old-space-size=8192

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

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [18]

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Test (fixtures)
run: pnpm test:fixtures:webpack

- name: Test (fixtures with dev)
run: pnpm test:fixtures:webpack:dev

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

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [18]

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 18
cache: "pnpm"

- name: Install dependencies
Expand All @@ -151,21 +144,15 @@ jobs:
- lint
- build
- test-fixtures
- test-fixtures-webpack
- test-unit
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [18]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 18
cache: "pnpm"

- name: Install dependencies
Expand All @@ -175,7 +162,7 @@ jobs:
uses: actions/cache@v3
with:
path: packages/*/dist
key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }}
key: ubuntu-latest-node-v18-${{ github.sha }}

- name: Release Edge
run: ./scripts/release-edge.sh
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"dev:prepare": "pnpm build:stub && nuxi prepare playground",
"lint": "eslint --ext .vue,.ts,.js,.mjs .",
"test:fixtures": "pnpm dev:prepare && JITI_ESM_RESOLVE=1 vitest run --dir test",
"test:fixtures:dev": "NUXT_TEST_DEV=true pnpm test:fixtures",
"test:fixtures:webpack": "TEST_WITH_WEBPACK=1 pnpm test:fixtures",
"test:fixtures:webpack:dev": "TEST_WITH_WEBPACK=1 NUXT_TEST_DEV=true pnpm test:fixtures",
"test:fixtures:dev": "TEST_ENV=dev pnpm test:fixtures",
"test:fixtures:webpack": "TEST_BUILDER=webpack pnpm test:fixtures",
"test:fixtures:webpack:dev": "TEST_BUILDER=webpack TEST_ENV=dev pnpm test:fixtures",
"test:unit": "vitest run --dir packages"
},
"devDependencies": {
Expand Down
26 changes: 19 additions & 7 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ import { defineNuxtConfig } from '@nuxt/bridge'
// @ts-ignore
global.__NUXT_PREPATHS__ = (global.__NUXT_PREPATHS__ || []).concat(__dirname)

const bridgeConfig = {
vite: process.env.TEST_BUILDER !== 'webpack',
transpile: process.env.TEST_TRANSPILE !== 'no-transpile',
compatibility: process.env.TEST_COMPATIBILITY !== 'no-compatibility',
resolve: process.env.TEST_RESOLVE !== 'no-resolve',
// Not yet tested in matrix
nitro: process.env.TEST_NITRO !== 'false',
nitroGenerator: process.env.TEST_NITRO_GENERATOR !== 'false',
imports: process.env.TEST_IMPORTS !== 'false',
meta: process.env.TEST_META !== 'false',
typescript: process.env.TEST_TYPESCRIPT !== 'false',
macros: {
pageMeta: true
}
}

console.log('Bridge config:', bridgeConfig)

export default defineNuxtConfig({
app: {
head: {
Expand Down Expand Up @@ -36,18 +54,12 @@ export default defineNuxtConfig({
},
plugins: ['plugins/template.ts']
},
bridge: bridgeConfig,
vite: {
build: {
assetsInlineLimit: 100 // keep SVG as assets URL
}
},
bridge: {
meta: true,
vite: !process.env.TEST_WITH_WEBPACK,
macros: {
pageMeta: true
}
},
runtimeConfig: {
secretKey: 'nuxt',
public: {
Expand Down
13 changes: 6 additions & 7 deletions test/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { describe, expect, it } from 'vitest'
import { setup, $fetch, fetch, startServer } from '@nuxt/test-utils'
import { expectNoClientErrors, parseData, renderPage } from './utils'

const isWebpack = process.env.TEST_WITH_WEBPACK
const isWebpack = process.env.TEST_BUILDER === 'webpack'
const isDev = process.env.TEST_ENV === 'dev'

await setup({
rootDir: fileURLToPath(new URL('../playground', import.meta.url)),
server: true,
dev: !!process.env.NUXT_TEST_DEV,
dev: isDev,
nuxtConfig: {
// @ts-expect-error No types yet.
bridge: { vite: !isWebpack },
buildDir: process.env.NITRO_BUILD_DIR,
nitro: { output: { dir: process.env.NITRO_OUTPUT_DIR } }
}
Expand Down Expand Up @@ -292,12 +291,12 @@ describe('nitro plugins', () => {
})

describe('dynamic paths', () => {
if (process.env.NUXT_TEST_DEV) {
if (isDev) {
// TODO:
it.todo('dynamic paths in dev')
return
}
if (process.env.TEST_WITH_WEBPACK) {
if (isWebpack) {
// TODO:
it.todo('work with webpack')
return
Expand All @@ -312,7 +311,7 @@ describe('dynamic paths', () => {
})

// Vite legacy build does not emit CSS files
it.skipIf(!process.env.TEST_WITH_WEBPACK)('adds relative paths to CSS', async () => {
it.skipIf(!isWebpack)('adds relative paths to CSS', async () => {
const html = await $fetch('/assets')
const urls = Array.from(html.matchAll(/(href|src)="(.*?)"/g)).map(m => m[2])
const cssURL = urls.find(u => /_nuxt\/assets.*\.css$/.test(u))
Expand Down
8 changes: 1 addition & 7 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { defineConfig } from 'vite'

export default defineConfig({
test: {
deps: {
inline: [/@nuxt\/test-utils/]
}
}
})
export default defineConfig({})