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

Improves routing for dynamic routes #17

Merged
merged 2 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 61 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,81 @@ on:
pull_request:

jobs:
test-proxy:
test-integration:
runs-on: ubuntu-latest
container: registry.gitlab.com/dealmore/dealmore-build-images/lambdaci:nodejs12.x
steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
.yarn
**/node_modules
key: ${{ runner.os }}-test

- name: Jest
run: |
yarn --frozen-lockfile --cache-folder .yarn
yarn test

test-e2e-prepare:
runs-on: ubuntu-latest
container: registry.gitlab.com/dealmore/dealmore-build-images/lambdaci:nodejs12.x
steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
.yarn
**/node_modules
key: ${{ runner.os }}-test

- name: Yarn install
run: yarn --frozen-lockfile --cache-folder .yarn

- name: Build tf-next
run: yarn --cwd packages/terraform-next-build build

- name: Build e2e fixtures
run: yarn test:e2e:prepare

- name: Upload e2e fixtures
uses: actions/upload-artifact@v2
with:
name: e2e-fixtures
path: |
packages/proxy/dist.zip
test/**/.next-tf/**/*
if-no-files-found: error

test-e2e:
needs: test-e2e-prepare
runs-on: ubuntu-latest
env:
SAM_CLI_TELEMETRY: 0
# Don't worry these are fake AWS credentials for AWS SAM
AWS_ACCESS_KEY_ID: ABIAZLJNBT8I3KFOU4NO
AWS_SECRET_ACCESS_KEY: 4Xt3Rbx4DO21MhK1IHXZXRvVRDuqaQ0Wo5lILA/h
steps:
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
- name: Setup Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Setup AWS SAM
run: |
brew tap aws/tap
brew install aws-sam-cli
sam --version
- uses: actions/checkout@v2
- name: Download e2e fixtures
uses: actions/download-artifact@v2
with:
name: e2e-fixtures
- run: yarn install --frozen-lockfile --check-files
- name: Run e2e-test
run: yarn test:e2e --runInBand
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "e2e: Debug Current Jest File",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--config",
"${workspaceRoot}/jest.e2e.config.js",
"--runInBand",
"${file}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"**/test/**/probes.json": "jsonc"
}
}
6 changes: 3 additions & 3 deletions examples/complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"start": "next start"
},
"dependencies": {
"next": "^9.5.4",
"react": "16.13.1",
"react-dom": "16.13.1"
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@dealmore/terraform-next-build": "^0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"start": "next start"
},
"dependencies": {
"next": "^9.5.4",
"react": "16.13.1",
"react-dom": "16.13.1"
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@dealmore/terraform-next-build": "^0.1.0"
Expand Down
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ module.exports = {
tsConfig: 'tsconfig.test.json',
},
},
// By default we only run tests in the packages subfolders
// For e2e tests see the jest.e2e.config.js file
testMatch: [
'<rootDir>/packages/**/__tests__/**/*.[jt]s?(x)',
'<rootDir>/packages/**/?(*.)+(spec|test).[jt]s?(x)',
],
};
14 changes: 14 additions & 0 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mainConfig = require('./jest.config');

module.exports = {
...mainConfig,
// We only run e2e tests here
// For unit tests see jest.config.js
testMatch: [
'<rootDir>/test/**/__tests__/**/*.[jt]s?(x)',
'<rootDir>/test/**/?(*.)+(spec|test).[jt]s?(x)',
],
// We use an increased timeout here because in the worst case
// AWS SAM needs to download a docker image before the test can run
testTimeout: 60000,
};
1 change: 1 addition & 0 deletions modules/proxy-config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ locals {
resource "aws_s3_bucket" "proxy_config" {
bucket_prefix = "next-tf-proxy-config"
acl = "private"
force_destroy = true
}

data "aws_iam_policy_document" "cf_access" {
Expand Down
1 change: 1 addition & 0 deletions modules/statics-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "aws_s3_bucket_notification" "on_create" {
resource "aws_s3_bucket" "static_deploy" {
bucket_prefix = "next-tf-static-deploy"
acl = "private"
force_destroy = true
}

# CloudFront permissions for the bucket
Expand Down
26 changes: 23 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,37 @@
"license": "Apache-2.0",
"workspaces": [
"packages/*",
"examples/*"
"examples/*",
"test/fixtures/*"
],
"scripts": {
"test": "jest"
"test": "jest",
"test:e2e:prepare": "node test/build-fixtures.js",
"test:e2e": "jest --config jest.e2e.config.js"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.64",
"@types/hjson": "^2.4.2",
"@types/jest": "^26.0.3",
"@types/node": "^12.0.0",
"@types/tmp": "^0.2.0",
"@types/unzipper": "^0.10.3",
"aws-sdk": "*",
"get-port": "^5.1.1",
"hjson": "^3.2.2",
"jest": "^26.1.0",
"node-fetch": "^2.6.1",
"prettier": "^2.0.5",
"tmp": "^0.2.1",
"ts-jest": "^26.1.1",
"typescript": "^3.9.5"
"typescript": "^3.9.5",
"unzipper": "^0.10.11",
"yaml": "^2.0.0-1"
},
"resolutions": {
"aws-sdk": "2.771.0",
"next": "^10.0.3",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/deploy-trigger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/aws-lambda": "^8.10.56",
"@types/mime": "^2.0.2",
"@types/unzipper": "^0.10.3",
"aws-sdk": "2.631.0"
"aws-sdk": "*"
},
"dependencies": {
"mime": "^2.4.6",
Expand Down