diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000000..84625a95da --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,39 @@ +name: 'Setup Environment and Resources' +description: 'Setup environment, resources and caching' + +outputs: + cache-dependencies-hit: + description: "Use dependencies cache" + value: ${{ steps.cache-npm.outputs.cache-hit }} + cache-build-hit: + description: "Use build output scripts cache" + value: ${{ steps.cache-build.outputs.cache-hit }} + +runs: + using: "composite" + steps: + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 15.x + + - name: Setup caching dependencies + uses: actions/cache@v2 + id: cache-npm + with: + path: | + node_modules + */*/node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + + - name: Setup caching build + uses: actions/cache@v2 + id: cache-build + with: + path: | + packages/*/lib + packages/*-theme/**/*.js + packages/*-theme/**/*.css + key: ${{ runner.os }}-build-${{ github.sha }} + restore-keys: ${{ runner.os }}-build-${{ github.sha }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 45c991acb7..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Lint -on: - pull_request: - branches: [develop] -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v2 - with: - # Number of commits to fetch. 0 indicates all history for all branches and tags. - # Pulls all commits (needed for Lerna) - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 15.x - cache: 'npm' - - - name: Dependencies Installation - # Installing package dependencies strictly based on lock file - run: npm ci --ignore-scripts --audit=false --fund=false - - - name: Build - # Builds only changed packages including its dependencies - run: lerna run build --include-dependencies --since origin/develop...HEAD - - - name: Lint - run: lerna run lint --include-dependents --since origin/develop...HEAD diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 581aab773a..35f1a133f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,11 +27,9 @@ jobs: git config --global user.name "refinitiv-ui-dev" - name: Dependencies Installation - # Installing package dependencies strictly based on lock file run: npm ci --ignore-scripts --audit=false --fund=false - - name: Build - # Builds only changed packages including its dependencies + - name: Production build run: lerna run build:prod --include-dependencies --since - name: Bump version and create GitHub release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f905b28f7..0222ecaec5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: pull_request: branches: [develop] jobs: - test-ubuntu: + build: runs-on: ubuntu-latest steps: - name: Check out repository code @@ -13,19 +13,60 @@ jobs: # Pulls all commits (needed for Lerna) fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 15.x - cache: 'npm' + - name: Setup resources and environment + uses: ./.github/actions/setup + id: setup - - name: Dependencies Installtion - # Installing package dependencies strictly based on lock file + - name: Install Dependencies + if: steps.setup.outputs.cache-dependencies-hit != 'true' run: npm ci --ignore-scripts --audit=false --fund=false - name: Build - # Builds only changed packages including its dependencies + if: steps.setup.outputs.cache-build-hit != 'true' run: lerna run build --include-dependencies --since origin/develop...HEAD + lint: + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup resources and environment + uses: ./.github/actions/setup + + - name: Lint + run: lerna run lint --include-dependents --since origin/develop...HEAD + + chrome: + needs: lint + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup resources and environment + uses: ./.github/actions/setup + + - name: Test + run: lerna run test --include-dependents --since origin/develop...HEAD -- -- --browsers chrome + + firefox: + needs: lint + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup resources and environment + uses: ./.github/actions/setup + - name: Test - run: lerna run test --include-dependents --since origin/develop...HEAD + # TODO: `@refinitiv/core` has test coverage below threshold on Firefox + run: lerna run test --include-dependents --since origin/develop...HEAD -- -- --browsers firefox --includeCoverage false diff --git a/packages/core/package.json b/packages/core/package.json index 1cda131d69..f2fa946644 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -42,6 +42,7 @@ "license": "Apache-2.0", "scripts": { "build": "tsc --sourceMap --declarationMap", + "build:watch": "npm run build -- --watch --preserveWatchOutput", "build:prod": "tsc", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/i18n/package.json b/packages/i18n/package.json index d66c442d12..83cd268be1 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -12,6 +12,7 @@ }, "scripts": { "build": "tsc --sourceMap --declarationMap", + "build:watch": "npm run build -- --watch --preserveWatchOutput", "build:prod": "tsc", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/phrasebook/package.json b/packages/phrasebook/package.json index 9ea7ec75f7..05cb4f0113 100644 --- a/packages/phrasebook/package.json +++ b/packages/phrasebook/package.json @@ -117,6 +117,7 @@ }, "scripts": { "build": "tsc --sourceMap --declarationMap", + "build:watch": "npm run build -- --watch --preserveWatchOutput", "build:prod": "tsc", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/test-helpers/package.json b/packages/test-helpers/package.json index 1c9a21a03a..f201fe9feb 100644 --- a/packages/test-helpers/package.json +++ b/packages/test-helpers/package.json @@ -14,6 +14,7 @@ "license": "Apache-2.0", "scripts": { "build": "tsc --sourceMap --declarationMap", + "build:watch": "npm run build -- --watch --preserveWatchOutput", "build:prod": "tsc", "lint": "eslint .", "lint:fix": "eslint . --fix",