Skip to content

Commit

Permalink
chore: use trailing commas & verify in CI (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre authored Dec 3, 2022
1 parent 23b656e commit fedb7ff
Show file tree
Hide file tree
Showing 32 changed files with 160 additions and 134 deletions.
12 changes: 6 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = defineConfig({
extends: [
'eslint:recommended',
'plugin:n/recommended',
'plugin:@typescript-eslint/recommended'
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021
ecmaVersion: 2021,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
Expand All @@ -22,11 +22,11 @@ module.exports = defineConfig({
'prefer-const': [
'warn',
{
destructuring: 'all'
}
destructuring: 'all',
},
],
'n/no-missing-import': 'off', // doesn't like ts imports
'n/no-process-exit': 'off',
'@typescript-eslint/no-explicit-any': 'off' // we use any in some places
}
'@typescript-eslint/no-explicit-any': 'off', // we use any in some places
},
})
6 changes: 3 additions & 3 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"packageRules": [
{
"depTypeList": ["peerDependencies"],
"enabled": false
}
"enabled": false,
},
],
"ignoreDeps": []
"ignoreDeps": [],
}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
cache-dependency-path: "**/pnpm-lock.yaml"
- name: install
run: pnpm install --frozen-lockfile --prefer-offline
- name: format
run: pnpm format
- name: lint
run: pnpm run lint
- name: audit
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"tabWidth": 2,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "none",
"trailingComma": "all",
"overrides": [
{
"files": ["*.json5"],
Expand Down
4 changes: 2 additions & 2 deletions builds/vite-plugin-react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export async function build(options: RunOptions) {
return runInRepo({
...options,
repo: 'vitejs/vite-plugin-react',
build: 'build'
build: 'build',
})
}

export const packages = {
'@vitejs/plugin-react':'packages/plugin-react'
'@vitejs/plugin-react': 'packages/plugin-react',
}
6 changes: 3 additions & 3 deletions builds/vite-plugin-svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export async function build(options: RunOptions) {
repo: 'sveltejs/vite-plugin-svelte',
branch: options.viteMajor === 4 ? 'vite-4' : 'main',
overrides: {
svelte: 'latest'
svelte: 'latest',
},
build: 'build'
build: 'build',
})
}

export const packages = {
'@sveltejs/vite-plugin-svelte':'packages/vite-plugin-svelte',
'@sveltejs/vite-plugin-svelte': 'packages/vite-plugin-svelte',
}
6 changes: 3 additions & 3 deletions builds/vite-plugin-vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runInRepo} from '../utils'
import { runInRepo } from '../utils'
import { RunOptions } from '../types'

export async function build(options: RunOptions) {
Expand All @@ -10,6 +10,6 @@ export async function build(options: RunOptions) {
}

export const packages = {
'@vitejs/plugin-vue':'packages/plugin-vue',
'@vitejs/plugin-vue-jsx':'packages/plugin-vue-jsx'
'@vitejs/plugin-vue': 'packages/plugin-vue',
'@vitejs/plugin-vue-jsx': 'packages/plugin-vue-jsx',
}
30 changes: 15 additions & 15 deletions discord-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ type Env = {
const statusConfig = {
success: {
color: parseInt('57ab5a', 16),
emoji: ':white_check_mark:'
emoji: ':white_check_mark:',
},
failure: {
color: parseInt('e5534b', 16),
emoji: ':x:'
emoji: ':x:',
},
cancelled: {
color: parseInt('768390', 16),
emoji: ':stop_button:'
}
emoji: ':stop_button:',
},
}

async function run() {
Expand All @@ -34,7 +34,7 @@ async function run() {
}
if (!process.env.DISCORD_WEBHOOK_URL) {
console.warn(
"Skipped beacuse process.env.DISCORD_WEBHOOK_URL was empty or didn't exist"
"Skipped beacuse process.env.DISCORD_WEBHOOK_URL was empty or didn't exist",
)
return
}
Expand Down Expand Up @@ -64,17 +64,17 @@ async function run() {
{
title: `${statusConfig[env.STATUS].emoji} ${env.SUITE}`,
description: await createDescription(env.SUITE, targetText),
color: statusConfig[env.STATUS].color
}
]
color: statusConfig[env.STATUS].color,
},
],
}

const res = await fetch(env.DISCORD_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
body: JSON.stringify(webhookContent)
body: JSON.stringify(webhookContent),
})
if (res.ok) {
console.log('Sent Webhook')
Expand All @@ -85,7 +85,7 @@ async function run() {

function assertEnv<T>(
name: string,
value: T
value: T,
): asserts value is Exclude<T, undefined> {
if (!value) {
throw new Error(`process.env.${name} is empty or does not exist.`)
Expand All @@ -101,7 +101,7 @@ async function createRunUrl(suite: string) {

// when matrix
const jobM = result.jobs.find(
(job) => job.name === `${process.env.GITHUB_JOB} (${suite})`
(job) => job.name === `${process.env.GITHUB_JOB} (${suite})`,
)
return jobM?.html_url
}
Expand All @@ -115,8 +115,8 @@ async function fetchJobs() {
const url = `${process.env.GITHUB_API_URL}/repos/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/jobs`
const res = await fetch(url, {
headers: {
Accept: 'application/vnd.github.v3+json'
}
Accept: 'application/vnd.github.v3+json',
},
})
const result = await res.json()
return result as { jobs: GitHubActionsJob[] }
Expand All @@ -134,7 +134,7 @@ function createTargetText(
refType: RefType,
ref: string,
permRef: string | undefined,
repo: string
repo: string,
) {
const repoText = repo !== 'vitejs/vite' ? `${repo}:` : ''
if (refType === 'branch') {
Expand Down
31 changes: 19 additions & 12 deletions ecosystem-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import path from 'path'
import process from 'process'
import { cac } from 'cac'

import {setupEnvironment, setupViteRepo, buildVite, bisectVite, parseViteMajor, parseMajorVersion} from './utils'
import {
setupEnvironment,
setupViteRepo,
buildVite,
bisectVite,
parseViteMajor,
parseMajorVersion,
} from './utils'
import { CommandOptions, RunOptions } from './types'

const cli = cac()
Expand All @@ -18,11 +25,11 @@ cli
.action(async (suites, options: CommandOptions) => {
const { root, vitePath, workspace } = await setupEnvironment()
const suitesToRun = getSuitesToRun(suites, root)
let viteMajor;
let viteMajor
if (!options.release) {
await setupViteRepo(options)
await buildVite({ verify: options.verify })
viteMajor = parseViteMajor(vitePath);
viteMajor = parseViteMajor(vitePath)
} else {
viteMajor = parseMajorVersion(options.release)
}
Expand All @@ -33,7 +40,7 @@ cli
workspace,
release: options.release,
verify: options.verify,
skipGit: false
skipGit: false,
}
for (const suite of suitesToRun) {
await run(suite, runOptions)
Expand All @@ -43,7 +50,7 @@ cli
cli
.command('build-vite', 'build vite only')
.option('--verify', 'verify vite checkout by running tests', {
default: false
default: false,
})
.option('--repo <repo>', 'vite repository to use', { default: 'vitejs/vite' })
.option('--branch <branch>', 'vite branch to use', { default: 'main' })
Expand All @@ -60,7 +67,7 @@ cli
.option(
'--verify',
'verify checkout by running tests before using local vite',
{ default: false }
{ default: false },
)
.option('--repo <repo>', 'vite repository to use', { default: 'vitejs/vite' })
.option('--release <version>', 'vite release to use from npm registry')
Expand All @@ -72,7 +79,7 @@ cli
root,
vitePath,
viteMajor: parseViteMajor(vitePath),
workspace
workspace,
}
for (const suite of suitesToRun) {
await run(suite, runOptions)
Expand All @@ -82,7 +89,7 @@ cli
cli
.command(
'bisect [...suites]',
'use git bisect to find a commit in vite that broke suites'
'use git bisect to find a commit in vite that broke suites',
)
.option('--good <ref>', 'last known good ref, e.g. a previous tag. REQUIRED!')
.option('--verify', 'verify checkouts by running tests', { default: false })
Expand All @@ -93,7 +100,7 @@ cli
.action(async (suites, options: CommandOptions & { good: string }) => {
if (!options.good) {
console.log(
'you have to specify a known good version with `--good <commit|tag>`'
'you have to specify a known good version with `--good <commit|tag>`',
)
process.exit(1)
}
Expand All @@ -111,7 +118,7 @@ cli
root,
vitePath,
viteMajor: parseViteMajor(vitePath),
workspace
workspace,
})
}
isFirstRun = false
Expand All @@ -135,7 +142,7 @@ async function run(suite: string, options: RunOptions) {
const { test } = await import(`./tests/${suite}.ts`)
await test({
...options,
workspace: path.resolve(options.workspace, suite)
workspace: path.resolve(options.workspace, suite),
})
}

Expand All @@ -150,7 +157,7 @@ function getSuitesToRun(suites: string[], root: string) {
suitesToRun = availableSuites
} else {
const invalidSuites = suitesToRun.filter(
(x) => !x.startsWith('_') && !availableSuites.includes(x)
(x) => !x.startsWith('_') && !availableSuites.includes(x),
)
if (invalidSuites.length) {
console.log(`invalid suite(s): ${invalidSuites.join(', ')}`)
Expand Down
2 changes: 1 addition & 1 deletion tests/_hydrogen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export async function test(options: RunOptions) {
...options,
repo: 'Shopify/hydrogen',
build: 'build',
test: 'test:vite-ci'
test: 'test:vite-ci',
})
}
6 changes: 3 additions & 3 deletions tests/_selftest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ export async function test(options: RunOptions) {
const pkg = JSON.parse(await fs.promises.readFile(pkgFile, 'utf-8'))
if (pkg.name !== 'vite-ecosystem-ci') {
throw new Error(
`invalid checkout, expected package.json with "name":"vite-ecosystem-ci" in ${dir}`
`invalid checkout, expected package.json with "name":"vite-ecosystem-ci" in ${dir}`,
)
}
pkg.scripts.selftestscript =
"[ -d ../../vite/packages/vite/dist ] || (echo 'vite build failed' && exit 1)"
await fs.promises.writeFile(
pkgFile,
JSON.stringify(pkg, null, 2),
'utf-8'
'utf-8',
)
},
test: 'pnpm run selftestscript',
verify: false
verify: false,
})
}
2 changes: 1 addition & 1 deletion tests/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export async function test(options: RunOptions) {
repo: 'withastro/astro',
branch: 'main',
build: 'build:ci',
test: 'test:vite-ci'
test: 'test:vite-ci',
})
}
2 changes: 1 addition & 1 deletion tests/histoire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export async function test(options: RunOptions) {
...options,
repo: 'histoire-dev/histoire',
build: 'build',
test: ['test', 'test:examples']
test: ['test', 'test:examples'],
})
}
6 changes: 3 additions & 3 deletions tests/iles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export async function test(options: RunOptions) {
await runInRepo({
...options,
repo: 'ElMassimo/iles',
overrides:{
"@vitejs/plugin-vue": true
overrides: {
'@vitejs/plugin-vue': true,
},
beforeInstall: async () => $`git lfs install && git lfs pull`,
build: 'build:all',
test: 'test'
test: 'test',
})
}
2 changes: 1 addition & 1 deletion tests/ladle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export async function test(options: RunOptions) {
branch: options.viteMajor === 4 ? 'vite-4' : 'main',
build: 'build',
beforeTest: 'pnpm playwright install chromium',
test: 'test'
test: 'test',
})
}
4 changes: 2 additions & 2 deletions tests/laravel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { RunOptions } from '../types'

export async function test(options: RunOptions) {
//see https://github.com/laravel/vite-plugin/blob/73466441b0c9eb0c1a5ce0a0e937bd83eaef4b70/.github/workflows/tests.yml#L10
process.env.LARAVEL_BYPASS_ENV_CHECK="1";
process.env.LARAVEL_BYPASS_ENV_CHECK = '1'
await runInRepo({
...options,
repo: 'laravel/vite-plugin',
build: 'build',
test: 'test'
test: 'test',
})
}
4 changes: 2 additions & 2 deletions tests/marko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function test(options: RunOptions) {
build: 'build',
test: 'test',
overrides: {
esbuild: `${options.vitePath}/packages/vite/node_modules/esbuild`
}
esbuild: `${options.vitePath}/packages/vite/node_modules/esbuild`,
},
})
}
Loading

0 comments on commit fedb7ff

Please sign in to comment.