From 7eb00d2eb2799e761e9322be490b1e8d0ceb3353 Mon Sep 17 00:00:00 2001 From: adewar Date: Fri, 31 Jan 2025 10:20:22 -0700 Subject: [PATCH] Update build test to produce different checks for clarity --- .github/workflows/content-sources-actions.yml | 96 +++++++++++++++++-- package.json | 1 + 2 files changed, 90 insertions(+), 7 deletions(-) diff --git a/.github/workflows/content-sources-actions.yml b/.github/workflows/content-sources-actions.yml index d12cb323..3658d926 100644 --- a/.github/workflows/content-sources-actions.yml +++ b/.github/workflows/content-sources-actions.yml @@ -1,4 +1,4 @@ -name: build-unit-tests +name: build-tests on: pull_request: branches: [main, prod-beta, prod-stable] @@ -11,8 +11,9 @@ concurrency: cancel-in-progress: true jobs: - build: + lint: runs-on: ubuntu-latest + name: lint steps: - name: Checkout repository uses: actions/checkout@v3 @@ -36,14 +37,95 @@ jobs: - name: Install Dependencies run: yarn install - - name: Tests - run: yarn test - - name: Lint run: yarn lint - - name: Build - run: yarn build --if-present + format: + runs-on: ubuntu-latest + name: format + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Cache - node_modules + if: always() + uses: actions/cache@v4 + with: + path: | + node_modules + dist + key: ${{ runner.os }}-build-test-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-test- + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Install Dependencies + run: yarn install + + - name: Format code with prettier + run: yarn format:check + + build-check: + runs-on: ubuntu-latest + name: build-check + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Cache - node_modules + if: always() + uses: actions/cache@v4 + with: + path: | + node_modules + dist + key: ${{ runner.os }}-build-test-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-test- + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Install Dependencies + run: yarn install + + - name: Build the application + run: yarn build + + unit-test: + name: unit-test + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Cache - node_modules + if: always() + uses: actions/cache@v4 + with: + path: | + node_modules + dist + key: ${{ runner.os }}-build-test-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-test- + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Install Dependencies + run: yarn install + + - name: Tests + run: yarn test - name: Convert JUnit report to CTRF format run: npx junit-to-ctrf test-results/jest-junit.xml -o test-results/ctrf-report.json diff --git a/package.json b/package.json index 5f19f0c4..9d6090de 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}' --no-error-on-unmatched-pattern", "lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx}' --no-error-on-unmatched-pattern", "format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,md}' --config ./.prettierrc", + "format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx,css,md}' --config ./.prettierrc", "patch:hosts": "fec patch-etc-hosts", "start": "fec dev", "start:stage": "fec dev --clouddotEnv=stage",