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

fix: update remove flow #18

Merged
merged 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: slsplus
GIT_AUTHOR_EMAIL: yuga.sun.bj@gmail.com
GIT_AUTHOR_EMAIL: slsplus.sz@gmail.com
GIT_COMMITTER_NAME: slsplus
GIT_COMMITTER_EMAIL: yuga.sun.bj@gmail.com
GIT_COMMITTER_EMAIL: slsplus.sz@gmail.com
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Running integration tests
- name: Running tests
run: npm run test
env:
SERVERLESS_PLATFORM_VENDOR: tencent
Expand Down
14 changes: 2 additions & 12 deletions tests/integration.test.js → __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '..', '.env.test')
})
const { generateId, getServerlessSdk } = require('./utils')
const { generateId, getServerlessSdk } = require('./lib/utils')
const axios = require('axios')

// set enough timeout for deployment to finish
jest.setTimeout(600000)

// the yaml file we're testing against
const instanceYaml = {
org: 'orgDemo',
app: 'appDemo',
component: 'nextjs',
component: 'nextjs@dev',
name: `nextjs-integration-tests-${generateId()}`,
stage: 'dev',
inputs: {
Expand All @@ -22,15 +14,13 @@ const instanceYaml = {
}
}

// get credentials from process.env but need to init empty credentials object
const credentials = {
tencent: {
SecretId: process.env.TENCENT_SECRET_ID,
SecretKey: process.env.TENCENT_SECRET_KEY,
}
}

// get serverless construct sdk
const sdk = getServerlessSdk(instanceYaml.org)

it('should successfully deploy nextjs app', async () => {
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { join } = require('path')
require('dotenv').config({ path: join(__dirname, '.env.test') })

const config = {
verbose: true,
silent: false,
testTimeout: 600000,
testEnvironment: 'node',
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$',
testPathIgnorePatterns: ['/node_modules/', '/__tests__/lib/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
}

module.exports = config
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"description": "Tencent Cloud Next.js Serverless Component",
"scripts": {
"test": "jest ./tests/integration.test.js --testEnvironment node",
"test": "jest",
"commitlint": "commitlint -f HEAD@{15}",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --fix --ext .js,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion serverless.component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: nextjs
version: 0.1.9
version: 0.1.10
author: 'Tencent Cloud, Inc.'
org: 'Tencent Cloud, Inc.'
description: Deploy a serverless Next.js application onto Tencent SCF and API Gateway.
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"adm-zip": "^0.4.16",
"download": "^8.0.0",
"tencent-component-toolkit": "^1.19.8",
"tencent-component-toolkit": "^1.20.5",
"type": "^2.1.0"
}
}
8 changes: 4 additions & 4 deletions src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,6 @@ class ServerlessComopnent extends Component {
const scf = new Scf(credentials, curRegion)
const apigw = new Apigw(credentials, curRegion)
const handler = async () => {
await scf.remove({
functionName: curState.functionName,
namespace: curState.namespace
})
// if disable apigw, no need to remove
if (state.apigwDisabled !== true) {
await apigw.remove({
Expand All @@ -372,6 +368,10 @@ class ServerlessComopnent extends Component {
customDomains: curState.customDomains
})
}
await scf.remove({
functionName: curState.functionName,
namespace: curState.namespace
})
}
removeHandlers.push(handler())
}
Expand Down