Skip to content

Commit

Permalink
refactor: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samarmeena committed Jun 6, 2024
1 parent c672575 commit 89b7fa1
Show file tree
Hide file tree
Showing 9 changed files with 4,546 additions and 149 deletions.
69 changes: 21 additions & 48 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,61 +1,34 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:prettier/recommended"
],
"ignorePatterns": ["**/*.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"project": true,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
// "typescript-sort-keys",
"import",
"simple-import-sort",
"import"
"typescript-sort-keys"
],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": ["**/*.js"],
"root": true,
"rules": {
// simple-import-sort
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
// import
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",

// simple-import-sort
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
// typescript-sort-keys
// "typescript-sort-keys/interface": "error",
// "typescript-sort-keys/string-enum": "error",

// common
"no-return-await": "error",
"no-unreachable-loop": "error",
"no-promise-executor-return": "error",
"no-unsafe-optional-chaining": "error",
"no-useless-backreference": "error",
"require-atomic-updates": "error",
"require-await": "error",
"no-await-in-loop": "error",
"spaced-comment": "error",
"sort-imports": "off",
"sort-keys": "error",
"no-unused-vars": "off", // typescript-eslint suggestion: off
"curly": "error",
"camelcase": "error",

// TypeScript
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/semi": "error",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true }],
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/ban-types": "error"
"typescript-sort-keys/interface": "error",
"typescript-sort-keys/string-enum": "error"
}
}
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check out code 🛎
uses: actions/checkout@v4
uses: actions/checkout@main

- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@main
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "npm"
node-version: "lts/*"

- name: Install dependencies
run: npm install
run: npm ci

- name: Run ESLint
run: npm run check:lint
run: npm run lint

- name: Run Prettier
run: npm run check:prettier
run: npm run prettier

- name: Run Build
run: npm run build
38 changes: 5 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
image_uri: ${{ steps.tag.outputs.current }}
steps:
- name: check out code 🛎
uses: actions/checkout@v4
uses: actions/checkout@main

- name: check out buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@master
id: buildx
with:
install: true
Expand All @@ -35,7 +35,7 @@ jobs:
echo "latest=${{ env.ECR_REGISTRY }}:latest" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@main
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -44,10 +44,10 @@ jobs:

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@main

- name: Build and Push
uses: docker/build-push-action@v3
uses: docker/build-push-action@master
with:
push: true
tags: ${{ steps.tag.outputs.current }}, ${{ steps.tag.outputs.latest }}
Expand All @@ -57,14 +57,6 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- 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: ap-south-1
mask-aws-account-id: "no"

- name: deploy to cluster
uses: kodermax/kubectl-aws-eks@master
env:
Expand All @@ -78,23 +70,3 @@ jobs:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
with:
args: rollout status deployment/${{ env.KUBE_DEPLOYMENT_NAME }} -n ${{ env.KUBE_NAMESPACE }}

alert:
name: Alert
if: ${{ always() }}
needs: [build, deploy]
runs-on: ubuntu-latest
steps:
- name: Successful
if: ${{ needs.build.result == 'success' && needs.deploy.result == 'success' }}
run: |
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"\`${{ needs.build.outputs.image_uri }}\` [deployed](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) successfully :tada:\"}" $DISCORD_WEBHOOK &> /dev/null
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}

- name: Failed
if: ${{ needs.build.result != 'success' || needs.deploy.result != 'success' }}
run: |
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"\`${{ needs.build.outputs.image_uri }}\` [deployment](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) failed :x:\"}" $DISCORD_WEBHOOK &> /dev/null
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# files
.vscode
.env
.env.local
package-lock.json
yarn.lock

# folders
.vscode/settings.json
build
node_modules
Loading

0 comments on commit 89b7fa1

Please sign in to comment.