From 7b7ae1c06d448bb5584b3c1bfc20f0f3a2c3ba88 Mon Sep 17 00:00:00 2001 From: Avi Shah Date: Thu, 12 Dec 2024 17:47:12 +0530 Subject: [PATCH] lint & test ci workflow parllelization --- .github/workflows/test.yaml | 90 +++++++++++++++++-- .../approval-status/index.ts | 3 +- .../request-status/index.ts | 3 +- .../upload-app/status/details/index.ts | 3 + package.json | 3 +- 5 files changed, 93 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5f587d885..5fb5a3137 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,16 +5,94 @@ on: types: [opened, reopened] jobs: - test: + setup: + name: Setup & Build Application runs-on: [ubuntu-latest] - concurrency: - group: ${{ github.workflow }}-ci-${{ github.ref }} - cancel-in-progress: true steps: - uses: actions/checkout@v4 - name: Setup Application uses: ./.github/actions/setup-app - - name: Run tests - run: npm test + - name: Build ember app + run: npm run build:test + + - name: Upload built ember app + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + + lint: + name: Run Linting + needs: [setup] + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + + - name: Restore Cached Node Modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Run Linting + run: npm run lint + + test: + name: Run ${{ matrix.tests.type }} + needs: [setup] + runs-on: [ubuntu-latest] + strategy: + fail-fast: false + matrix: + tests: + - type: Unit Tests + commandArgs: --file-path='/irene/tests/unit*.js' --split=3 --parallel=3 --load-balance + - type: Acceptance Tests + commandArgs: --file-path='/irene/tests/acceptance*.js' --split=3 --parallel=3 --load-balance + - type: Integration Tests - Part 1 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=1 --parallel=12 --load-balance + - type: Integration Tests - Part 2 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=2 --parallel=12 --load-balance + - type: Integration Tests - Part 3 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=3 --parallel=12 --load-balance + - type: Integration Tests - Part 4 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=4 --parallel=12 --load-balance + - type: Integration Tests - Part 5 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=5 --parallel=12 --load-balance + - type: Integration Tests - Part 6 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=6 --parallel=12 --load-balance + - type: Integration Tests - Part 7 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=7 --parallel=12 --load-balance + - type: Integration Tests - Part 8 + commandArgs: --file-path='/irene/tests/integration*.js' --split=8 --partition=8 --parallel=12 --load-balance + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist + + - name: Restore Cached Node Modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Run ${{ matrix.tests.type }} + run: | + npm run test:ember -- ${{matrix.tests.commandArgs}} --path=dist --wmmf + + - name: Job Summary + if: always() + run: | + echo "| Module | Total | Passed | Failed | Skipped | Duration (ms) |" >> $GITHUB_STEP_SUMMARY + echo "| --- | --- | --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY + + cat module-metadata-*.json | jq -r '.modules[] | "\(.moduleName | gsub("\\|"; "\\\\|")) | \(.total) | \(.passed) | \(.failed) | \(.skipped) | \(.duration) "' >> $GITHUB_STEP_SUMMARY diff --git a/app/components/organization-namespace/approval-status/index.ts b/app/components/organization-namespace/approval-status/index.ts index 0794e6337..669d509a8 100644 --- a/app/components/organization-namespace/approval-status/index.ts +++ b/app/components/organization-namespace/approval-status/index.ts @@ -10,6 +10,8 @@ import IntlService from 'ember-intl/services/intl'; import MeService from 'irene/services/me'; import OrganizationNamespaceModel from 'irene/models/organization-namespace'; +dayjs.extend(relativeTime); + export interface OrganizationNamespaceApprovalStatusSignature { Args: { namespace: OrganizationNamespaceModel; @@ -59,7 +61,6 @@ export default class OrganizationNamespaceApprovalStatus extends Component { get createdOnDate() { - dayjs.extend(relativeTime); return dayjs(this.args.namespace.createdOn).fromNow(); } } diff --git a/app/components/upload-app/status/details/index.ts b/app/components/upload-app/status/details/index.ts index caf75431e..5a891f317 100644 --- a/app/components/upload-app/status/details/index.ts +++ b/app/components/upload-app/status/details/index.ts @@ -7,12 +7,15 @@ import { addObserver, removeObserver } from '@ember/object/observers'; import { action } from '@ember/object'; import RouterService from '@ember/routing/router-service'; import { helper } from '@ember/component/helper'; +import relativeTime from 'dayjs/plugin/relativeTime'; import { SubmissionModelWithSystemFileData } from '../index'; import ENUMS from 'irene/enums'; import ProjectService from 'irene/services/project'; import UploadAppService from 'irene/services/upload-app'; +dayjs.extend(relativeTime); + interface UploadAppStatusDetailsSignature { Element: HTMLDivElement; Args: { diff --git a/package.json b/package.json index fdf545833..2291b59a6 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "repository": "https://github.com/appknox/irene", "scripts": { "build": "ember build --environment=production", + "build:test": "ember build --environment=test", "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", "lint:css": "stylelint \"**/*.{css,scss}\" --allow-empty-input", "lint:css:fix": "concurrently \"npm:lint:css -- --fix\"", @@ -24,7 +25,7 @@ "startstaging": "cross-env IRENE_API_HOST=https://api.appknox.io ember server", "startprod": "cross-env IRENE_API_HOST=https://api.appknox.com ember server", "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", - "test:ember": "ember exam --split=6 --parallel", + "test:ember": "ember exam", "cypress:open": "cypress open", "cypress:run": "cypress run --browser chrome", "deploy": "ember deploy production --verbose=true --activate=true --show-progress=true",