Skip to content

fix: ensure isr conditional 404 fix works for next 11 #1765

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 73 additions & 0 deletions .github/workflows/cypress-next-11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Run e2e (Next 11 demo)
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
push:
branches:
- main
paths:
- 'demos/next-11/**/*.{js,jsx,ts,tsx}'
- 'cypress/integration/next-11/**/*.{ts,js}'
- 'src/**/*.{ts,js}'
jobs:
cypress:
name: Cypress
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's not many tests that are included in this suite, it's likely not worth having so many containers dedicated to this. However, I'd leave it as a matrix so that as we add more tests it's really easy to add containers to keep the time to run the tests low.

Suggested change
containers: [1, 2, 3, 4]
containers: [1]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Generate Github token
uses: navikt/github-app-token-generator@v1
id: get-token
with:
private-key: ${{ secrets.TOKENS_PRIVATE_KEY }}
app-id: ${{ secrets.TOKENS_APP_ID }}

- name: Checkout @netlify/wait-for-deploy-action
uses: actions/checkout@v2
with:
repository: netlify/wait-for-deploy-action
token: ${{ steps.get-token.outputs.token }}
path: ./.github/actions/wait-for-netlify-deploy

- name: Wait for Netlify Deploy
id: deploy
uses: ./.github/actions/wait-for-netlify-deploy
with:
site-name: nextjs-plugin-next-11-demo
timeout: 300

- name: Deploy successful
if: ${{ steps.deploy.outputs.origin-url }}
run: echo ${{ steps.deploy.outputs.origin-url }}

- name: Node
uses: actions/setup-node@v2
with:
node-version: '16'

- run: npm install

- name: Cypress run
if: ${{ steps.deploy.outputs.origin-url }}
id: cypress
uses: cypress-io/github-action@v2
with:
browser: chrome
headless: true
record: true
parallel: true
config-file: cypress/config/next-11.json
group: 'Next Runtime - Next 11'
spec: cypress/integration/next-11/*
env:
DEBUG: '@cypress/github-action'
CYPRESS_baseUrl: ${{ steps.deploy.outputs.origin-url }}
CYPRESS_NETLIFY_CONTEXT: ${{ steps.deploy.outputs.context }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.NEXT_11_CYPRESS_RECORD_KEY }}
5 changes: 5 additions & 0 deletions cypress/config/next-11.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:3000",
"integrationFolder": "cypress/integration/next-11",
"projectId": "asp7p9"
}
8 changes: 8 additions & 0 deletions cypress/integration/next-11/isr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('ISR pages', () => {
it('renders a 404 from an ISR page with TTL=60', () => {
cy.request({ url: '/isr-not-found', failOnStatusCode: false }).then((res) => {
expect(res.status).to.eq(404)
expect(res.headers).to.have.property('x-nf-render-mode', 'odb ttl=60')
})
})
})
4 changes: 4 additions & 0 deletions demos/next-11/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "next",
"root": true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case anyone else is interested in what this property does (because I didn't know offhand either), from the ESLint docs site:

By default, ESLint looks for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place "root": true inside the .eslintrc.* file or eslintConfig field of the package.json file or in the .eslintrc.* file at your project’s root level. ESLint stops looking in parent folders once it finds a configuration with "root": true.

@orinokai This is a bit of a nitpick, but it might be worth adding a small note here about ESLint not looking for configuration in parent directories past this point with this setting since this info is a little buried in the docs

}
38 changes: 38 additions & 0 deletions demos/next-11/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

netlify/functions
.netlify/functions
.netlify/cache
15 changes: 15 additions & 0 deletions demos/next-11/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[build]
command = "next build"
publish = ".next"
ignore = "if [ $CACHED_COMMIT_REF == $COMMIT_REF ]; then (exit 1); else git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../..; fi;"

[[plugins]]
package = "@netlify/plugin-nextjs"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be included since

[[plugins]]
package = "@netlify/plugin-local-install-core"


[[plugins]]
package = "../plugin-wrapper"

is present in the file


# This is a fake plugin, that makes it run npm install
[[plugins]]
package = "@netlify/plugin-local-install-core"

[[plugins]]
package = "../plugin-wrapper"

Loading