From ca2232458629c6d6f9a017374b0d851ec5c50485 Mon Sep 17 00:00:00 2001 From: Michael Dowse Date: Wed, 23 Oct 2024 16:06:59 +0200 Subject: [PATCH] chore: Create new build-repository action - Use shared build-repository action - Update upload/download artifacts to v4 - Simplify unlock-dependencies custom action --- .github/actions/build-package/action.yml | 125 ------------ .github/actions/build-repository/action.yml | 126 ++++++++++++ .github/actions/download-artifact/action.yml | 2 +- .../patch-local-dependencies/action.yml | 18 +- .../actions/patch-local-dependencies/core.js | 18 ++ .../actions/patch-local-dependencies/index.js | 51 +++++ .../patch-local-dependencies/local.mjs | 5 - .../patch-local-dependencies/utils.mjs | 104 ---------- .../actions/unlock-dependencies/action.yml | 10 +- .github/actions/upload-artifact/action.yml | 2 +- .github/workflows/build-lint-test.yml | 17 +- .github/workflows/dry-run.yml | 182 +++++++----------- 12 files changed, 279 insertions(+), 381 deletions(-) delete mode 100644 .github/actions/build-package/action.yml create mode 100644 .github/actions/build-repository/action.yml create mode 100644 .github/actions/patch-local-dependencies/core.js create mode 100644 .github/actions/patch-local-dependencies/index.js delete mode 100644 .github/actions/patch-local-dependencies/local.mjs delete mode 100644 .github/actions/patch-local-dependencies/utils.mjs diff --git a/.github/actions/build-package/action.yml b/.github/actions/build-package/action.yml deleted file mode 100644 index 8f0f11a..0000000 --- a/.github/actions/build-package/action.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: Build dependency package locally -description: Checks out a dependency package locally and updates all references to it -inputs: - package: - description: Name of the package - required: true - download_dependencies: - description: Whether to download dependencies - default: false - skip_build: - description: Whether to skip the build - default: false - skip_tests: - description: Whether to skip the tests - default: false - target_artifact: - description: Name of the artifact that will be uploaded - default: dependencies - artifact_path: - description: Path or pattern for the artifact files that should be uploaded - -runs: - using: composite - steps: - - name: Clone - uses: actions/checkout@v4 - with: - repository: cloudscape-design/${{ inputs.package }} - path: ${{ inputs.package }} - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Download artifacts - if: ${{ inputs.download_dependencies == 'true' }} - uses: actions/download-artifact@v3 - with: - name: dependencies - - - run: cd ${{ inputs.package }} - shell: bash - - - uses: cloudscape-design/actions/.github/actions/patch-local-dependencies@main - with: - path: ${{ github.workspace }}/${{ inputs.package }} - - - name: npm install - shell: bash - run: npm install - working-directory: ${{ inputs.package }} - - name: Build - if: ${{ inputs.skip_build != 'true' }} - shell: bash - run: npm run build - working-directory: ${{ inputs.package }} - - name: Test - if: ${{ inputs.skip_tests != 'true' }} - shell: bash - run: npm test - working-directory: ${{ inputs.package }} - - name: Pack artifacts (lib folder) - if: ${{ inputs.package == 'build-tools' || inputs.package == 'component-toolkit' || inputs.package == 'browser-test-tools' || inputs.package == 'documenter' || inputs.package == 'jest-preset' || inputs.package == 'global-styles' || inputs.package == 'collection-hooks' }} - shell: bash - working-directory: ${{ inputs.package }} - run: | - cd lib - npm pack - cp *-${{ inputs.package }}-*.tgz $GITHUB_WORKSPACE/${{ inputs.package }}.tgz - - - name: Pack test-utils artifacts - if: ${{ inputs.package == 'test-utils' }} - shell: bash - working-directory: ${{ inputs.package }} - run: | - cd lib/core - npm pack - cp *-test-utils-core-*.tgz $GITHUB_WORKSPACE - cd ../converter - npm pack - echo $GITHUB_WORKSPACE - cp *-test-utils-converter-*.tgz $GITHUB_WORKSPACE - cd $GITHUB_WORKSPACE - mv *-test-utils-converter-*.tgz test-utils-converter.tgz - mv *-test-utils-core-*.tgz test-utils-core.tgz - - - name: Pack theming-core artifacts - if: ${{ inputs.package == 'theming-core' }} - shell: bash - working-directory: ${{ inputs.package }} - run: | - cd lib/browser - npm pack - cp *-theming-runtime-*.tgz $GITHUB_WORKSPACE - cd ../node - npm pack - echo $GITHUB_WORKSPACE - cp *-theming-build-*.tgz $GITHUB_WORKSPACE - cd $GITHUB_WORKSPACE - mv *-theming-build-*.tgz theming-build.tgz - mv *-theming-runtime-*.tgz theming-runtime.tgz - - - name: Package generic components packages - if: ${{ inputs.package == 'board-components' || inputs.package == 'code-view' || inputs.package == 'chat-components' }} - shell: bash - working-directory: ${{ inputs.package }} - run: | - cd lib/components - npm pack - cp *-${{ inputs.package }}-*.tgz $GITHUB_WORKSPACE/${{ inputs.package }}.tgz - - - name: Package component files - if: ${{ inputs.package == 'components' }} - shell: bash - working-directory: ${{ inputs.package }} - run: | - tar -czf ../components-full.tgz . - tar -czf ../components.tgz --directory=lib/components . - tar -czf ../design-tokens.tgz --directory=lib/design-tokens . - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.target_artifact }} - path: ${{ inputs.artifact_path || format('{0}*.tgz', inputs.package) }} diff --git a/.github/actions/build-repository/action.yml b/.github/actions/build-repository/action.yml new file mode 100644 index 0000000..320e4c5 --- /dev/null +++ b/.github/actions/build-repository/action.yml @@ -0,0 +1,126 @@ +name: Build repository +description: Builds a repository +inputs: + repository: + description: Name of the repository + required: true + skip_lint: + required: false + type: boolean + default: true + skip_tests: + required: false + type: boolean + default: false + cache_working_directory: + required: false + type: boolean + default: false + artifact-path: + type: string + description: An optional file, directory or wildcard pattern that describes what to upload + default: '' + artifact-name: + type: string + description: An optional artifact name. Required when artifact-path is specified + default: '' + +defaults: + run: + shell: bash + +runs: + using: composite + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: ${{ inputs.repository }} + - name: Set-up node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Download dependencies artifacts + id: download-artifacts + uses: actions/download-artifact@v4 + with: + pattern: cloudscape-design-* + path: ./.build-cache + merge-multiple: true + + - name: Patch local dependencies + uses: cloudscape-design/actions/.github/actions/patch-local-dependencies@main + with: + path: ${{ github.workspace }} + + - name: Unlock dependencies + uses: cloudscape-design/actions/.github/actions/unlock-dependencies@main + - name: Install + shell: bash + run: npm install + - name: Build + shell: bash + run: npm run build + - name: Lint + if: ${{ inputs.skip_lint != 'true' }} + shell: bash + run: npm run lint + - name: Test + if: ${{ inputs.skip_tests != 'true' && inputs.repository != 'cloudscape-design/components' }} + shell: bash + run: npm run test + - name: Test:Unit + if: ${{ inputs.skip_tests != 'true' && inputs.repository == 'cloudscape-design/components' }} + shell: bash + run: npm run test:unit + + - name: Cache working directory folder + if: ${{ inputs.cache_working_directory == 'true' }} + uses: actions/cache@v4 + with: + path: ${{ github.workspace }} + key: ${{ inputs.repository }}-${{ github.event.pull_request.head.sha || github.sha }} + + - name: Package lib + shell: bash + run: | + cd ./lib + if [ -f "package.json" ]; then + # If there's a package.json in ./lib, just pack it here + echo "Found package.json in ./lib, running npm pack in ./lib" + npm pack + else + # Otherwise, iterate through subdirectories and pack if package.json exists + echo "No package.json found in ./lib, iterating through subdirectories" + for dir in */; do + if [ -f "$dir/package.json" ]; then + cd "$dir" + npm pack + mv *.tgz ../ + cd .. + else + echo "No package.json in $dir, skipping npm pack" + fi + done + fi + + - name: Sanitize package name + shell: bash + id: sanitize + run: | + SANITIZED_NAME=$(echo "${{ inputs.repository }}" | sed 's/@//g' | sed 's/\//-/g') + echo "sanitized_name=$SANITIZED_NAME" >> $GITHUB_OUTPUT + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.sanitize.outputs.sanitized_name }} + path: lib/*.tgz + + - name: Upload additional artifacts + if: ${{ inputs.artifact-path != '' && inputs.artifact-name != '' }} + uses: cloudscape-design/actions/.github/actions/upload-artifact@main + with: + path: ${{ inputs.artifact-path }} + name: ${{ inputs.artifact-name }} diff --git a/.github/actions/download-artifact/action.yml b/.github/actions/download-artifact/action.yml index 4e65926..412e684 100644 --- a/.github/actions/download-artifact/action.yml +++ b/.github/actions/download-artifact/action.yml @@ -13,7 +13,7 @@ inputs: runs: using: composite steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: ${{ inputs.name }} path: ${{ inputs.path }} diff --git a/.github/actions/patch-local-dependencies/action.yml b/.github/actions/patch-local-dependencies/action.yml index cc87b55..21bae8d 100644 --- a/.github/actions/patch-local-dependencies/action.yml +++ b/.github/actions/patch-local-dependencies/action.yml @@ -4,16 +4,10 @@ inputs: path: description: Root directory of the package that should be updated required: true - type: - description: 'How the dependencies should change. Possible values: "local" (to consume local tarballs), and "next" (to consume from pre-release CodeArtifact)' - default: local - required: false + tarball-dir: + description: Path to the directory containing the local tarballs + required: true + default: './.build-cache' runs: - using: composite - steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: INPUT_PATH=${{ inputs.path }} INPUT_TYPE=${{ inputs.type }} node ${{ github.action_path }}/local.mjs - shell: bash + using: 'node20' + main: 'index.js' diff --git a/.github/actions/patch-local-dependencies/core.js b/.github/actions/patch-local-dependencies/core.js new file mode 100644 index 0000000..ce1f1f9 --- /dev/null +++ b/.github/actions/patch-local-dependencies/core.js @@ -0,0 +1,18 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// Adapted from https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts#L126C1-L138C2 +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '' + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`) + } + + if (options && options.trimWhitespace === false) { + return val + } + + return val.trim() +} + +module.exports = { getInput }; \ No newline at end of file diff --git a/.github/actions/patch-local-dependencies/index.js b/.github/actions/patch-local-dependencies/index.js new file mode 100644 index 0000000..0a7e761 --- /dev/null +++ b/.github/actions/patch-local-dependencies/index.js @@ -0,0 +1,51 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('fs'); +const path = require('path'); + +const core = require('./core'); + +const rootPath = core.getInput('path'); +const tarballDir = core.getInput('tarball-dir'); + +const packageJsonFullPath = path.resolve(path.join(rootPath, 'package.json')); +const tarballDirFullPath = path.resolve(tarballDir); + +if (!fs.existsSync(tarballDirFullPath)) { + console.log('No local tarball directory found. No local dependencies will be loaded.'); + return; +} + +if (!fs.existsSync(packageJsonFullPath)) { + throw new Error(`package.json not found at path: ${packageJsonFullPath}`); +} + +const packageJsonData = JSON.parse(fs.readFileSync(packageJsonFullPath, 'utf8')); +const tarballFiles = fs.readdirSync(tarballDirFullPath).filter(file => file.endsWith('.tgz')); + +const updateCloudscapeDependencies = dependencies => { + if (!dependencies) return {}; + return Object.keys(dependencies).reduce((updatedDeps, key) => { + if (key.startsWith('@cloudscape-design/')) { + const tarball = tarballFiles.find(file => file.replace('cloudscape-design-', '').startsWith(key.replace('@cloudscape-design/', ''))); + if (tarball) { + console.log(`Updating ${key} to tarball file: ${tarball}`); + updatedDeps[key] = `file:${path.join(tarballDirFullPath, tarball)}`; + } else { + console.log(`No tarball found for ${key}, skipping update.`); + updatedDeps[key] = dependencies[key]; + } + } else { + updatedDeps[key] = dependencies[key]; + } + return updatedDeps; + }, {}); +}; + +packageJsonData.dependencies = updateCloudscapeDependencies(packageJsonData.dependencies); +packageJsonData.devDependencies = updateCloudscapeDependencies(packageJsonData.devDependencies); + +fs.writeFileSync(packageJsonFullPath, JSON.stringify(packageJsonData, null, 2)); + +console.log(`Successfully updated @cloudscape-design/* dependencies to point to local tarballs.`); diff --git a/.github/actions/patch-local-dependencies/local.mjs b/.github/actions/patch-local-dependencies/local.mjs deleted file mode 100644 index 99bac7c..0000000 --- a/.github/actions/patch-local-dependencies/local.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import { updatePackageJsons } from './utils.mjs'; - -updatePackageJsons( - packageName => `file:${process.env.GITHUB_WORKSPACE}/${packageName.replace('@cloudscape-design/', '')}.tgz`, -); diff --git a/.github/actions/patch-local-dependencies/utils.mjs b/.github/actions/patch-local-dependencies/utils.mjs deleted file mode 100644 index 5b2668f..0000000 --- a/.github/actions/patch-local-dependencies/utils.mjs +++ /dev/null @@ -1,104 +0,0 @@ -import path from 'path'; -import fs from 'fs'; - -const inputs = { - path: process.env.INPUT_PATH, -}; - -function findPackageFiles(directory) { - const files = []; - - if (!fs.existsSync(directory)) { - return []; - } - - ['package.json', 'package-lock.json'].forEach(fileName => { - const packageJson = path.join(directory, fileName); - if (fs.existsSync(packageJson)) { - files.push(packageJson); - } - }); - - return files; -} - -function findAllPackageJsons() { - const files = []; - - if (!inputs.path || !fs.existsSync(inputs.path)) { - console.error(`Invalid input path: ${inputs.path}`); - process.exit(1); - } - - const mainPackageJsons = findPackageFiles(inputs.path); - if (mainPackageJsons.length) { - files.push(...mainPackageJsons); - } - - const subPackagesPath = path.join(inputs.path, 'packages'); - if (fs.existsSync(subPackagesPath)) { - fs.readdirSync(subPackagesPath).forEach(fileName => { - const filePath = path.join(subPackagesPath, fileName); - if (fs.statSync(filePath).isDirectory()) { - const packageJsons = findPackageFiles(filePath); - if (packageJsons) { - files.push(...packageJsons); - } - } - }); - } - - return files; -} - -function updateDependencyVersions(dependencies, newVersion, sourcePackageName) { - if (!dependencies) { - return; - } - - const updatedDependencies = {}; - - Object.keys(dependencies) - .filter(packageName => packageName.startsWith('@cloudscape-design/')) - .forEach(packageName => { - const isPackageLock = typeof dependencies[packageName] !== 'string'; - const previousVersion = isPackageLock ? dependencies[packageName].version : dependencies[packageName]; - - // Skip local file dependencies - if (previousVersion.startsWith('file:')) { - return; - } - - const nextVersion = typeof newVersion === 'function' ? newVersion(packageName) : newVersion; - - if (isPackageLock) { - updatedDependencies[packageName] = { - ...dependencies[packageName], - version: nextVersion, - }; - - // Remove some additional keys for package-lock.json files - delete updatedDependencies[packageName].resolved; - delete updatedDependencies[packageName].integrity; - } else { - updatedDependencies[packageName] = nextVersion; - } - }); - - return { ...dependencies, ...updatedDependencies }; -} - -export function updatePackageJsons(newVersion) { - const packageJsons = findAllPackageJsons(); - packageJsons.forEach(filePath => { - const packageJson = JSON.parse(fs.readFileSync(filePath)); - const packageName = packageJson.name; - - ['dependencies', 'devDependencies'].forEach(dependencyKey => { - const newDeps = updateDependencyVersions(packageJson[dependencyKey], newVersion, packageName); - packageJson[dependencyKey] = newDeps; - }); - - fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 2)); - }); -} diff --git a/.github/actions/unlock-dependencies/action.yml b/.github/actions/unlock-dependencies/action.yml index 7f10cd5..8f7c9fc 100644 --- a/.github/actions/unlock-dependencies/action.yml +++ b/.github/actions/unlock-dependencies/action.yml @@ -2,11 +2,5 @@ name: Unlock Cloudscape dependencies in package-lock description: Removes all @cloudscape-design dependencies from package-lock file runs: - using: composite - steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: node ${{ github.action_path }}/index.js - shell: bash + using: 'node20' + main: 'index.js' diff --git a/.github/actions/upload-artifact/action.yml b/.github/actions/upload-artifact/action.yml index db9377e..db5270a 100644 --- a/.github/actions/upload-artifact/action.yml +++ b/.github/actions/upload-artifact/action.yml @@ -18,7 +18,7 @@ runs: tar -zcvf ${{ inputs.name }}.tar.gz ${{ inputs.path }} shell: bash - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ inputs.name }} path: ${{ inputs.name }}.tar.gz diff --git a/.github/workflows/build-lint-test.yml b/.github/workflows/build-lint-test.yml index d57b386..6f98fa5 100644 --- a/.github/workflows/build-lint-test.yml +++ b/.github/workflows/build-lint-test.yml @@ -59,21 +59,10 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - - name: Unlock dependencies - uses: cloudscape-design/actions/.github/actions/unlock-dependencies@main - - run: npm install - - run: npm run build - - run: npm run lint - - run: npm run test - if: ${{ github.repository != 'cloudscape-design/components' }} - - run: npm run test:unit - if: ${{ github.repository == 'cloudscape-design/components' }} - - name: Upload Artifacts - if: ${{ inputs.artifact-path != '' }} - uses: cloudscape-design/actions/.github/actions/upload-artifact@main + - name: Build Repository + uses: cloudscape-design/actions/.github/actions/build-repository@main with: - path: ${{ inputs.artifact-path }} - name: ${{ inputs.artifact-name }} + respository: ${{ github.repository }} - name: Codecov if: ${{ inputs.skip-codecov == false && always() }} uses: codecov/codecov-action@v4 diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml index 3ddeb58..18adca4 100644 --- a/.github/workflows/dry-run.yml +++ b/.github/workflows/dry-run.yml @@ -25,53 +25,52 @@ jobs: name: Build build-tools runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: build-tools + repository: cloudscape-design/build-tools buildJestPreset: name: Build jest-preset runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: jest-preset + repository: cloudscape-design/jest-preset buildGlobalStyles: name: Build global-styles runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: global-styles + repository: cloudscape-design/global-styles buildCollectionHooks: name: Build collection-hooks runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: collection-hooks + repository: cloudscape-design/collection-hooks buildBrowserTestTools: name: Build browser-test-tools runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: browser-test-tools + repository: cloudscape-design/browser-test-tools buildDocumenter: name: Build documenter runs-on: ubuntu-latest steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: documenter + repository: cloudscape-design/documenter buildTestUtils: name: Build test-utils runs-on: ubuntu-latest needs: buildDocumenter steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: test-utils - download_dependencies: true + repository: cloudscape-design/test-utils buildThemingCore: name: Build theming-core runs-on: ubuntu-latest @@ -79,21 +78,18 @@ jobs: - buildBrowserTestTools - buildComponentToolkit steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: theming-core - artifact_path: theming-*.tgz - download_dependencies: true + repository: cloudscape-design/theming-core buildComponentToolkit: name: Build component-toolkit runs-on: ubuntu-latest needs: - buildBrowserTestTools steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: component-toolkit - download_dependencies: true + repository: cloudscape-design/component-toolkit buildComponents: name: Build components runs-on: ubuntu-latest @@ -108,13 +104,11 @@ jobs: - buildThemingCore - buildComponentToolkit steps: - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: components - target_artifact: components-package - artifact_path: ./*.tgz + repository: cloudscape-design/components skip_tests: true - download_dependencies: true + cache_working_directory: true buildBoardComponents: name: Build board components @@ -128,20 +122,15 @@ jobs: - buildComponentToolkit - buildComponents steps: - - name: Download component artifacts - uses: actions/download-artifact@v3 + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - name: components-package - - uses: cloudscape-design/actions/.github/actions/build-package@main - with: - package: board-components - download_dependencies: true + repository: cloudscape-design/board-components buildCodeView: name: Build code view components runs-on: ubuntu-latest needs: - - buildBuildTools + - buildBuildTools - buildGlobalStyles - buildBrowserTestTools - buildDocumenter @@ -149,14 +138,9 @@ jobs: - buildComponentToolkit - buildComponents steps: - - name: Download component artifacts - uses: actions/download-artifact@v3 - with: - name: components-package - - uses: cloudscape-design/actions/.github/actions/build-package@main + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: code-view - download_dependencies: true + repository: cloudscape-design/code-view buildChatComponents: name: Build chat components @@ -170,14 +154,9 @@ jobs: - buildComponentToolkit - buildComponents steps: - - name: Download component artifacts - uses: actions/download-artifact@v3 + - uses: cloudscape-design/actions/.github/actions/build-repository@main with: - name: components-package - - uses: cloudscape-design/actions/.github/actions/build-package@main - with: - package: chat-components - download_dependencies: true + repository: cloudscape-design/chat-components unitTest: name: Components unit tests @@ -185,21 +164,16 @@ jobs: needs: - buildComponents steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Download component artifacts - uses: actions/download-artifact@v3 + - name: Restore cached working directory + uses: actions/cache@v4 with: - name: components-package - - name: Unpack components artifacts - run: tar -xzf components-full.tgz - - name: Unit tests + key: cloudscape-design/components-${{ github.event.pull_request.head.sha || github.sha }} + path: ${{ github.workspace }} + - name: Run Unit Tests run: npm run test:unit integTestShards: - name: Components integration tests shard + name: Components integration tests shards runs-on: ubuntu-latest strategy: matrix: @@ -207,56 +181,34 @@ jobs: needs: - buildComponents steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Download component artifacts - uses: actions/download-artifact@v3 + - name: Restore cached working directory + uses: actions/cache@v4 with: - name: components-package - - name: Unpack components artifacts - run: tar -xzf components-full.tgz + key: cloudscape-design/components-${{ github.event.pull_request.head.sha || github.sha }} + restore-keys: | + cloudscape-design/components- + path: ${{ github.workspace }} - name: Integration tests run: npm run test:integ -- --shard=${{ matrix.shard }}/${{ strategy.job-total }} - integTest: - name: Components integration tests - runs-on: ubuntu-latest - needs: - - integTestShards - steps: - - run: echo "Completed all integration tests" - motionTest: name: Components motion tests runs-on: ubuntu-latest needs: - buildComponents steps: - - name: Setup Node.js - uses: actions/setup-node@v3 + - name: Restore cached working directory + uses: actions/cache@v4 with: - node-version: 18 - - name: Download component artifacts - uses: actions/download-artifact@v3 - with: - name: components-package - - name: Unpack components artifacts - run: tar -xzf components-full.tgz + key: cloudscape-design/components-${{ github.event.pull_request.head.sha || github.sha }} + restore-keys: | + cloudscape-design/components- + path: ${{ github.workspace }} - name: Motion tests run: npm run test:motion - a11yTest: - name: Components accessibility tests - runs-on: ubuntu-latest - needs: - - a11yTestShards - steps: - - run: echo "Completed all accessibility tests" - a11yTestShards: - name: Components accessibility tests shard + name: Components accessibility tests shards runs-on: ubuntu-latest strategy: matrix: @@ -264,19 +216,32 @@ jobs: needs: - buildComponents steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Download component artifacts - uses: actions/download-artifact@v3 + - name: Restore cached working directory + uses: actions/cache@v4 with: - name: components-package - - name: Unpack components artifacts - run: tar -xzf components-full.tgz + key: cloudscape-design/components-${{ github.event.pull_request.head.sha || github.sha }} + restore-keys: | + cloudscape-design/components- + path: ${{ github.workspace }} - name: Accessibility tests run: npm run test:a11y -- --shard=${{ matrix.shard }}/${{ strategy.job-total }} + integTest: + name: Components integration tests + runs-on: ubuntu-latest + needs: + - integTestShards + steps: + - run: echo "Completed all integration tests" + + a11yTest: + name: Components accessibility tests + runs-on: ubuntu-latest + needs: + - a11yTestShards + steps: + - run: echo "Completed all accessibility tests" + demosTest: name: Demos tests runs-on: ubuntu-latest @@ -291,12 +256,7 @@ jobs: - buildGlobalStyles - buildThemingCore steps: - - name: Download component artifacts - uses: actions/download-artifact@v3 - with: - name: components-package - name: Build - uses: cloudscape-design/actions/.github/actions/build-package@main + uses: cloudscape-design/actions/.github/actions/build-repository@main with: - package: demos - download_dependencies: true + repository: cloudscape-design/demos