Skip to content

Commit

Permalink
Feature/e2e pipeline (#237)
Browse files Browse the repository at this point in the history
* Initial e2e pipeline setup

* Change local path to etherspot package in pipeline for e2e tests

* Check one of the e2e tests

* Fix pipeline path

* Comment jq

* Change jq command

* Change e2e test

* Comment e2e test

* Change image to v.16

* Change image to v.18

* Uncomment npm commands

* Add github actions for e2e

* fix: slack status for pipeline

* fix: Change branch

* fix: mochaawesome reports

* disable slack on install

* feat: Add publish step

---------

Co-authored-by: vnovacev <[email protected]>
  • Loading branch information
sarthakprp and vnovacev authored Oct 18, 2023
1 parent e324d3c commit 1af1e57
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 15 deletions.
85 changes: 70 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
install:
working_directory: ~/etherspot-sdk
docker:
- image: cimg/node:14.21.3
- image: cimg/node:18.16.1
auth:
username: $DOCKERHUB_USER
password: $DOCKERHUB_PASSWORD
Expand All @@ -25,15 +25,14 @@ jobs:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- slack/status:
fail_only: true
failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job has failed! :circleci-fail:"
webhook: "${SLACK_WEBHOOK_URL}"
# - slack/status:
# failure_message: "Triggered by: *${CIRCLE_USERNAME}* \n\n Ooops! The *$CIRCLE_JOB* job has failed! :circleci-fail:"
# webhook: "${SLACK_WEBHOOK_URL}"

publish:
e2e-tests:
working_directory: ~/etherspot-sdk
docker:
- image: cimg/node:14.21.3
- image: cimg/node:18.16.1
auth:
username: $DOCKERHUB_USER
password: $DOCKERHUB_PASSWORD
Expand All @@ -47,19 +46,67 @@ jobs:
- run:
name: Build Etherpot-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.git
cd e2e-sdk
sed -i.bak "s/_private_key_/$PRIVATE_KEY/g" .env
mv package.json temp.json
jq -r '.dependencies.etherspot |= "file:../etherspot-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-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-sdk/.npmrc
- run:
name: Build Etherpot SDK
command: npm run build
- run:
name: Publish package to npm
command: npm publish
command: |
cd ~/etherspot-sdk
npm publish
- run:
name: Announce Publish
command: |
chmod +x .circleci/announcePublish.sh
.circleci/announcePublish.sh "Etherspot 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
Expand All @@ -78,16 +125,24 @@ 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:
- master
- publish-github-release:
context: general-vars
requires:
- publish-npm-package
filters:
branches:
only:
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: install_and_publish

on:
push:
branches:
- feature/e2e_pipeline

jobs:
install:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ~/etherspot-sdk
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Authenticate with registry
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.ETHERSPOT_NPM_TOKEN }}" > ~/etherspot-sdk/.npmrc

- name: Restore cache
uses: actions/cache@v3
with:
path: ./node_modules
key: dependency-cache-${{ hashFiles('package.json') }}
restore-keys: dependency-cache-*

- name: Install dependencies
run: npm install

- name: Save cache
uses: actions/cache@v3
with:
path: ./node_modules
key: dependency-cache-${{ hashFiles('package.json') }}

publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ~/etherspot-sdk
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Restore cache
uses: actions/cache@v3
with:
path: ./node_modules
key: dependency-cache-${{ hashFiles('package.json') }}
restore-keys: dependency-cache-*

- name: Authenticate with registry
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.ETHERSPOT_NPM_TOKEN }}" > ~/etherspot-sdk/.npmrc

- name: Build Etherpot-SDK
run: npm run build

- name: Checkout e2e repo and run tests
run: |
git clone https://github.com/etherspot/e2e-sdk.git
cd e2e-sdk
sed -i.bak "s/_private_key_/${{ secrets.PRIVATE_KEY }}/g" .env
mv package.json temp.json
jq -r '.dependencies.etherspot |= "file:../etherspot-sdk"' temp.json > package.json
rm temp.json
npm i
# npm run test-mainnet
- name: Install gh cli
run: |
sudo apt update
sudo apt install gh
- name: Get package version
run: |
PACKAGE_VERSION="$(jq .version package.json -r)"
echo $PACKAGE_VERSION
- name: Publish release
run: |
ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${{ secrets.GITHUB_USERNAME }} -r ${{ github.repository }} -c ${{ github.sha }} $PACKAGE_VERSION

0 comments on commit 1af1e57

Please sign in to comment.