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

Some changes to make vite-ecosystem-ci pass #371

Merged
merged 11 commits into from
Jul 23, 2022
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- name: Run tests
run: ${{ matrix.testCmd }}
env:
GIT_REPOSITORY: ${{ github.repository }}
GIT_BRANCH: ${{ github.ref_name }}
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
9 changes: 0 additions & 9 deletions boilerplates/.testRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
editFileRevert,
} from '../libframe/test/setup'
import assert from 'assert'
const viteVersion = '3.?.?'

function testRun(
cmd: 'npm run dev' | 'npm run prod' | 'npm run preview',
Expand All @@ -35,14 +34,6 @@ function testRun(
const isProd = cmd === 'npm run prod' || cmd === 'npm run preview'
const isDev = !isProd

if (uiFramewok === 'preact' && isProd && viteVersion.startsWith('3')) {
// https://github.com/preactjs/preact/issues/3558
const msg = 'SKIPPED preact prod until it supports Vite 3.'
console.log(msg)
test(msg, () => {})
return
}

test('page content is rendered to HTML', async () => {
const html = await fetchHtml('/')
expect(html).toContain('<h1>Welcome</h1>')
Expand Down
32 changes: 18 additions & 14 deletions examples/cloudflare-workers-react-full/.testRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ import { page, run, autoRetry, fetchHtml, isGithubAction, urlBase } from '../../
function testRun(cmd: 'npm run dev' | 'npm run preview', { hasStarWarsPage }: { hasStarWarsPage: boolean }) {
const isWrangler = cmd === 'npm run preview'

if (isWrangler) {
if (isGithubAction()) {
const repository = process.env['GIT_REPOSITORY']
expect(repository).toBeTruthy()
// GitHub Actions doesn't make secrets available to Pull Requests.
// - https://git.luolix.topmunity/t/feature-request-allow-secrets-in-approved-external-pull-requests/18071/4
if (isGithubAction() && process.env['GIT_BRANCH'] !== 'main') {
const msg = 'SKIPPED: wrangler tests are not run in Pull Requests'
console.log(msg)
test(msg, () => {})
return
}
const envVars = Object.keys(process.env)
if (!envVars.includes('CF_ACCOUNT_ID') || !envVars.includes('CF_API_TOKEN')) {
const msg = 'SKIPPED: Cloudflare Workers tokens not provided.'
console.log(msg)
test(msg, () => {})
return
// - https://git.luolix.topmunity/t/feature-request-allow-secrets-in-approved-external-pull-requests/18071/4
if (!process.env['CF_ACCOUNT_ID']) {
expect(repository).not.toBe('brillout/vite-plugin-ssr')
expect(process.env['CF_ACCOUNT_ID']).toBeFalsy()
expect(process.env['CF_API_TOKEN']).toBeFalsy()
if (isWrangler) {
const msg = 'SKIPPED: wrangler tests cannot be run in Pull Requests.'
console.log(msg)
test(msg, () => {})
return
}
} else {
expect(repository).toBe('brillout/vite-plugin-ssr')
expect(process.env['CF_ACCOUNT_ID']).toBeTruthy()
expect(process.env['CF_API_TOKEN']).toBeTruthy()
}
}

Expand Down
14 changes: 14 additions & 0 deletions examples/graphql-apollo-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,19 @@
"react-dom": "^18.2.0",
"vite": "^3.0.2",
"vite-plugin-ssr": "0.4.11"
},
"pnpm": {
"packageExtensions": {
"@apollo/client": {
"peerDependencies": {
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
}
}
}
}
}
}
14 changes: 14 additions & 0 deletions examples/graphql-apollo-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,19 @@
"vite": "^3.0.2",
"vite-plugin-ssr": "0.4.11",
"vue": "^3.2.27"
},
"pnpm": {
"packageExtensions": {
"@apollo/client": {
"peerDependencies": {
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions examples/graphql-apollo-vue/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ import ssr from 'vite-plugin-ssr/plugin'

export default {
plugins: [vue(), ssr()],
ssr: {
noExternal: ['@apollo/client', '@vue/apollo-composable']
}
}
4 changes: 2 additions & 2 deletions examples/layouts-react/.testRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function testRun(cmd: 'npm run dev' | 'npm run preview', uiFrameworkRoot: 'react
}
{
await page.click('a[href="/starship/reviews"]')
let text: string
let text!: string | null
await autoRetry(async () => {
text = await page.textContent('body')
expect(text).toContain(textReviews)
Expand All @@ -56,7 +56,7 @@ function testRun(cmd: 'npm run dev' | 'npm run preview', uiFrameworkRoot: 'react
}
{
await page.click('a[href="/starship/spec"]')
let text: string
let text!: string | null
await autoRetry(async () => {
text = await page.textContent('body')
expect(text).toContain(textTechSpec)
Expand Down
6 changes: 3 additions & 3 deletions examples/preact-client-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"dependencies": {
"@babel/core": "^7.17.10",
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@preact/preset-vite": "^2.2.0",
"preact": "^10.7.3",
"preact-render-to-string": "^5.2.0",
"@preact/preset-vite": "^2.3.0",
"preact": "^10.10.0",
"preact-render-to-string": "^5.2.1",
"vite": "^2.9.14",
"vite-plugin-ssr": "0.4.11"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/preact-server-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"dependencies": {
"@babel/core": "^7.17.10",
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@preact/preset-vite": "^2.2.0",
"preact": "^10.7.1",
"preact-render-to-string": "^5.2.0",
"@preact/preset-vite": "^2.3.0",
"preact": "^10.10.0",
"preact-render-to-string": "^5.2.1",
"vite": "^2.9.14",
"vite-plugin-ssr": "0.4.11"
}
Expand Down
9 changes: 0 additions & 9 deletions examples/urql/.testRun.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
export { testRun }

import { page, run, autoRetry, fetchHtml, urlBase } from '../../libframe/test/setup'
const viteVersion = '3.?.?'

function testRun(cmd: 'npm run dev' | 'npm run preview') {
run(cmd)

if (cmd === 'npm run preview' && viteVersion.startsWith('3')) {
// https://github.com/FormidableLabs/urql/issues/2484
const msg = 'SKIPPED urql production test until it supports Vite 3.'
console.log(msg)
test(msg, () => {})
return
}

test('urql content is rendered to HTML', async () => {
const html = await fetchHtml('/')
expect(html).toContain('<h1>Countries</h1>')
Expand Down
2 changes: 1 addition & 1 deletion examples/urql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react-dom": "^18.1.0",
"react-ssr-prepass": "^1.5.0",
"typescript": "^4.6.4",
"urql": "^2.2.0",
"urql": "^2.2.3",
"vite": "^2.9.14",
"vite-plugin-ssr": "0.4.11"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "pnpm@6.21.0",
"packageManager": "pnpm@7.6.0",
"scripts": {
"========= Dev": "",
"// Develop vite-plugin-ssr": "",
Expand Down
Loading