diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 67d17206..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,162 +0,0 @@ -version: 2.1 -orbs: - coveralls: coveralls/coveralls@1.0.6 - node: circleci/node@4.1 -jobs: - checkout_source: - docker: - - image: cimg/node:16.5 - steps: - - checkout - - persist_to_workspace: - root: . - paths: - - . - - install_dependencies: - docker: - - image: cimg/node:16.5 - steps: - - attach_workspace: - at: . - - restore_cache: - keys: - - dependencies-{{ checksum "package-lock.json" }} - - run: - name: Install dependencies - command: | - npm install - npm run cp-ci-env - - save_cache: - key: dependencies-{{ checksum "package-lock.json" }} - paths: - - node_modules - - persist_to_workspace: - root: . - paths: - - .env - - node_modules/* - - test: - docker: - - image: 'cimg/node:16.5' - resource_class: large - steps: - - attach_workspace: - at: . - - run: - name: Run tests - command: | - CI=true npm run test - - store_artifacts: - path: test - prefix: test - scenarios: - docker: - - image: 'cimg/node:16.5' - resource_class: large - steps: - - attach_workspace: - at: . - - run: - name: Run scenarios - command: | - CI=true npm run scenarios - - store_artifacts: - path: scenarios - prefix: scenarios - - lint: - docker: - - image: 'cimg/node:16.5' - resource_class: medium - steps: - - attach_workspace: - at: . - - run: - name: Run Lint - command: npm run lint - - store_artifacts: - path: lint - prefix: lint - - coverage: - docker: - - image: 'cimg/node:16.5' - # parallelism: 10 - resource_class: xlarge - steps: - - attach_workspace: - at: . - - run: - name: Run Coverage - command: npm run coverage - - coveralls/upload - - store_artifacts: - path: coverage - prefix: coverage - - slither: - docker: - - image: 'trailofbits/eth-security-toolbox' - resource_class: medium - steps: - - attach_workspace: - at: . - - run: - name: Slither - command: | - slither . --filter-paths "node_modules" --disable-color - - gasCompare: - docker: - - image: 'cimg/node:16.5' - resource_class: medium - steps: - - attach_workspace: - at: . - - run: - name: Run GasCompare - command: | - if [ "$CIRCLE_BRANCH" == 'master' ]; then - exit 0 - fi - CI=true npm run test - mv ./gasReporterOutput.json /tmp/gasReporterOutput_Current.json - git checkout master - npm install - CI=true npm run test - mv ./gasReporterOutput.json /tmp/gasReporterOutput_Master.json - git reset --hard - git checkout $CIRCLE_BRANCH - npm run gasCompare /tmp/gasReporterOutput_Current.json /tmp/gasReporterOutput_Master.json - -notify: - webhooks: - - url: >- - https://coveralls.io/webhook?repo_token=${process.env.COVERALLS_REPO_TOKEN} -workflows: - tests: - jobs: - - checkout_source - - install_dependencies: - requires: - - checkout_source - - test: - requires: - - install_dependencies - - scenarios: - requires: - - install_dependencies - - coverage: - requires: - - install_dependencies - - slither: - requires: - - install_dependencies - - lint: - requires: - - install_dependencies - - gasCompare: - requires: - - install_dependencies diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1b877ce0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,152 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize] + +jobs: + + install_dependencies: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install dependencies + run: | + npm install + npm run cp-ci-env + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: persist + + test: + runs-on: ubuntu-latest + needs: install_dependencies + steps: + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: retrieve + - name: Run tests + run: | + CI=true npm run test + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + name: test + path: test + + scenarios: + runs-on: ubuntu-latest + needs: install_dependencies + steps: + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: retrieve + - name: Run scenarios + run: | + CI=true npm run scenarios + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + name: scenarios + path: scenarios + + lint: + runs-on: ubuntu-latest + needs: install_dependencies + steps: + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: retrieve + - name: Run Lint + run: npm run lint + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + name: lint + path: lint + + coverage: + runs-on: ubuntu-latest + needs: install_dependencies + steps: + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: retrieve + - name: Run Coverage + run: npm run coverage + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + name: coverage + path: coverage + + slither: + runs-on: ubuntu-latest + needs: install_dependencies + steps: + - uses: bissolli/gh-action-persist-workspace@v1 + with: + action: retrieve + - name: Run Slither + uses: crytic/slither-action@v0.3.0 + id: slither + with: + node-version: 16 + sarif: results.sarif + fail-on: high + + # WIP can safely be ignored + # gasCompare: + # runs-on: ubuntu-latest + # needs: install_dependencies + # steps: + # - uses: bissolli/gh-action-persist-workspace@v1 + # with: + # action: retrieve + # - name: Run GasCompare + # run: | + # if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + # BRANCH_NAME=$GITHUB_HEAD_REF + # else + # BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g') + # fi + # echo "Current branch is $BRANCH_NAME" + # if [ "$BRANCH_NAME" == "master" ]; then + # echo "This is the master branch. Exiting..." + # exit 0 + # fi + # CI=true npm run test + # mv ./gasReporterOutput.json /tmp/gasReporterOutput_Current.json + # git checkout master + # npm install + # CI=true npm run test + # mv ./gasReporterOutput.json /tmp/gasReporterOutput_Master.json + + # - uses: bissolli/gh-action-persist-workspace@v1 + # with: + # action: persist + + # - name: Checkout + # uses: actions/checkout@v3 + + # - uses: bissolli/gh-action-persist-workspace@v1 + # with: + # action: retrieve + + # - name: Run GasCompare + # run: | + # npm run gasCompare /tmp/gasReporterOutput_Current.json /tmp/gasReporterOutput_Master.json \ No newline at end of file diff --git a/package.json b/package.json index 0e9e374b..c67e055d 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "@primitivefi/hardhat-dodoc": "^0.1.3", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", - "circleci-pr-commenter": "^0.1.2", "fs": "^0.0.1-security", "hardhat": "^2.11.0", "hardhat-abi-exporter": "^2.3.0", diff --git a/scripts/gasCompare.js b/scripts/gasCompare.js index 019d6ca5..a45aec3e 100644 --- a/scripts/gasCompare.js +++ b/scripts/gasCompare.js @@ -1,8 +1,5 @@ const fs = require("fs"); const markdown = require('json-to-markdown-table'); -const Commenter = require('circleci-pr-commenter'); - -const commenter = new Commenter() let arguments = process.argv @@ -79,21 +76,15 @@ let gasCompare = async () => { } } } -let markdownstring = markdown(gasChangeData,coloumn); -if(gasChangeData.length!==0){ - - await commenter.createOrUpdateComment('gasCompare', markdownstring ).catch(err=>{ - console.log(markdownstring); - }) + + let markdownString = markdown(gasChangeData, coloumn); + + if (gasChangeData.length !== 0) { + // Write the markdown to a file called gasCompareOutput.json + fs.writeFileSync('gasCompareOutput.md', markdownString); + } else { + console.log("No changes found in gas Consumption"); } - -else{ - await commenter.createOrUpdateComment('gasCompare', `No changes found in gas Consumption`).catch(err=> - { - console.log(`No changes found in gas Consumption`); - }) - -} } gasCompare();