diff --git a/.circleci/config.yml b/.circleci/config.yml index b09da2d4..f533e706 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,11 +1,200 @@ version: 2.1 setup: true orbs: + node: circleci/node@dev:<> orb-tools: circleci/orb-tools@11.5 - shellcheck: circleci/shellcheck@3.1 + jq: circleci/jq@2.2.0 +commands: + check-uploaded-test-results: + parameters: + job-name: + type: string + expected-tests: + type: integer + steps: + - run: + name: check for << parameters.job-name >> test results + command: | + export TEST_JOB_NUMBER=$(jq '.items[] | select(.name == "<< parameters.job-name >>") | .job_number' workflow.json) + curl --request GET \ + --url https://circleci.com/api/v2/project/gh/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$TEST_JOB_NUMBER/tests \ + --header 'authorization: Basic $CIRCLE_TOKEN' \ + | jq '.items | length | if . != << parameters.expected-tests >> then halt_error else . end' +executors: + linux: + docker: + - image: cimg/base:stable + macos: + macos: + xcode: 13.2.0 + machine: + machine: + image: ubuntu-2004:202111-01 + windows: + machine: + image: windows-server-2022-gui:current + shell: bash.exe + resource_class: windows.medium +jobs: + # Install Node.js into a non-node container. + integration-test-install-specified-version: + parameters: + os: + type: executor + executor: <> + steps: + - checkout + - node/install: + node-version: "16.13" + install-yarn: true # Test the install of YARN + yarn-version: "1.22.5" + - run: + command: | + if ! node --version | grep -q "16"; then + echo "Node version 16 not found" + exit 1 + fi + + integration-test-install-latest: + parameters: + os: + type: executor + executor: <> + steps: + - checkout + - node/install: + node-version: "latest" + - run: + name: Check that latest Node.js is installed. + command: | + NODE_ORB_INSTALL_VERSION=$(nvm ls-remote | tail -n1 | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') + + echo "Latest Node version = $NODE_ORB_INSTALL_VERSION" + echo "Installed version: $(node --version)" + if ! node --version | grep -q "$NODE_ORB_INSTALL_VERSION"; then + echo "Error: Installed version is different from the latest version." + exit 1 + fi + + integration-test-use-nvmrc-version: + parameters: + os: + type: executor + executor: <> + steps: + - checkout + - run: echo '16.13' > .nvmrc + - node/install + + integration-test-install-lts: + parameters: + os: + type: executor + executor: <> + steps: + - checkout + - node/install + - run: + name: Check that the latest LTS version of Node.js is installed. + command: | + NODE_ORB_INSTALL_VERSION=$(nvm ls-remote | grep 'Latest LTS' | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') + echo "Latest Node LTS version = $NODE_ORB_INSTALL_VERSION" + echo "Installed version: $(node --version)" + if ! node --version | grep -q "$NODE_ORB_INSTALL_VERSION"; then + echo "Error: Installed version is different from the latest LTS version." + exit 1 + fi + + integration-test-override-ci: + executor: node/default + steps: + - checkout + - node/install-packages: + override-ci-command: npm install + cache-path: ~/project/node_modules + cache-version: override-v3 + app-dir: "~/project/sample" + - run: cd ~/project/sample && npm run test + integration-test-override-ci-windows: + executor: windows + steps: + - checkout + - run: + name: Install Node.js + command: | + nvm install lts + nvm use lts + - node/install-packages: + override-ci-command: npm install + cache-path: ~/project/node_modules + cache-version: override-v3 + app-dir: "~/project/sample" + - run: cd ~/project/sample && npm run test + integration-test-pnpm: + executor: + name: node/default + steps: + - checkout + - node/install-packages: + pkg-manager: pnpm + app-dir: "~/project/sample" + - run: cd ~/project/sample && pnpm test + integration-test-yarn: + executor: + name: node/default + steps: + - checkout + - node/install-packages: + pkg-manager: yarn + cache-version: yarn-v3 + app-dir: "~/project/sample" + - run: cd ~/project/sample && yarn test + integration-test-yarn-berry: + executor: + name: node/default + steps: + - checkout + - node/install-packages: + pkg-manager: yarn-berry + cache-version: yarn-berry-v1 + app-dir: "~/project/sample" + - run: cd ~/project/sample && yarn test + + check-test-results-uploaded: + executor: + name: node/default + steps: + - jq/install + - run: + name: fetch workflow + command: | + curl --request GET \ + --url https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job \ + --header 'authorization: Basic $CIRCLE_TOKEN' > workflow.json + - check-uploaded-test-results: + job-name: node-npm-jest-test-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-yarn-jest-test-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-pnpm-jest-test-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-test-results-file-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-npm-mocha-test-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-yarn-mocha-test-job + expected-tests: 1 + - check-uploaded-test-results: + job-name: node-pnpm-mocha-test-job + expected-tests: 1 workflows: - lint-pack: + test-deploy: jobs: - orb-tools/lint: filters: @@ -19,27 +208,188 @@ workflows: filters: tags: only: /.*/ - - shellcheck/check: - exclude: SC2148,SC2038,SC2086,SC2002,SC2016 + - integration-test-install-specified-version: + filters: + tags: + only: /.*/ + matrix: + parameters: + os: [linux, macos, machine] + - integration-test-install-latest: + filters: + tags: + only: /.*/ + matrix: + parameters: + os: [linux, macos, machine] + - integration-test-install-lts: + filters: + tags: + only: /.*/ + matrix: + parameters: + os: [linux, macos, machine] + - node/test: + filters: + tags: + only: /.*/ + name: node-npm-jest-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: jest + - node/test: + filters: + tags: + only: /.*/ + name: node-yarn-jest-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: jest + pkg-manager: yarn + - node/test: + filters: + tags: + only: /.*/ + name: node-pnpm-jest-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: jest + pkg-manager: pnpm + - node/test: + filters: + tags: + only: /.*/ + name: node-npm-mocha-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: mocha + run-command: testmocha + - node/test: + filters: + tags: + only: /.*/ + name: node-yarn-mocha-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: mocha + pkg-manager: yarn + run-command: testmocha + - node/test: + filters: + tags: + only: /.*/ + name: node-pnpm-mocha-test-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: mocha + pkg-manager: pnpm + run-command: testmocha + - node/test: + filters: + tags: + only: /.*/ + name: node-yarn-mocha-with-test-result-path-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-for: mocha + pkg-manager: yarn + run-command: testmocha + test-results-path: sample/test-results.xml + - node/test: + filters: + tags: + only: /.*/ + name: node-test-results-file-job + app-dir: "~/project/sample" + cache-version: v4 + test-results-path: sample/other-junit.xml + - node/test: + filters: + tags: + only: /.*/ + name: node-test-no-junit + app-dir: "~/project/sample" + cache-version: v4 + - check-test-results-uploaded: + filters: + tags: + only: /.*/ + requires: + - node-npm-jest-test-job + - node-yarn-jest-test-job + - node-pnpm-jest-test-job + - node-npm-mocha-test-job + - node-yarn-mocha-test-job + - node-pnpm-mocha-test-job + - node-test-results-file-job + - node/run: + filters: + tags: + only: /.*/ + name: node-run-npm-job + app-dir: "~/project/sample" + cache-version: v4 + npm-run: build + - node/run: + filters: + tags: + only: /.*/ + name: node-run-yarn-job + app-dir: "~/project/sample" + cache-version: v5 + pkg-manager: yarn + yarn-run: build + - node/run: + filters: + tags: + only: /.*/ + name: node-run-pnpm-job + app-dir: "~/project/sample" + cache-version: v5 + pkg-manager: pnpm + yarn-run: build + - integration-test-override-ci: + filters: + tags: + only: /.*/ + - integration-test-override-ci-windows: + filters: + tags: + only: /.*/ + - integration-test-pnpm: + filters: + tags: + only: /.*/ + - integration-test-yarn: + filters: + tags: + only: /.*/ + - integration-test-yarn-berry: filters: tags: only: /.*/ - orb-tools/publish: orb-name: circleci/node vcs-type: << pipeline.project.type >> + pub-type: production requires: - [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check] - # Use a context to hold your publishing token. + - orb-tools/lint + - orb-tools/review + - orb-tools/pack + - integration-test-install-specified-version + - integration-test-install-latest + - integration-test-install-lts + - integration-test-pnpm + - check-test-results-uploaded + - node-yarn-mocha-with-test-result-path-job + - node-test-results-file-job + - node-run-npm-job + - node-run-yarn-job + - node-run-pnpm-job github-token: GHI_TOKEN context: orb-publisher filters: + branches: + ignore: /.*/ tags: - only: /.*/ - # Triggers the next workflow in the Orb Development Kit. - - orb-tools/continue: - pipeline-number: << pipeline.number >> - vcs-type: << pipeline.project.type >> - requires: [orb-tools/publish] - filters: - tags: - only: /.*/ + only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ diff --git a/.circleci/config_normal.yml b/.circleci/config_normal.yml new file mode 100644 index 00000000..b09da2d4 --- /dev/null +++ b/.circleci/config_normal.yml @@ -0,0 +1,45 @@ +version: 2.1 +setup: true +orbs: + orb-tools: circleci/orb-tools@11.5 + shellcheck: circleci/shellcheck@3.1 + +workflows: + lint-pack: + jobs: + - orb-tools/lint: + filters: + tags: + only: /.*/ + - orb-tools/pack: + filters: + tags: + only: /.*/ + - orb-tools/review: + filters: + tags: + only: /.*/ + - shellcheck/check: + exclude: SC2148,SC2038,SC2086,SC2002,SC2016 + filters: + tags: + only: /.*/ + - orb-tools/publish: + orb-name: circleci/node + vcs-type: << pipeline.project.type >> + requires: + [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check] + # Use a context to hold your publishing token. + github-token: GHI_TOKEN + context: orb-publisher + filters: + tags: + only: /.*/ + # Triggers the next workflow in the Orb Development Kit. + - orb-tools/continue: + pipeline-number: << pipeline.number >> + vcs-type: << pipeline.project.type >> + requires: [orb-tools/publish] + filters: + tags: + only: /.*/ diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml deleted file mode 100644 index f0818948..00000000 --- a/.circleci/test-deploy.yml +++ /dev/null @@ -1,394 +0,0 @@ -version: 2.1 -orbs: - node: circleci/node@dev:<> - orb-tools: circleci/orb-tools@11.5 - jq: circleci/jq@2.2.0 -commands: - check-uploaded-test-results: - parameters: - job-name: - type: string - expected-tests: - type: integer - steps: - - run: - name: check for << parameters.job-name >> test results - command: | - export TEST_JOB_NUMBER=$(jq '.items[] | select(.name == "<< parameters.job-name >>") | .job_number' workflow.json) - curl --request GET \ - --url https://circleci.com/api/v2/project/gh/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$TEST_JOB_NUMBER/tests \ - --header 'authorization: Basic $CIRCLE_TOKEN' \ - | jq '.items | length | if . != << parameters.expected-tests >> then halt_error else . end' -executors: - linux: - docker: - - image: cimg/base:stable - macos: - macos: - xcode: 13.2.0 - machine: - machine: - image: ubuntu-2004:202111-01 - windows: - machine: - image: windows-server-2022-gui:current - shell: bash.exe - resource_class: windows.medium -jobs: - # Install Node.js into a non-node container. - integration-test-install-specified-version: - parameters: - os: - type: executor - executor: <> - steps: - - checkout - - node/install: - node-version: "16.13" - install-yarn: true # Test the install of YARN - yarn-version: "1.22.5" - - run: - command: | - if ! node --version | grep -q "16"; then - echo "Node version 16 not found" - exit 1 - fi - - integration-test-install-latest: - parameters: - os: - type: executor - executor: <> - steps: - - checkout - - node/install: - node-version: "latest" - - run: - name: Check that latest Node.js is installed. - command: | - NODE_ORB_INSTALL_VERSION=$(nvm ls-remote | tail -n1 | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') - - echo "Latest Node version = $NODE_ORB_INSTALL_VERSION" - echo "Installed version: $(node --version)" - if ! node --version | grep -q "$NODE_ORB_INSTALL_VERSION"; then - echo "Error: Installed version is different from the latest version." - exit 1 - fi - - integration-test-use-nvmrc-version: - parameters: - os: - type: executor - executor: <> - steps: - - checkout - - run: echo '16.13' > .nvmrc - - node/install - - integration-test-install-lts: - parameters: - os: - type: executor - executor: <> - steps: - - checkout - - node/install - - run: - name: Check that the latest LTS version of Node.js is installed. - command: | - NODE_ORB_INSTALL_VERSION=$(nvm ls-remote | grep 'Latest LTS' | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') - echo "Latest Node LTS version = $NODE_ORB_INSTALL_VERSION" - echo "Installed version: $(node --version)" - if ! node --version | grep -q "$NODE_ORB_INSTALL_VERSION"; then - echo "Error: Installed version is different from the latest LTS version." - exit 1 - fi - - integration-test-override-ci: - executor: node/default - steps: - - checkout - - node/install-packages: - override-ci-command: npm install - cache-path: ~/project/node_modules - cache-version: override-v3 - app-dir: "~/project/sample" - - run: cd ~/project/sample && npm run test - integration-test-override-ci-windows: - executor: windows - steps: - - checkout - - run: - name: Install Node.js - command: | - nvm install lts - nvm use lts - - node/install-packages: - override-ci-command: npm install - cache-path: ~/project/node_modules - cache-version: override-v3 - app-dir: "~/project/sample" - - run: cd ~/project/sample && npm run test - integration-test-pnpm: - executor: - name: node/default - steps: - - checkout - - node/install-packages: - pkg-manager: pnpm - app-dir: "~/project/sample" - - run: cd ~/project/sample && pnpm test - integration-test-yarn: - executor: - name: node/default - steps: - - checkout - - node/install-packages: - pkg-manager: yarn - cache-version: yarn-v3 - app-dir: "~/project/sample" - - run: cd ~/project/sample && yarn test - integration-test-yarn-berry: - executor: - name: node/default - steps: - - checkout - - node/install-packages: - pkg-manager: yarn-berry - cache-version: yarn-berry-v1 - app-dir: "~/project/sample" - - run: cd ~/project/sample && yarn test - - check-test-results-uploaded: - executor: - name: node/default - steps: - - jq/install - - run: - name: fetch workflow - command: | - curl --request GET \ - --url https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job \ - --header 'authorization: Basic $CIRCLE_TOKEN' > workflow.json - - check-uploaded-test-results: - job-name: node-npm-jest-test-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-yarn-jest-test-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-pnpm-jest-test-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-test-results-file-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-npm-mocha-test-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-yarn-mocha-test-job - expected-tests: 1 - - check-uploaded-test-results: - job-name: node-pnpm-mocha-test-job - expected-tests: 1 - -workflows: - test-deploy: - jobs: - - orb-tools/lint: - filters: - tags: - only: /.*/ - - orb-tools/pack: - filters: - tags: - only: /.*/ - - orb-tools/review: - filters: - tags: - only: /.*/ - - integration-test-install-specified-version: - filters: - tags: - only: /.*/ - matrix: - parameters: - os: [linux, macos, machine] - - integration-test-install-latest: - filters: - tags: - only: /.*/ - matrix: - parameters: - os: [linux, macos, machine] - - integration-test-install-lts: - filters: - tags: - only: /.*/ - matrix: - parameters: - os: [linux, macos, machine] - - node/test: - filters: - tags: - only: /.*/ - name: node-npm-jest-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: jest - - node/test: - filters: - tags: - only: /.*/ - name: node-yarn-jest-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: jest - pkg-manager: yarn - - node/test: - filters: - tags: - only: /.*/ - name: node-pnpm-jest-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: jest - pkg-manager: pnpm - - node/test: - filters: - tags: - only: /.*/ - name: node-npm-mocha-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: mocha - run-command: testmocha - - node/test: - filters: - tags: - only: /.*/ - name: node-yarn-mocha-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: mocha - pkg-manager: yarn - run-command: testmocha - - node/test: - filters: - tags: - only: /.*/ - name: node-pnpm-mocha-test-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: mocha - pkg-manager: pnpm - run-command: testmocha - - node/test: - filters: - tags: - only: /.*/ - name: node-yarn-mocha-with-test-result-path-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-for: mocha - pkg-manager: yarn - run-command: testmocha - test-results-path: sample/test-results.xml - - node/test: - filters: - tags: - only: /.*/ - name: node-test-results-file-job - app-dir: "~/project/sample" - cache-version: v4 - test-results-path: sample/other-junit.xml - - node/test: - filters: - tags: - only: /.*/ - name: node-test-no-junit - app-dir: "~/project/sample" - cache-version: v4 - - check-test-results-uploaded: - filters: - tags: - only: /.*/ - requires: - - node-npm-jest-test-job - - node-yarn-jest-test-job - - node-pnpm-jest-test-job - - node-npm-mocha-test-job - - node-yarn-mocha-test-job - - node-pnpm-mocha-test-job - - node-test-results-file-job - - node/run: - filters: - tags: - only: /.*/ - name: node-run-npm-job - app-dir: "~/project/sample" - cache-version: v4 - npm-run: build - - node/run: - filters: - tags: - only: /.*/ - name: node-run-yarn-job - app-dir: "~/project/sample" - cache-version: v5 - pkg-manager: yarn - yarn-run: build - - node/run: - filters: - tags: - only: /.*/ - name: node-run-pnpm-job - app-dir: "~/project/sample" - cache-version: v5 - pkg-manager: pnpm - yarn-run: build - - integration-test-override-ci: - filters: - tags: - only: /.*/ - - integration-test-override-ci-windows: - filters: - tags: - only: /.*/ - - integration-test-pnpm: - filters: - tags: - only: /.*/ - - integration-test-yarn: - filters: - tags: - only: /.*/ - - integration-test-yarn-berry: - filters: - tags: - only: /.*/ - - orb-tools/publish: - orb-name: circleci/node - vcs-type: << pipeline.project.type >> - pub-type: production - requires: - - orb-tools/lint - - orb-tools/review - - orb-tools/pack - - integration-test-install-specified-version - - integration-test-install-latest - - integration-test-install-lts - - integration-test-pnpm - - check-test-results-uploaded - - node-yarn-mocha-with-test-result-path-job - - node-test-results-file-job - - node-run-npm-job - - node-run-yarn-job - - node-run-pnpm-job - github-token: GHI_TOKEN - context: orb-publisher - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+$/