Skip to content

Commit

Permalink
feat: migrate to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Feb 22, 2024
1 parent 3acebfd commit 283e211
Show file tree
Hide file tree
Showing 17 changed files with 7,268 additions and 4,381 deletions.
83 changes: 7 additions & 76 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,80 +1,11 @@
module.exports = {
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"tsconfig.json",
"tsconfig.test.json"
extends: './node_modules/@restorecommerce/dev/.eslintrc.cjs',
parserOptions: {
project: [
'tsconfig.json',
],
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/eslint-plugin",
"prefer-arrow-functions"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "class",
"format": ["PascalCase"]
},
{
"selector": "interface",
"format": ["PascalCase"]
}
],
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-use-before-define": [2, {"functions": true, "classes": true}],
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/type-annotation-spacing": "error",
"arrow-parens": [
"off",
"as-needed"
],
"capitalized-comments": 0,
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"no-trailing-spaces": "error",
"no-var": "error",
"object-shorthand": "error",
"prefer-arrow-functions/prefer-arrow-functions": [
"warn",
{
"classPropertiesAllowed": false,
"disallowPrototype": false,
"returnStyle": "unchanged",
"singleReturnOnly": false
}
],
"prefer-arrow-callback": "error",
"quote-props": [
"error",
"as-needed"
],
"spaced-comment": "error"
rules: {
'@typescript-eslint/consistent-type-imports': 0
}
};
};
42 changes: 15 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ on: push

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '20.8.0'
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm ci
Expand All @@ -21,54 +19,44 @@ jobs:
run: npm run build

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '20.8.0'
node-version-file: '.nvmrc'

- name: Setup System
uses: restorecommerce/setup-system-action@v1
- uses: restorecommerce/setup-system-action@v1

- name: Install Dependencies
run: npm ci

- name: Test
run: npm run test
run: npm run test && npm run lcov-report

- name: Coveralls
uses: coverallsapp/github-action@master
- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

image:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup buildx
uses: docker/setup-buildx-action@v1
- uses: docker/setup-buildx-action@v3

- name: Set variables
id: vars
run: |
echo ::set-output name=version_tag::$(echo ${GITHUB_REF#refs/*/})
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Build
uses: docker/build-push-action@v2
- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
build-args: |
APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }}
cache-from: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: pr-lint
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 32 additions & 30 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: release
name: Release

on:
push:
tags:
- v*
branches:
- master

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-20.04
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v1
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- uses: docker/setup-buildx-action@v1
- uses: docker/setup-buildx-action@v3
with:
install: true

Expand All @@ -34,28 +38,26 @@ jobs:
run: |
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Docker meta
- uses: docker/metadata-action@v5
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tag-sha: true
tag-semver: |
{{version}}
{{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v2
images: ${{ github.repository }}

- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
load: true
build-args: |
APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }}
cache-from: |
${{ github.repository }}:latest
tags: ${{ steps.docker_meta.outputs.tags }}
tags: ${{ github.repository }}
labels: ${{ steps.docker_meta.outputs.labels }}

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm clean-install

- run: npx [email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extension": [
"ts"
],
"spec": "test/**/*.spec.ts",
"require": "ts-node/register",
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.8
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing Guidelines

## Commit Messages

This repository uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [commitlint](https://commitlint.js.org)
to standardize the commit messages.

## Development Flow

This repository follows a gitflow-style development.

The `main`/`master` branch is locked, and only allows pull requests.
Any change in the `main`/`master` branch gets automatically released via [semantic-release](https://github.com/semantic-release/semantic-release).

The `next` branch gets merged into `main`/`master` on an unscheduled basis.

Any change to the repository requires a new branch from the `next` branch, which then gets merged back into it with a pull request.

The pull request title must follow the same rules as commit messages and it gets linted.

The following diagram visualizes the development flow:

![development flow](./.github/development-flow.png)
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
### Base
FROM node:20.8.0-alpine3.18 as base
### Build
FROM node:20.8.0-alpine3.18 as build
ENV NO_UPDATE_NOTIFIER=true

RUN apk add --no-cache git
RUN apk add g++ make python3

USER node
ARG APP_HOME=/home/node/srv
WORKDIR $APP_HOME

COPY package.json package.json
COPY package-lock.json package-lock.json


### Build
FROM base as build

RUN npm ci

COPY --chown=node:node . .
Expand All @@ -24,9 +17,16 @@ RUN npm run build


### Deployment
FROM base as deployment
FROM node:20.8.0-alpine3.18 as deployment

ENV NO_UPDATE_NOTIFIER=true

RUN npm ci --only=production
USER node
ARG APP_HOME=/home/node/srv
WORKDIR $APP_HOME

COPY package.json package.json
COPY package-lock.json package-lock.json

COPY --chown=node:node . $APP_HOME
COPY --chown=node:node --from=build $APP_HOME/lib $APP_HOME/lib
Expand Down
4 changes: 4 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Please consult the documentation for using it:
- *link:https://docs.restorecommerce.io/architecture/index.html[Restorecommerce Architecture]*
Part of link:https://github.com/restorecommerce[Restorecommerce].

== Contributing

Read more in link:{docdir}/CONTRIBUTING.md[CONTRIBUTING.md]
Loading

0 comments on commit 283e211

Please sign in to comment.