From 5e3f5f88d53f72546cba339b390b6ec56e3403eb Mon Sep 17 00:00:00 2001 From: Nik <2661899+CodeSchwert@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:05:48 +1200 Subject: [PATCH] refactor: SDK workflow builds (#1938) --- .../workflows/build-lint-typecheck-test.yaml | 149 +++++++++++++++--- .github/workflows/build-sdk.yaml | 41 +++++ 2 files changed, 167 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/build-sdk.yaml diff --git a/.github/workflows/build-lint-typecheck-test.yaml b/.github/workflows/build-lint-typecheck-test.yaml index 2a548b29c8..a9fa1556b4 100644 --- a/.github/workflows/build-lint-typecheck-test.yaml +++ b/.github/workflows/build-lint-typecheck-test.yaml @@ -16,51 +16,138 @@ jobs: NODE_OPTIONS: --max-old-space-size=14366 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: lts/* + node-version-file: ".nvmrc" registry-url: https://registry.npmjs.org/ cache: "yarn" - name: Install dependencies run: yarn install --immutable + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + - name: Check Single Package Version Policy run: yarn syncpack:check - name: Build run: yarn build - - name: Typecheck - run: yarn typecheck + - name: Cache build artifacts + uses: actions/cache@v4 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-${{ github.sha }} + + build-passport: + name: Build Passport Sample App + runs-on: ubuntu-latest-4-cores + needs: build + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + registry-url: https://registry.npmjs.org/ + cache: "yarn" + + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- + + - name: Restore cached build artifacts + uses: actions/cache@v4 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-${{ github.sha }} + restore-keys: ${{ runner.os }}-build- - name: Build passport sample app run: yarn workspace @imtbl/passport-sdk-sample-app build + + typecheck: + name: Typecheck + runs-on: ubuntu-latest-4-cores + needs: build + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + registry-url: https://registry.npmjs.org/ + cache: "yarn" + + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- + + - name: Restore cached build artifacts + uses: actions/cache@v4 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-${{ github.sha }} + restore-keys: ${{ runner.os }}-build- + + - name: Typecheck + run: yarn typecheck test: name: Test runs-on: ubuntu-latest-8-cores + needs: build env: NODE_OPTIONS: --max-old-space-size=14366 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: .nvmrc registry-url: https://registry.npmjs.org/ cache: "yarn" - - name: Install dependencies - run: yarn install --immutable + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- - - name: Build - run: yarn build + - name: Restore cached build artifacts + uses: actions/cache@v4 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-${{ github.sha }} + restore-keys: ${{ runner.os }}-build- - name: Test run: yarn test @@ -83,29 +170,40 @@ jobs: cypress: name: Cypress runs-on: ubuntu-latest-4-cores + needs: build env: NODE_OPTIONS: --max-old-space-size=14366 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: lts/* + node-version-file: ".nvmrc" registry-url: https://registry.npmjs.org/ cache: "yarn" - - name: Install dependencies - run: yarn install --immutable + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- - name: Get reviewing teams id: reviewer-teams run: echo "teams=${{ join(github.event.pull_request.requested_teams.*.name, ', ') }}" >> $GITHUB_OUTPUT - - name: Build + - name: Restore cached build artifacts if: ${{ contains(steps.reviewer-teams.outputs.teams, 'Wallets') && !contains(github.event.pull_request.title, 'SKIP-CY') }} - run: yarn build + uses: actions/cache@v4 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-${{ github.sha }} + restore-keys: ${{ runner.os }}-build- - name: Checkout-widgets cypress tests if: ${{ contains(steps.reviewer-teams.outputs.teams, 'Wallets') && !contains(github.event.pull_request.title, 'SKIP-CY') }} @@ -129,19 +227,24 @@ jobs: lint: name: Lint runs-on: ubuntu-latest-4-cores + needs: build steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: lts/* + node-version-file: ".nvmrc" registry-url: https://registry.npmjs.org/ cache: "yarn" - - name: Install dependencies - run: yarn install --immutable + - name: Restore cached node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-node-modules- - name: Lint run: yarn lint diff --git a/.github/workflows/build-sdk.yaml b/.github/workflows/build-sdk.yaml new file mode 100644 index 0000000000..c555d9fddf --- /dev/null +++ b/.github/workflows/build-sdk.yaml @@ -0,0 +1,41 @@ +name: Build and Cache SDK + +on: + pull_request: + merge_group: + +jobs: + build-cache-sdk: + name: Build and Cache SDK + runs-on: ubuntu-latest-4-cores + env: + NODE_OPTIONS: --max-old-space-size=14366 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Cache build artifacts + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-build-cache-deps-${{ hashFiles('yarn.lock') }} + + - name: Build + run: yarn build + + - name: Cache build artifacts + uses: actions/cache@v2 + with: + path: | + ./sdk + ./packages + key: ${{ runner.os }}-build-cache-${{ github.sha }}