diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a19077..266c15d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: install: working_directory: ~/etherspot-prime-sdk docker: - - image: cimg/node:18.16.0 + - image: cimg/node:18.16.1 auth: username: $DOCKERHUB_USER password: $DOCKERHUB_PASSWORD @@ -25,15 +25,66 @@ jobs: key: dependency-cache-{{ checksum "package.json" }} paths: - ./node_modules + # - slack/status: + # failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job has failed! :circleci-fail:" + # webhook: "${SLACK_WEBHOOK_URL}" + + e2e-tests: + working_directory: ~/etherspot-prime-sdk + docker: + - image: cimg/node:18.16.1 + auth: + username: $DOCKERHUB_USER + password: $DOCKERHUB_PASSWORD + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: + name: Authenticate with registry + command: echo "//registry.npmjs.org/:_authToken=$ETHERSPOT_NPM_TOKEN" > ~/etherspot-prime-sdk/.npmrc + - run: + name: Build Etherpot Prime SDK + command: npm run build + - run: + name: Checkout e2e repo and run tests + no_output_timeout: 60m + command: | + cd ~ + git clone https://github.com/etherspot/e2e-sdk-prime.git + cd e2e-sdk-prime + sed -i.bak "s/_private_key_/$PRIVATE_KEY/g" .env + sed -i.bak "s/_project_key_/$PROJECT_KEY/g" .env + mv package.json temp.json + jq -r '.dependencies."@etherspot/prime-sdk" |= "file:../etherspot-prime-sdk"' temp.json > package.json + rm temp.json + npm i + touch ~/logs.txt + npm run test-mainnet |& tee ~/logs.txt + chmod 755 ~/logs.txt + cat ~/logs.txt + echo "export LOGS='$(cat ~/logs.txt)'" >> $BASH_ENV + echo $BASH_ENV + rm ~/logs.txt + source "$BASH_ENV" + - run: + name: Move test report + command: | + mv /home/circleci/e2e-sdk-prime/mochawesome-report /tmp/ + chmod 777 -R /tmp/mochawesome-report + when: always + - store_artifacts: + path: /tmp/mochawesome-report + when: always - slack/status: - fail_only: true - failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job has failed! :circleci-fail:" + failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job e2e tests failed! :circleci-fail: \n\n Report URL: https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/tmp/mochawesome-report/mochawesome.html" + success_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Woohoh! The *$CIRCLE_JOB* job e2e tests completed successfully! :circleci-pass: \n\n Report URL: https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/tmp/mochawesome-report/mochawesome.html" + # only_for_branches: master webhook: "${SLACK_WEBHOOK_URL}" - - publish: + publish-npm-package: working_directory: ~/etherspot-prime-sdk docker: - - image: cimg/node:18.16.0 + - image: cimg/node:18.16.1 auth: username: $DOCKERHUB_USER password: $DOCKERHUB_PASSWORD @@ -49,17 +100,14 @@ jobs: command: npm run build - run: name: Publish package to npm - command: npm publish --access=public + command: | + cd ~/etherspot-prime-sdk + npm publish - run: name: Announce Publish command: | chmod +x .circleci/announcePublish.sh .circleci/announcePublish.sh "Etherspot Prime SDK" "$(node -e "console.log(require('./package.json').version)")" - - slack/status: - fail_only: true - failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job has failed! :circleci-fail:" - only_for_branches: master - webhook: "${SLACK_WEBHOOK_URL}" publish-github-release: docker: - image: ardd97/ghr @@ -78,10 +126,16 @@ workflows: jobs: - install: context: general-vars - - publish: + - e2e-tests: + context: general-vars + filters: + branches: + only: + - master + - publish-npm-package: context: general-vars requires: - - install + - e2e-tests filters: branches: only: @@ -89,8 +143,8 @@ workflows: - publish-github-release: context: general-vars requires: - - publish + - publish-npm-package filters: branches: only: - - master + - master \ No newline at end of file