Skip to content

Commit

Permalink
Restructure, add service generators, use AWS SAM and GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Maoragai12 committed Jan 18, 2023
1 parent 62b6177 commit 4084048
Show file tree
Hide file tree
Showing 64 changed files with 23,733 additions and 104 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{json,xml,yml,yaml}]
indent_size = 2
123 changes: 123 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
env:
node: true
root: true
parser: "@typescript-eslint/parser"
plugins:
- "@typescript-eslint"
- unused-imports
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
rules:
array-bracket-spacing:
- error
- always
arrow-spacing: error
camelcase: error
comma-dangle:
- error
- always-multiline
curly: error
eol-last: error
eqeqeq: error
func-call-spacing: error
indent:
- error
- 4
- SwitchCase: 1
max-depth:
- error
- 3
max-len:
- error
- code: 120
max-statements-per-line:
- error
- max: 1
newline-per-chained-call:
- error
- ignoreChainWithDepth: 2
no-duplicate-imports: error
no-multi-assign: error
no-multiple-empty-lines:
- error
- max: 1
maxEOF: 0
no-nested-ternary: error
no-trailing-spaces: error
no-unneeded-ternary: error
no-useless-constructor: error
no-var: error
prefer-const: error
semi: error
space-before-blocks: error
object-curly-spacing:
- error
- always
quotes:
- error
- single
- avoid-escape
brace-style: error
keyword-spacing: error
no-whitespace-before-property: error
space-before-function-paren:
- error
- named: never
anonymous: never
asyncArrow: always
spaced-comment:
- error
- always
no-return-await: error
quote-props:
- error
- as-needed
max-lines-per-function:
- error
- max: 30
skipBlankLines: true
no-restricted-syntax:
- error
- selector: TryStatement > BlockStatement[body.length=1] AwaitExpression
message: No try block for one line! Use then-catch instead.
padding-line-between-statements:
- error
- blankLine: always
prev: "*"
next: return
- blankLine: always
prev: directive
next: "*"
- blankLine: any
prev: directive
next: directive
- blankLine: always
prev: import
next: "*"
- blankLine: any
prev: import
next: import
- blankLine: never
prev: "*"
next: throw
key-spacing:
- error
- afterColon: true
comma-spacing:
- error
- before: false
after: true
no-unused-vars: 'off'
unused-imports/no-unused-imports: error
unused-imports/no-unused-vars:
- warn
- vars: all
varsIgnorePattern: "^_"
args: after-used
argsIgnorePattern: "^_"
overrides:
- files: jest.preset.js
rules:
"@typescript-eslint/no-var-requires": "off"
152 changes: 152 additions & 0 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Deploy Dev
on:
push:
branches:
- dev

env:
SAM_CLI_TELEMETRY: 0

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
run-timestamp: ${{ steps.run-timestamp.outputs.timestamp }}

steps:
- name: Pull the full git history
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate a timestamp for this run
id: run-timestamp
run: echo ::set-output name=timestamp::$(date +'%s%N')
shell: bash

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true

- name: Install node modules
run: npm ci

- name: Run code analysis
run: npm run affected:lint -- --base=refs/remotes/origin/dev~1 --head=refs/remotes/origin/dev

test:
name: Test
needs:
- lint
runs-on: ubuntu-latest
timeout-minutes: 2

steps:
- name: Pull the full git history
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true

- name: Install node modules
run: npm ci

- name: Run tests
run: npm run affected:test -- --base=refs/remotes/origin/dev~1 --head=refs/remotes/origin/dev

build:
name: Build
needs:
- lint
- test
runs-on: ubuntu-latest
timeout-minutes: 2

steps:
- name: Pull the full git history
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true

- name: Install node modules
run: npm ci

- name: Install AWS SAM
uses: aws-actions/setup-sam@v1

- name: Build Lambda artifacts
shell: bash
run: npm run affected:build -- --base=refs/remotes/origin/dev~1 --head=refs/remotes/origin/dev --args='--EnvType=dev'

- name: Cache the build directory
uses: actions/cache@v2
with:
path: ./.aws-sam/*
key: ${{ github.sha }}-build-${{ needs.config.outputs.run-timestamp }}

deploy:
name: Deploy
needs:
- lint
- test
- build
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Pull the full git history
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true

- name: Install dependencies
run: npm ci

- name: Install AWS SAM
uses: aws-actions/setup-sam@v1

- name: Restore the build directory from cache
uses: actions/cache@v2
with:
path: ./.aws-sam/*
key: ${{ github.sha }}-build-${{ needs.config.outputs.run-timestamp }}

- name: Deploy the build artifacts
shell: bash
run: npm run affected:deploy -- --base=refs/remotes/origin/dev~1 --head=refs/remotes/origin/dev --args='--EnvType=dev'
Loading

0 comments on commit 4084048

Please sign in to comment.