diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 40d56e13e..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,166 +0,0 @@ -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 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..d61dc7094 --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,131 @@ +name: Qa + +permissions: + contents: read + pull-requests: write + +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 install --immutable + 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: + 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 new file mode 100644 index 000000000..c19ff9a6d --- /dev/null +++ b/[.circleci]/config.yml @@ -0,0 +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