Skip to content

Merge pull request #856 from oceanprotocol/feature/deploy_vestings_B_… #1079

Merge pull request #856 from oceanprotocol/feature/deploy_vestings_B_…

Merge pull request #856 from oceanprotocol/feature/deploy_vestings_B_… #1079

Workflow file for this run

name: 'CI'
on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
- run: npm ci
- run: npm install -g solhint
- run: solhint contracts/**/*.sol
tests_full:
runs-on: ubuntu-latest
steps:
- name: "step-log-ref"
run: |
echo "[C] github.ref: ${{github.ref}}"
- name: "step-log-event_name "
run: |
echo "[C] github.event_name : ${{github.event_name }}"
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
- run: npm ci
- name: Run Hardhat
run: |
npx hardhat node &
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Run tests
run: npm run test:full:cover
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/
slither:
name: Slither Analysis
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run Slither
uses: crytic/slither-action@v0.1.0
continue-on-error: true
id: slither
with:
node-version: 16
sarif: results.sarif
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}`
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
coverage:
runs-on: ubuntu-latest
needs: [tests_full]
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage
path: coverage/
- uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
if: "${{ env.CC_TEST_REPORTER_ID != '' }}"
with:
coverageLocations: |
${{ github.workspace }}/coverage/lcov.info:lcov
check_deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
# Env var expansion workaround
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set ADDRESS_FILE
run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV
- name: Build local docker file
run: docker build -t 'oceanprotocol/ocean-contracts:test' .
- name: Checkout Barge
uses: actions/checkout@v3
with:
repository: 'oceanprotocol/barge'
path: 'barge'
- name: Run Ganache with Barge
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: test
- run: npm ci
- name: Wait for contracts deployment
working-directory: ${{ github.workspace }}/barge
run: |
for i in $(seq 1 250); do
sleep 5
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] && break
done
ls -la "$HOME/.ocean/ocean-contracts/artifacts/"
- run: cat ${HOME}/.ocean/ocean-contracts/artifacts/address.json
- run: node scripts/check_deployment.js
- name: docker logs
run: docker logs ocean_ocean-contracts_1
if: ${{ failure() }}
publish-npm:
needs: [lint, tests_full,check_deployment]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- name: Delete useless files
run: rm -rf ./artifacts/build-info/*
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
publish-pypi:
runs-on: ubuntu-latest
needs: [lint, tests_full,check_deployment]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: "step-log-ref"
run: |
echo "[C] github.ref: ${{github.ref}}"
- name: "step-log-event_name "
run: |
echo "[C] github.event_name : ${{github.event_name }}"
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
- run: npm ci
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- name: Delete useless files
run: rm -rf ./artifacts/build-info/*
- name: Copy artifacts to root folder
run: find ./artifacts/contracts -name '*.json' -exec mv '{}' './artifacts/' ';'
- name: Remove folders from artifacts
run: find ./artifacts -maxdepth 1 -mindepth 1 -type d -exec rm -rf '{}' \;
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Create __init__.py files
run: |
find artifacts -type d -exec touch '{}'/__init__.py ';'
find addresses -type d -exec touch '{}'/__init__.py ';'
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}