-
Notifications
You must be signed in to change notification settings - Fork 26k
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
Cover 1st-party examples with tests #45270
Changes from 46 commits
df87d54
6487a71
4adcd49
d6b5a55
d539b41
a1be69e
07ba14d
daadd6b
9c97eff
0bfa744
9214bca
9ee2286
4470e8d
c3a4dd7
c1e6c23
6e02849
0a76e55
2850d4f
c424ed6
7c92114
db1f050
3c883e8
6b33638
404c026
10b7f10
c9a9696
af2e484
e052d7f
f220ab8
98f5a57
40ef8b7
c2f6966
f07baa0
7dda882
70dd3c7
a6330b6
0cadaef
2c0e5a6
dbb865c
8a869c0
92b045f
8d39fbc
494d995
9a17e92
b35c256
eed8fb8
bad9f53
e2f938d
006cb1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This file duplicates bunch of things from build_test_deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
is_dispatched: | ||
description: 'Leave this option enabled' | ||
required: true | ||
default: true | ||
type: boolean | ||
schedule: | ||
- cron: '0 */4 * * *' | ||
|
||
name: Test examples | ||
|
||
env: | ||
PNPM_VERSION: 7.24.3 | ||
|
||
jobs: | ||
testExamples: | ||
# Don't execute using cron on forks | ||
if: (github.repository == 'vercel/next.js') || (inputs.is_dispatched == true) | ||
name: Test Examples | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
env: | ||
NEXT_TELEMETRY_DISABLED: 1 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: [16, 18] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 25 | ||
# https://github.com/actions/virtual-environments/issues/1187 | ||
- name: tune linux network | ||
run: sudo ethtool -K eth0 tx off rx off | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
check-latest: true | ||
|
||
- run: npm i -g pnpm@${PNPM_VERSION} | ||
|
||
- run: pnpm install | ||
- run: pnpm build | ||
|
||
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start xvfb-run node run-tests.js --type examples >> /proc/1/fd/1" | ||
name: Run test/examples |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
|
||
const testedExamples = [ | ||
// Internal features | ||
'active-class-name', | ||
'amp', | ||
'amp-first', | ||
'amp-story', | ||
'api-routes', | ||
'api-routes-cors', | ||
'api-routes-middleware', | ||
'api-routes-rate-limit', | ||
'api-routes-rest', | ||
'app-dir-i18n-routing', | ||
'app-dir-mdx', | ||
'basic-css', | ||
'basic-export', | ||
'blog', | ||
'blog-starter', | ||
'catch-all-routes', | ||
'custom-routes-proxying', | ||
'custom-server', | ||
'data-fetch', | ||
'dynamic-routing', | ||
'environment-variables', | ||
'fast-refresh-demo', | ||
'head-elements', | ||
'headers', | ||
'hello-world', | ||
'hello-world-esm', | ||
'i18n-routing', | ||
'image-component', | ||
'image-legacy-component', | ||
'layout-component', | ||
'middleware', | ||
'middleware-matcher', | ||
'modularize-imports', | ||
'nested-components', | ||
'next-css', | ||
'next-forms', | ||
'progressive-render', | ||
'redirects', | ||
'remove-console', | ||
'reproduction-template', | ||
'rewrites', | ||
'script-component', | ||
'ssr-caching', | ||
'styled-jsx-with-csp', | ||
'svg-components', | ||
'using-router', | ||
'with-absolute-imports', | ||
'with-app-layout', | ||
'with-context-api', | ||
'with-env-from-next-config-js', | ||
'with-loading', | ||
'with-shallow-routing', | ||
'with-sitemap', | ||
'with-typescript', | ||
'with-typescript-types', | ||
'with-web-worker', | ||
'with-webassembly', | ||
|
||
// Library integrations that we can't break | ||
'with-jest', | ||
'with-jest-babel', | ||
'with-mdx', | ||
'with-mdx-remote', | ||
'with-tailwindcss', | ||
'with-turbopack', | ||
'with-vercel-fetch', | ||
] | ||
|
||
const testExample = (example) => { | ||
const exampleFiles = path.join(__dirname, '..', '..', 'examples', example) | ||
|
||
const packageJson = fs.readJsonSync(path.join(exampleFiles, 'package.json')) | ||
describe(`example '${example}'`, () => { | ||
// If there is an issue during a build, jest won't tell us which example caused it | ||
// we need to log it ourselfs | ||
beforeAll(() => { | ||
require('console').log(`Running example '${example}'`) | ||
}) | ||
createNextDescribe( | ||
`example '${example}'`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, See the comment. We need to fire |
||
{ | ||
files: exampleFiles, | ||
dependencies: { | ||
// We need to make sure that these default dependencies are not installed by default | ||
// for our examples to ensure that they have all their dependencies in package.json | ||
'@types/node': undefined, | ||
'@types/react': undefined, | ||
next: undefined, | ||
react: undefined, | ||
'react-dom': undefined, | ||
typescript: undefined, | ||
...packageJson.dependencies, | ||
...packageJson.devDependencies, | ||
}, | ||
}, | ||
() => { | ||
it('builds', () => {}) | ||
} | ||
) | ||
}) | ||
} | ||
|
||
testedExamples.forEach(testExample) | ||
jankaifer marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an allowlist, we might want to change this to an ignorelist so that new examples are automatically tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not running in normal CI it's actually possible now 👍
We probably should run all examples and we will see in the CI exactly which ones are broken.
But I still think that we want to have a workflow like this with only 1st party examples that should be always green.
And if we start running CI on all examples we need to be extra cautious when adding new libraries because we will be installing that library with access to our CI secrets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add this in Follow-up PR