-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Skip e2e steps using CircleCI params (#48)
* Add step to skip e2e tests using conditional params
- Loading branch information
Showing
1 changed file
with
51 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
version: 2.1 | ||
|
||
parameters: | ||
run_e2e_tests: | ||
type: boolean | ||
default: true | ||
orbs: | ||
slack: circleci/[email protected] | ||
|
||
|
@@ -38,53 +41,53 @@ jobs: | |
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: | | ||
if [ "$SKIP_E2E_TESTS" = "false" ]; then | ||
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" | ||
else | ||
echo "E2E Tests skipped..." | ||
fi | ||
- 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: | ||
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}" | ||
- when: | ||
condition: <<pipeline.parameters.run_e2e_tests>> | ||
steps: | ||
|
||
- 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: | ||
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-npm-package: | ||
working_directory: ~/etherspot-prime-sdk | ||
docker: | ||
|