From 8eec20ba0a45a73f431897daad5a9ceb0c86ccf8 Mon Sep 17 00:00:00 2001 From: Chukwuemeka Ajima Date: Thu, 10 Jul 2025 15:55:38 +0200 Subject: [PATCH 1/3] chore(ci): move ci to github actions - move all related CI-CD workflows from circleci to github actions --- .github/actions/ci/action.yml | 26 ++++++ .github/workflows/docs.yml | 11 ++- .github/workflows/qa.yml | 125 ++++++++++++++++++++++++++ .github/workflows/release.yml | 24 +---- {.circleci => [.circleci]}/config.yml | 0 5 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 .github/actions/ci/action.yml create mode 100644 .github/workflows/qa.yml rename {.circleci => [.circleci]}/config.yml (100%) diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 000000000..af93a3029 --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,26 @@ +name: CI + +description: Shared action to install dependencies + +runs: + using: composite + + steps: + - name: Read .nvmrc + id: nvm + run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT + shell: bash + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version-file: ".nvmrc" + cache: "yarn" + + # Whenever on a changeset versioning PR + # Then installing can not fail with lockfile changes + # Because the package.json for integration test changes. + + - name: Install + run: yarn install --immutable + shell: bash diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4e11c9b95..c15958619 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -6,7 +6,10 @@ on: event: description: "TypeDoc deploy" required: true -permissions: {} + +permissions: + pages: write # to deploy to Pages + id-token: write jobs: # Build job @@ -29,11 +32,7 @@ jobs: # Deploy job deploy: runs-on: ubuntu-latest - needs: build - - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source + needs: build # to verify the deployment originates from an appropriate source # Deploy to the github-pages environment environment: diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 000000000..dcff55b28 --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,125 @@ +name: Qa + +on: + push: + branches: + - 'master' + - '!changeset-release/**' + + pull_request: + +jobs: + immutable-install: + if: ${{ !startsWith(github.ref, 'refs/heads/changeset-release/') }} + name: Immutable Install + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup + uses: ./.github/actions/ci + + # The shared install action does not respect the + # `--immutable` flag, so we need to run it here. + - name: Install with lockfile + run: yarn install --immutable + + linting: + if: ${{ !startsWith(github.ref, 'refs/heads/changeset-release/') }} + name: Linting + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup + uses: ./.github/actions/ci + + - name: Lint + run: yarn format + + type-checking: + if: ${{ !startsWith(github.ref, 'refs/heads/changeset-release/') }} + name: Type checking + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup + uses: ./.github/actions/ci + + - name: TypeScript + run: yarn typecheck + + testing: + if: ${{ !startsWith(github.ref, 'refs/heads/changeset-release/') }} + name: Testing + needs: [immutable-install, linting, type-checking] + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup + uses: ./.github/actions/ci + + - name: Build + run: yarn build + + - uses: oNaiPs/secrets-to-env-action@ec46a22bfc9b37e014b627b3208b07eb8909ea0f # v1.5 + with: + secrets: ${{ toJSON(secrets) }} + + - name: Test (Examples) + run: cd examples;yarn test + + - name: Test (Unit) + run: yarn test:unit + + - name: Test (Integration) + run: yarn test --coverage + + - name: Upload Coverage Report + uses: codecov/codecov-action@v5 #2db07e317924c76f654a414629d71c65876882e2 v5.4.3 + with: + file: coverage/clover.xml + token: ${{ secrets.CODECOV_TOKEN }} + flags: test-coverage + + regression-testing: + if: ${{ !startsWith(github.ref, 'refs/heads/changeset-release/') }} + name: Regression Testing + needs: [testing] + runs-on: ubuntu-latest + strategy: + matrix: + version: [18, 20] + fail-fast: true + max-parallel: 1 + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup + uses: ./.github/actions/ci + + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ matrix.version }} + + - name: Build + run: yarn build + + - uses: oNaiPs/secrets-to-env-action@ec46a22bfc9b37e014b627b3208b07eb8909ea0f # v1.5 + with: + secrets: ${{ toJSON(secrets) }} + + - name: Integration tests + run: yarn test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e087bf18..7c43d87ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,28 +38,8 @@ jobs: # https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8 token: ${{ steps.generate_github_token.outputs.token }} - - name: Read .nvmrc - run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT - id: nvm - - - name: Setup Node (uses version in .nvmrc) - uses: actions/setup-node@v4 - with: - node-version: '${{ steps.nvm.outputs.NVMRC }}' - - - name: Get yarn cache - id: yarn-cache - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 - with: - path: ${{ steps.yarn-cache.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Install dependencies - run: yarn install --frozen-lockfile + - name: Setup + uses: ./.github/actions/ci - name: Creating .npmrc run: | diff --git a/.circleci/config.yml b/[.circleci]/config.yml similarity index 100% rename from .circleci/config.yml rename to [.circleci]/config.yml From 788736ca4aed77fc28f1dd7acdd8b015d9b359ec Mon Sep 17 00:00:00 2001 From: Chukwuemeka Ajima Date: Thu, 10 Jul 2025 16:19:46 +0200 Subject: [PATCH 2/3] chore(ci): minor fix - add actions permission - add command to install example dependencies --- .github/workflows/qa.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index dcff55b28..3db863372 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -1,5 +1,9 @@ name: Qa +permissions: + contents: read + pull-requests: write + on: push: branches: @@ -77,7 +81,10 @@ jobs: secrets: ${{ toJSON(secrets) }} - name: Test (Examples) - run: cd examples;yarn test + run: | + cd examples + yarn install --immutable + yarn test - name: Test (Unit) run: yarn test:unit From 545095f96ceb843288b6c31fe83dbc20d7f6c54e Mon Sep 17 00:00:00 2001 From: Chukwuemeka Ajima Date: Thu, 10 Jul 2025 16:53:16 +0200 Subject: [PATCH 3/3] chore(ci): minor fix - remove file option from codecov reporter --- .github/workflows/qa.yml | 1 - [.circleci]/config.yml | 332 +++++++++++++++++++-------------------- 2 files changed, 166 insertions(+), 167 deletions(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 3db863372..d61dc7094 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -95,7 +95,6 @@ jobs: - name: Upload Coverage Report uses: codecov/codecov-action@v5 #2db07e317924c76f654a414629d71c65876882e2 v5.4.3 with: - file: coverage/clover.xml token: ${{ secrets.CODECOV_TOKEN }} flags: test-coverage diff --git a/[.circleci]/config.yml b/[.circleci]/config.yml index 40d56e13e..c19ff9a6d 100644 --- a/[.circleci]/config.yml +++ b/[.circleci]/config.yml @@ -1,166 +1,166 @@ -version: 2.1 - -# define constants -aliases: - - &working_directory ~/commercetools-sdk-typescript - - # node version 18 - - &restore_yarn_cache_node_18 - name: 'Restoring yarn cache' - keys: - - yarn-cache-node_18-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - - - &save_yarn_cache_node_18 - name: 'Saving yarn cache' - key: yarn-cache-node_18-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - paths: - - ~/.cache/yarn - - - # node version 20 - - &restore_yarn_cache_node_20 - name: 'Restoring yarn cache' - keys: - - yarn-cache-node_20-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - - - &save_yarn_cache_node_20 - name: 'Saving yarn cache' - key: yarn-cache-node_20-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - # Persisting to the workspace is always relative to the root which is our working directory. - # https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace - paths: - - ~/.cache/yarn - - # node version 22 - - &restore_yarn_cache_node_22 - name: 'Restoring yarn cache' - keys: - - yarn-cache-node_22-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - - - &save_yarn_cache_node_22 - name: 'Saving yarn cache' - key: yarn-cache-node_22-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - # Persisting to the workspace is always relative to the root which is our working directory. - # https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace - paths: - - ~/.cache/yarn - -# executors -executors: - node_18: - docker: - - image: cimg/node:18.20.8 - working_directory: *working_directory - - node_20: - docker: - - image: cimg/node:20.19.1 - working_directory: *working_directory - - node_22: - docker: - - image: cimg/node:22.15.0 - working_directory: *working_directory - - -# orbs -orbs: - codecov: codecov/codecov@4.2.0 - -# jobs -jobs: - install_test_node_18: - executor: node_18 - steps: - - checkout - - restore_cache: *restore_yarn_cache_node_18 - - run: - name: Installing dependencies - command: yarn install --frozen-lockfile - - save_cache: *save_yarn_cache_node_18 - - run: - name: Install example dependencies - command: | - cd examples - yarn install --frozen-lockfile - - run: - name: Building packages - command: yarn build - - run: - name: Running example tests - command: | - cd examples - yarn test - - run: - name: Running tests - command: yarn test:unit - - install_test_node_20: - executor: node_20 - steps: - - checkout - - restore_cache: *restore_yarn_cache_node_20 - - run: - name: Installing dependencies - command: yarn install --frozen-lockfile - - save_cache: *save_yarn_cache_node_20 - - run: - name: Install example dependencies - command: | - cd examples - yarn install --frozen-lockfile - - run: - name: Building packages - command: yarn build - - run: - name: Running example tests - command: | - cd examples - yarn test - - run: - name: Running tests - command: yarn test:unit - - install_test_node_22: - executor: node_22 - steps: - - checkout - - restore_cache: *restore_yarn_cache_node_22 - - run: - name: Installing dependencies - command: yarn install --frozen-lockfile - - save_cache: *save_yarn_cache_node_22 - - run: - name: Install example dependencies - command: | - cd examples - yarn install --frozen-lockfile - - run: - name: Building packages - command: yarn build - - run: - name: Running example tests - command: | - cd examples - yarn test - - run: - name: Running tests - command: JEST_TIMEOUT=180000 yarn test --coverage - - codecov/upload: - file: coverage/clover.xml - flags: 'test-coverage' - -# workflows -workflows: - version: 2 - build_and_test: - jobs: - - install_test_node_18: - context: org-global - - install_test_node_20: - context: org-global - - install_test_node_22: - context: org-global - requires: - - install_test_node_18 - - install_test_node_20 +# version: 2.1 + +# # define constants +# aliases: +# - &working_directory ~/commercetools-sdk-typescript + +# # node version 18 +# - &restore_yarn_cache_node_18 +# name: 'Restoring yarn cache' +# keys: +# - yarn-cache-node_18-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} + +# - &save_yarn_cache_node_18 +# name: 'Saving yarn cache' +# key: yarn-cache-node_18-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} +# paths: +# - ~/.cache/yarn + + +# # node version 20 +# - &restore_yarn_cache_node_20 +# name: 'Restoring yarn cache' +# keys: +# - yarn-cache-node_20-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} + +# - &save_yarn_cache_node_20 +# name: 'Saving yarn cache' +# key: yarn-cache-node_20-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} +# # Persisting to the workspace is always relative to the root which is our working directory. +# # https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace +# paths: +# - ~/.cache/yarn + +# # node version 22 +# - &restore_yarn_cache_node_22 +# name: 'Restoring yarn cache' +# keys: +# - yarn-cache-node_22-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} + +# - &save_yarn_cache_node_22 +# name: 'Saving yarn cache' +# key: yarn-cache-node_22-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} +# # Persisting to the workspace is always relative to the root which is our working directory. +# # https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace +# paths: +# - ~/.cache/yarn + +# # executors +# executors: +# node_18: +# docker: +# - image: cimg/node:18.20.8 +# working_directory: *working_directory + +# node_20: +# docker: +# - image: cimg/node:20.19.1 +# working_directory: *working_directory + +# node_22: +# docker: +# - image: cimg/node:22.15.0 +# working_directory: *working_directory + + +# # orbs +# orbs: +# codecov: codecov/codecov@4.2.0 + +# # jobs +# jobs: +# install_test_node_18: +# executor: node_18 +# steps: +# - checkout +# - restore_cache: *restore_yarn_cache_node_18 +# - run: +# name: Installing dependencies +# command: yarn install --frozen-lockfile +# - save_cache: *save_yarn_cache_node_18 +# - run: +# name: Install example dependencies +# command: | +# cd examples +# yarn install --frozen-lockfile +# - run: +# name: Building packages +# command: yarn build +# - run: +# name: Running example tests +# command: | +# cd examples +# yarn test +# - run: +# name: Running tests +# command: yarn test:unit + +# install_test_node_20: +# executor: node_20 +# steps: +# - checkout +# - restore_cache: *restore_yarn_cache_node_20 +# - run: +# name: Installing dependencies +# command: yarn install --frozen-lockfile +# - save_cache: *save_yarn_cache_node_20 +# - run: +# name: Install example dependencies +# command: | +# cd examples +# yarn install --frozen-lockfile +# - run: +# name: Building packages +# command: yarn build +# - run: +# name: Running example tests +# command: | +# cd examples +# yarn test +# - run: +# name: Running tests +# command: yarn test:unit + +# install_test_node_22: +# executor: node_22 +# steps: +# - checkout +# - restore_cache: *restore_yarn_cache_node_22 +# - run: +# name: Installing dependencies +# command: yarn install --frozen-lockfile +# - save_cache: *save_yarn_cache_node_22 +# - run: +# name: Install example dependencies +# command: | +# cd examples +# yarn install --frozen-lockfile +# - run: +# name: Building packages +# command: yarn build +# - run: +# name: Running example tests +# command: | +# cd examples +# yarn test +# - run: +# name: Running tests +# command: JEST_TIMEOUT=180000 yarn test --coverage +# - codecov/upload: +# file: coverage/clover.xml +# flags: 'test-coverage' + +# # workflows +# workflows: +# version: 2 +# build_and_test: +# jobs: +# - install_test_node_18: +# context: org-global +# - install_test_node_20: +# context: org-global +# - install_test_node_22: +# context: org-global +# requires: +# - install_test_node_18 +# - install_test_node_20