Skip to content

Commit

Permalink
(feat) Add build, e2e, pre-release and release jobs (#2)
Browse files Browse the repository at this point in the history
* Add build, e2e, pre-release and release jobs

* Fix the lint check job
  • Loading branch information
vasharma05 authored Jan 2, 2025
1 parent d2c5c5f commit 4d35216
Show file tree
Hide file tree
Showing 6 changed files with 1,295 additions and 149 deletions.
23 changes: 19 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
"env": {
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:jest-dom/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "react-hooks"],
"root": true,
"plugins": ["@typescript-eslint", "import", "jest-dom", "react-hooks", "testing-library"],
"overrides": [
{
"files": ["**/*.test.tsx"],
"extends": ["plugin:testing-library/react"]
},
{
"files": ["e2e/**/*.spec.ts"],
"extends": ["plugin:playwright/recommended"],
"rules": {
"testing-library/prefer-screen-queries": "off"
}
}
],
"rules": {
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
Expand All @@ -22,6 +34,7 @@
"fixStyle": "inline-type-imports"
}
],
"import/no-duplicates": "error",
"prefer-const": "off",
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-unsafe-optional-chaining": "off",
Expand All @@ -33,6 +46,7 @@
"error",
{
"paths": [
// These two rules ensure that we're importing lodash and lodash-es correctly. Not doing so can bloat our bundle size significantly.
{
"name": "lodash",
"message": "Import specific methods from `lodash`. e.g. `import map from 'lodash/map'`"
Expand All @@ -42,6 +56,7 @@
"importNames": ["default"],
"message": "Import specific methods from `lodash-es`. e.g. `import { map } from 'lodash-es'`"
},
// These two rules ensure that we're importing Carbon components and icons from the correct packages (after v10). May be removed in the future.
{
"name": "carbon-components-react",
"message": "Import from `@carbon/react` directly. e.g. `import { Toggle } from '@carbon/react'`"
Expand All @@ -54,4 +69,4 @@
}
]
}
}
}
190 changes: 131 additions & 59 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,175 @@
name: Node.js CI
name: Mekom Solutions CI

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]
release:
types:
- created

env:
ESM_NAME: "@openmrs/esm-template-app"
ESM_NAME: "@mekomsolutions/esm-patient-medical-supply-orders-app"
JS_NAME: "openmrs-esm-patient-medical-supply-orders-app.js"

jobs:
build:
runs-on: ubuntu-latest
env:
TURBO_API: 'http://127.0.0.1:9080'
TURBO_TOKEN: ${{ secrets.TURBO_SERVER_TOKEN }}
TURBO_TEAM: ${{ github.repository_owner }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- run: yarn install --immutable
- run: yarn verify
- run: yarn build
- name: Upload Artifacts
registry-url: "https://registry.npmjs.org"

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Setup local cache server for Turborepo
uses: felixmosh/turborepo-gh-artifacts@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

- name: Run verification
run: yarn verify

- name: Build package
run: yarn turbo build --color --concurrency=5

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist
name: dist-build
path: dist
if-no-files-found: warn
compression-level: 6
overwrite: true

pre_release:
runs-on: ubuntu-latest

needs: build

if: ${{ github.event_name == 'push' }}

steps:
- run: echo "Uncomment the lines below and delete this one."
# - uses: actions/checkout@v4
# - name: Download Artifacts
# uses: actions/download-artifact@v4
# - name: Use Node.js
# uses: actions/setup-node@v4
# with:
# node-version: "18"
# registry-url: "https://registry.npmjs.org"
# - run: yarn install --immutable
# - run: yarn version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}"
# - run: yarn build
# - run: git config user.email "[email protected]" && git config user.name "OpenMRS CI"
# - run: git add . && git commit -m "Prerelease version" --no-verify
# - run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public --tag next
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# - name: Upload Artifacts
# uses: actions/upload-artifact@v4
# with:
# name: dist
# path: |
# dist
- uses: actions/checkout@v4

- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: dist-build
path: dist

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Setup local cache server for Turborepo
uses: felixmosh/turborepo-gh-artifacts@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

- name: Version bump
run: yarn version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}"

- name: Build package
run: yarn turbo build --color --concurrency=5

- name: Configure Git
run: |
git config user.email "[email protected]"
git config user.name "Mekom Solutions CI"
- name: Commit version changes
run: |
git add .
git commit -m "Prerelease version" --no-verify
- name: Publish pre-release
run: |
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}"
yarn npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: Upload Pre-release Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-prerelease
path: dist
if-no-files-found: warn
compression-level: 6
overwrite: true

release:
runs-on: ubuntu-latest

needs: build

if: ${{ github.event_name == 'release' }}

steps:
- uses: actions/checkout@v4
- name: Download Artifacts

- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Use Node.js
with:
name: dist-build
path: dist

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: 'https://registry.npmjs.org'
- run: yarn install --immutable
- run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
registry-url: "https://registry.npmjs.org"

deploy:
runs-on: ubuntu-latest
- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

needs: pre_release
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

if: ${{ github.event_name == 'push' }}
- name: Setup local cache server for Turborepo
uses: felixmosh/turborepo-gh-artifacts@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

steps:
- run: echo "Uncomment the lines below and delete this one."
# - name: Trigger RefApp Build
# uses: fjogeleit/http-request-action@v1
# with:
# url: https://ci.openmrs.org/rest/api/latest/queue/O3-BP
# method: "POST"
# customHeaders: '{ "Authorization": "Bearer ${{ secrets.BAMBOO_TOKEN }}" }'
- name: Publish release
run: |
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}"
yarn npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openmrs/esm-patient-medical-supply-orders-app",
"version": "4.0.0",
"name": "@mekomsolutions/esm-patient-medical-supply-orders-app",
"version": "1.0.0",
"license": "MPL-2.0",
"description": "An OpenMRS seed application for building microfrontends",
"browser": "dist/openmrs-esm-patient-medical-supply-orders-app.js",
Expand All @@ -19,7 +19,7 @@
"coverage": "yarn test --coverage",
"prepare": "husky install",
"postinstall": "husky install",
"extract-translations": "i18next 'src/**/*.component.tsx' --config ./i18next-parser.config.js",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ./i18next-parser.config.js",
"test-e2e": "playwright test"
},
"browserslist": [
Expand Down Expand Up @@ -82,9 +82,12 @@
"dotenv": "^16.0.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-playwright": "^2.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-testing-library": "^7.1.1",
"husky": "^8.0.3",
"i18next": "^23.2.8",
"i18next-parser": "^9.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { OverflowMenuItem } from '@carbon/react';
import { useLaunchWorkspaceRequiringVisit, useOrderBasket, type Order } from '@openmrs/esm-patient-common-lib';
import React from 'react';
import { Layer, OverflowMenu, OverflowMenuItem } from '@carbon/react';
import { useLaunchWorkspaceRequiringVisit, useOrderBasket, type Order } from '@openmrs/esm-patient-common-lib';
import { type MedicalSupplyOrderBasketItem } from '../types';
import { buildMedicalSupplyOrderItem } from '../resources';
import { useTranslation } from 'react-i18next';
import { OverflowMenu } from '@carbon/react';
import { Layer } from '@carbon/react';

interface ModifyMedicalSupplyOrderMenuItemProps {
orderItem: Order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
Grid,
InlineNotification,
Layer,
NumberInput,
SelectSkeleton,
TextArea,
TextInput,
} from '@carbon/react';
Expand All @@ -28,9 +30,6 @@ import styles from './medical-supply-order-form.scss';
import { type Concept, ordersEqual, prepOrderPostData, useQuantityUnits } from '../resources';
import { moduleName } from '../../constants';
import { type MedicalSupplyOrderBasketItem } from '../types';
import { NumberInput } from '@carbon/react';
import { Select } from '@carbon/react';
import { SelectSkeleton } from '@carbon/react';

export interface OrderFormProps extends DefaultPatientWorkspaceProps {
initialOrder: MedicalSupplyOrderBasketItem;
Expand Down
Loading

0 comments on commit 4d35216

Please sign in to comment.