Skip to content

Migrate Oracle contracts to GitHub actions #33

Migrate Oracle contracts to GitHub actions

Migrate Oracle contracts to GitHub actions #33

Workflow file for this run

name: CI
on: [push , pull_request]
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/[email protected]
# id: slither
# with:
# node-version: 16
# sarif: results.sarif
# fail-on: high
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
# npm run test
# mv ./gasReporterOutput.json /tmp/gasReporterOutput_Current.json
# git checkout master
# npm run test
# npm install
# mv ./gasReporterOutput.json /tmp/gasReporterOutput_Master.json
# git reset --hard
# git fetch --all
# git checkout $BRANCH_NAME # Checkout back to the original branch
# npm run gasCompare /tmp/gasReporterOutput_Current.json /tmp/gasReporterOutput_Master.json
- name: Run GasCompare
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
BRANCH_NAME=${{ github.event.pull_request.head.ref }}
REPO_NAME=${{ github.event.pull_request.head.repo.full_name }}
PR_NUMBER=${{ github.event.pull_request.number }}
else
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
REPO_NAME=$GITHUB_REPOSITORY
PR_NUMBER=""
fi
echo "Current branch is $BRANCH_NAME from repo $REPO_NAME"
if [ "$BRANCH_NAME" == "master" ]; then
echo "This is the master branch. Exiting..."
exit 0
fi
npm run test
mv ./gasReporterOutput.json /tmp/gasReporterOutput_Current.json
git checkout master
npm install
npm run test
mv ./gasReporterOutput.json /tmp/gasReporterOutput_Master.json
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
# Fetch and checkout the branch from the forked repository
git fetch origin pull/$PR_NUMBER/head:$BRANCH_NAME
git checkout $BRANCH_NAME
else
git checkout $BRANCH_NAME
fi
npm run gasCompare /tmp/gasReporterOutput_Current.json /tmp/gasReporterOutput_Master.json