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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/deploy-luda-editor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: deploy-luda-editor
on:
push:
branches:
- "**__le**"
- "master"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-2
jobs:
deploy-luda-editor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: set BRANCH_NAME, STACK_NAME
run: |
BRANCH_NAME=$(echo ${GITHUB_REF##*/} | tr "[:upper:]" "[:lower:]" | sed -e 's/\//-/g' -e 's/|/-/g')
echo $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
STACK_NAME=$(echo ${GITHUB_REF##*/} | tr "[:upper:]" "[:lower:]" | tr -cd '[:alnum:]')
echo $STACK_NAME
echo "STACK_NAME=$STACK_NAME" >> $GITHUB_ENV

- run: echo ${{ env.BRANCH_NAME }};

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: wasm-pack install
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: rustup wasm32-unknown-unknown
run: rustup target add wasm32-unknown-unknown

- uses: actions/cache@v3
id: namui-cli-rust-cache
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
namui-cli/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('namui-cli/Cargo.lock') }}

- name: Get npm cache directory
id: npm-cache-dir
run: echo "::set-output name=dir::$(npm config get cache)"

- uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: install cargo-lambda
run: pip3 install cargo-lambda

- name: install namui-cli
run: bash namui-cli/scripts/install.sh

- name: build client
working-directory: luda-editor/client
run: namui build wasm-unknown-web

- name: build server as lambda
working-directory: luda-editor/server
run: cargo lambda build --release --target x86_64-unknown-linux-gnu --output-format zip

- name: npm install in cdk
working-directory: luda-editor/cdk
run: npm ci

- name: bootstrap cdk
working-directory: luda-editor/cdk
run: npx cdk bootstrap

# Github client id and secret is not for production. please put it in github secrets on production branch.
- name: deploy cdk
working-directory: luda-editor/cdk
run: |
CDK_STACK_NAME=${{ env.STACK_NAME }} npx cdk deploy CdkStack --require-approval never \
--parameters lambdaFunctionName=${{ env.BRANCH_NAME }} \
--parameters serveStaticS3Bucket=luda-editor \
--parameters serveStaticS3KeyPrefix=${{ env.BRANCH_NAME }}/www \
--parameters githubClientId=abd04a6aeba3e99f5b4b \
--parameters githubClientSecret=501a915ca627e24d2088cf01416fe836db470dba \
--parameters s3BucketName=luda-editor \
--parameters s3KeyPrefix=${{ env.BRANCH_NAME }}

- name: inject client setting
working-directory: luda-editor/client
run: |
ENDPOINT=$(aws cloudformation describe-stacks \
--stack-name ${{ env.STACK_NAME }} \
--query "Stacks[0].Outputs[?OutputKey=='FunctionUrl'].OutputValue" \
--output text)
JSON=$(cat << EOF
{
"endpoint": "$ENDPOINT"
}
EOF
)
echo $JSON > target/namui/wasm_unknown_web/bundle/setting.json

- name: deploy client to s3
working-directory: luda-editor/client
run: aws s3 cp target/namui/wasm_unknown_web s3://luda-editor/${{ env.BRANCH_NAME }}/www --recursive
33 changes: 8 additions & 25 deletions .github/workflows/namui-test-host-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
namui-test-host: ${{ steps.filter.outputs.namui-test-host }}
namui-cli: ${{ steps.filter.outputs.namui-cli }}
namui: ${{ steps.filter.outputs.namui }}
luda-editor-client: ${{ steps.filter.outputs.luda-editor-client }}
luda-editor: ${{ steps.filter.outputs.luda-editor }}
namui-prebuilt: ${{ steps.filter.outputs.namui-prebuilt }}
nrpc: ${{ steps.filter.outputs.nrpc }}
namui-sample: ${{ steps.filter.outputs.namui-sample }}
image-cropper: ${{ steps.filter.outputs.image-cropper }}
namui-animation-editor: ${{ steps.filter.outputs.namui-animation-editor }}
Expand All @@ -38,20 +37,16 @@ jobs:
- namui-cli/**
- namui/**
- docker-images/namui-test-host/linux.Dockerfile
luda-editor-client:
luda-editor:
- .github/**
- luda-editor/luda-editor/**
- luda-editor/**
- namui/**
- docker-images/namui-test-host/linux.Dockerfile
namui-prebuilt:
- .github/**
- namui/**
- namui-prebuilt/**
- docker-images/namui-test-host/linux.Dockerfile
nrpc:
- .github/**
- nrpc/**
- docker-images/namui-test-host/linux.Dockerfile
namui-sample:
- .github/**
- namui/**
Expand Down Expand Up @@ -109,18 +104,16 @@ jobs:
target: wasm-unknown-web
path: namui

test-luda-editor-client:
test-luda-editor:
needs: [check-rebuild, set-up]
if: needs.check-rebuild.outputs.luda-editor-client == 'true'
if: needs.check-rebuild.outputs.luda-editor == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/init-test-job
- run: cargo test --manifest-path luda-editor/crdt/Cargo.toml
- uses: ./.github/actions/namui-test
with:
target: wasm-unknown-web
path: luda-editor/core
- run: cargo test --manifest-path luda-editor/rpc/Cargo.toml
- run: cargo test --manifest-path luda-editor/server/Cargo.toml
- uses: ./.github/actions/namui-test
with:
target: wasm-unknown-web
Expand All @@ -138,15 +131,6 @@ jobs:
target: wasm-unknown-web
path: namui-prebuilt

test-nrpc:
needs: [check-rebuild, set-up]
if: needs.check-rebuild.outputs.nrpc == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/init-test-job
- run: cargo test --manifest-path nrpc/Cargo.toml

test-namui-sample:
needs: [check-rebuild, set-up]
if: needs.check-rebuild.outputs.namui-sample == 'true'
Expand Down Expand Up @@ -203,9 +187,8 @@ jobs:
# PLEASE ADD ALL TEST HERE!
- test-namui-cli
- test-namui
- test-luda-editor-client
- test-luda-editor
- test-namui-prebuilt
- test-nrpc
- test-namui-sample
- test-image-cropper
- test-namui-animation-editor
Expand Down
8 changes: 8 additions & 0 deletions luda-editor/cdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions luda-editor/cdk/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
14 changes: 14 additions & 0 deletions luda-editor/cdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Welcome to your CDK TypeScript project

This is a blank project for CDK development with TypeScript.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

## Useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
* `cdk deploy` deploy this stack to your default AWS account/region
* `cdk diff` compare deployed stack with current state
* `cdk synth` emits the synthesized CloudFormation template
19 changes: 19 additions & 0 deletions luda-editor/cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import "source-map-support/register";
import * as cdk from "aws-cdk-lib";
import { CdkStack } from "../lib/cdk-stack";

const app = new cdk.App();
new CdkStack(app, "CdkStack", {
stackName: process.env.CDK_STACK_NAME,
/* If you don't specify 'env', this stack will be environment-agnostic.
* Account/Region-dependent features and context lookups will not work,
* but a single synthesized template can be deployed anywhere. */
/* Uncomment the next line to specialize this stack for the AWS Account
* and Region that are implied by the current CLI configuration. */
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
/* Uncomment the next line if you know exactly what Account and Region you
* want to deploy the stack to. */
// env: { account: '123456789012', region: 'us-east-1' },
/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */
});
42 changes: 42 additions & 0 deletions luda-editor/cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"app": "npx ts-node --prefer-ts-exts bin/cdk.ts",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:stackRelativeExports": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
]
}
}
8 changes: 8 additions & 0 deletions luda-editor/cdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
}
};
Loading