Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
branches: [master]

jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 14.x
registry-url: https://registry.npmjs.org

- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: npm-v14-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }}
restore-keys: npm-v14-${{ runner.os }}-refs/heads/master-

- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Releasing
run: |
npm run release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: slsplus
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: slsplus
GIT_COMMITTER_EMAIL: [email protected]
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test

on:
pull_request:
branches: [master]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Ensure connection with 'master' branch
fetch-depth: 2

- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 14.x
registry-url: https://registry.npmjs.org

- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v14-${{ runner.os }}-${{ github.ref }}-
npm-v14-${{ runner.os }}-refs/heads/master-

- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Upgrade pip
run: |
pip3 install --upgrade pip
pip3 -V
- name: Running tests
run: |
npm run test
env:
SERVERLESS_PLATFORM_VENDOR: tencent
GLOBAL_ACCELERATOR_NA: true
TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}
45 changes: 45 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Validate

on:
pull_request:
branches: [master]

jobs:
lintAndFormatting:
name: Lint & Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Ensure connection with 'master' branch
fetch-depth: 2

- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 14.x
registry-url: https://registry.npmjs.org

- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v14-${{ runner.os }}-${{ github.ref }}-
npm-v14-${{ runner.os }}-refs/heads/master-

- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save

- name: Validate Formatting
run: npm run prettier:fix
- name: Validate Lint rules
run: npm run lint:fix
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

34 changes: 22 additions & 12 deletions tests/integration.test.js → __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
const { generateId, getServerlessSdk } = require('./utils')
const { join } = require('path')
const { generateId, getServerlessSdk } = require('./lib/utils')
const path = require('path')
const execSync = require('child_process').execSync

// set enough timeout for deployment to finish
jest.setTimeout(300000)
const srcPath = path.join(__dirname, '..', 'example')

// the yaml file we're testing against
const instanceYaml = {
org: 'orgDemo',
app: 'appDemo',
component: 'django',
component: 'django@dev',
name: `django-integration-tests-${generateId()}`,
stage: 'dev',
inputs: {
djangoProjectName: 'mydjangocomponent',
src: join(__dirname, '..', 'example/src'),
djangoProjectName: 'djangodemo',
src: {
src: srcPath,
exclude: ['.env'],
include: [
{
source: './requirements',
target: '../'
}
]
},
region: 'ap-guangzhou',
apigatewayConf: { environment: 'test' }
}
}

// get credentials from process.env but need to init empty credentials object
const credentials = {
tencent: {}
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 django app', async () => {
const instance = await sdk.deploy(instanceYaml, { tencent: {} })
execSync(`python3 -u -m pip install -r requirements.txt -t ./requirements`, { cwd: srcPath })
const instance = await sdk.deploy(instanceYaml, credentials)
expect(instance).toBeDefined()
expect(instance.instanceName).toEqual(instanceYaml.name)
expect(instance.outputs).toBeDefined()
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
requirements
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
ASGI config for {{ project_name }} project.
ASGI config for djangodemo project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/asgi/
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangodemo.settings')

application = get_asgi_application()
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
"""
Django settings for {{ project_name }} project.
Django settings for djangodemo project.

Generated by 'django-admin startproject' using Django {{ django_version }}.
Generated by 'django-admin startproject' using Django 3.1.3.

For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

import os
from pathlib import Path

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ secret_key }}'
SECRET_KEY = 'tr%ez&(i@2$l#i9u)xv1kxdh#ufk^dm_vjvwa1pqwk&xc*pd*e'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand All @@ -49,12 +49,12 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = '{{ project_name }}.urls'
ROOT_URLCONF = 'djangodemo.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand All @@ -67,22 +67,22 @@
},
]

WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
WSGI_APPLICATION = 'djangodemo.wsgi.application'


# Database
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#databases
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }


# Password validation
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -101,7 +101,7 @@


# Internationalization
# https://docs.djangoproject.com/en/{{ docs_version }}/topics/i18n/
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -115,6 +115,6 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""{{ project_name }} URL Configuration
"""djangodemo URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/{{ docs_version }}/topics/http/urls/
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand All @@ -15,7 +15,10 @@
"""
from django.contrib import admin
from django.urls import path
from djangodemo.views import index


urlpatterns = [
path('', index),
path('admin/', admin.site.urls),
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# Create your views here.

def index(request):
print(request)
return HttpResponse("Django Application Created By Serverless Component")
return render(request, 'index.html', context={'hello': 'world'})

def author(request):
print(request)
Expand Down
Loading