Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into feat/schedule-property
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Nov 18, 2021
2 parents 784e310 + eddf2a3 commit 3890af8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Next.js Integration test
name: Integration test

on:
pull_request:
branches: [main, 'chore/ci-e2e-nextjs']
branches: [main, 'chore/ci-integration-tests']
# Run on release PRs only, or changes to this same file
paths: ['CHANGELOG.md', '.github/workflows/e2e-nextjs.yml']
paths: ['CHANGELOG.md', '.github/workflows/integration-tests.yml']

jobs:
integration:
runs-on: ubuntu-latest
strategy:
matrix:
bundler: ['default', 'esbuild']
site: ['netlify/netlify-plugin-nextjs']
steps:
- name: Checking out zip-it-and-ship-it
uses: actions/checkout@v2
with:
path: zip-it-and-ship-it
- name: Checking out netlify-plugin-nextjs
- name: Checking out test site
uses: actions/checkout@v2
with:
repository: netlify/netlify-plugin-nextjs
path: netlify-plugin-nextjs
repository: '${{ matrix.site }}'
path: test-site
- name: Checking out netlify-cli
uses: actions/checkout@v2
with:
Expand All @@ -35,22 +35,14 @@ jobs:
# We need to add each of the lockfile paths so that the global npm cache is populated accordingly
cache-dependency-path: |
zip-it-and-ship-it/package-lock.json
netlify-plugin-nextjs/package-lock.json
test-site/package-lock.json
netlify-cli/npm-shrinkwrap.json
- name: Installing netlify-cli
run: npm ci
working-directory: netlify-cli
- name: Installing netlify-plugin-nextjs
- name: Installing test site
run: npm install
working-directory: netlify-plugin-nextjs
- name: Patching netlify.toml to change the bundler
if: "${{ matrix.bundler != 'default' }}"
run:
'npm i @iarna/toml --no-save && node -e "const { readFileSync, writeFileSync } = require(''fs'');const {
parse, stringify } = require(''@iarna/toml'');const config = parse(readFileSync(''netlify.toml'',
''utf-8''));config.functions = { ...config.functions, node_bundler: ''${{ matrix.bundler }}''
};writeFileSync(''netlify.toml'', stringify(config));"'
working-directory: netlify-plugin-nextjs
working-directory: test-site
- name: Symlinking zip-it-and-ship-it (1/2)
run:
rm -rf $GITHUB_WORKSPACE/netlify-cli/node_modules/@netlify/zip-it-and-ship-it && mkdir -p
Expand All @@ -69,19 +61,19 @@ jobs:
run:
$GITHUB_WORKSPACE/netlify-cli/bin/run deploy --build --json --site ${{ secrets.NETLIFY_SITE_ID }} --auth ${{
secrets.NETLIFY_TOKEN }} --functions .netlify/functions > .netlify-deploy-log.json
working-directory: netlify-plugin-nextjs
working-directory: test-site
- name: Parsing deploy result
run: |
node -e "console.log('deploy_log_url=' + require('./.netlify-deploy-log.json').logs)" >> $GITHUB_ENV
node -e "console.log('deploy_url=' + require('./.netlify-deploy-log.json').deploy_url)" >> $GITHUB_ENV
working-directory: netlify-plugin-nextjs
working-directory: test-site
- name: Posting comment
uses: KeisukeYamashita/create-comment@v1
with:
check-only-first-line: true
unique: true
comment: |
## Next.js Integration Test (${{ matrix.bundler }})
## Integration Test: ${{ matrix.site }}
- **Deploy URL**: ${{ env.deploy_url }}
- **Deploy logs**: ${{ env.deploy_log_url }}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"nyc": "^15.0.0",
"sinon": "^12.0.0",
"sort-on": "^4.1.1",
"source-map-support": "^0.5.20",
"throat": "^6.0.1",
"typescript": "^4.4.3"
},
Expand Down
1 change: 1 addition & 0 deletions src/runtimes/node/bundlers/nft/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const transpile = async (path: string, config: FunctionConfig) => {
format: 'cjs',
logLevel: 'error',
platform: 'node',
sourcemap: Boolean(config.nodeSourcemap),
target: [nodeTarget],
write: false,
})
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/esm-throwing-error/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parserOptions": { "sourceType": "module" }
}
5 changes: 5 additions & 0 deletions tests/fixtures/esm-throwing-error/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const handler = () => {
throw new Error('uh-oh')
}

export { handler }
28 changes: 28 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const sortOn = require('sort-on')
const { dir: getTmpDir, tmpName } = require('tmp-promise')
const unixify = require('unixify')

require('source-map-support').install()

// We must require this file first because we need to stub it before the main
// functions are required.
// eslint-disable-next-line import/order
Expand Down Expand Up @@ -2379,3 +2381,29 @@ testMany(
})
},
)

test('Generates a sourcemap for any transpiled files when `nodeSourcemap: true`', async (t) => {
const fixtureName = 'esm-throwing-error'
const basePath = join(FIXTURES_DIR, fixtureName)
const { files } = await zipFixture(t, fixtureName, {
opts: {
archiveFormat: 'none',
basePath,
config: { '*': { nodeBundler: 'nft', nodeSourcemap: true } },
featureFlags: { nftTranspile: true },
},
})
const func = require(join(files[0].path, 'function.js'))

try {
func.handler()

t.fail()
} catch (error) {
const filePath = join(files[0].path, 'src', 'tests', 'fixtures', fixtureName, 'function.js')

// Asserts that the line/column of the error match the position of the
// original source file, not the transpiled one.
t.true(error.stack.includes(`${filePath}:2:9`))
}
})

0 comments on commit 3890af8

Please sign in to comment.