kleros/kleros-v2

View on GitHub
.github/workflows/contracts-testing.yml

Summary

Maintainability
Test Coverage
name: Contracts Testing

on:
  workflow_dispatch:
  merge_group:
  push:
    branches:
      - master
      - dev
    paths-ignore:
      - "kleros-sdk/**"
      - "services/**"
      - "subgraph/**"
      - "web/**"
  pull_request:
    branches:
      - "*"
      
permissions:  # added using https://github.com/step-security/secure-workflows
  contents: read

jobs:
  contracts-testing:
    runs-on: ubuntu-latest
    steps:
    - name: Harden Runner
      uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
      with:
        disable-sudo: true
        egress-policy: block
        allowed-endpoints: >
          binaries.soliditylang.org:443
          classic.yarnpkg.com:443
          github.com:443
          nightly.yarnpkg.com:443
          nodejs.org:443
          objects.githubusercontent.com:443
          registry.yarnpkg.com:443
          registry.npmjs.org:443
          54.185.253.63:443

    - name: Setup Node.js environment
      uses: actions/setup-node@2a017f350dbf6c4b6bb4508cc83809719115162e
      with:
        node-version: 18.x   
        
    - uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
    
    - name: Cache node modules
      uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
      env:
        cache-name: cache-node-modules
      with:
        path: | 
          ~/.npm
          **/node_modules
        key: ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
        restore-keys: |
          ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
          
    #- name: Install parent dependencies
    #  run: |
    #    echo "current dir: $PWD"
    #    yarn install
             
    - name: Install contracts dependencies
      run: |
        yarn workspace @kleros/kleros-v2-contracts install
      
    - name: Compile
      run: |
        yarn hardhat compile
      working-directory: contracts
      
    - name: Test with coverage
      run: |         
        yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\" --show-stack-traces
      working-directory: contracts

    - name: Upload a build artifact
      uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05
      with:    
        name: code-coverage-report    
        path: contracts/coverage