name: Lint

on:
  push:
  workflow_dispatch:

jobs:
  lint_go:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Go
        uses: actions/setup-go@v3

      - name: Check Go code formatting
        run: yarn fmt:go

  lint_sol:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup NodeJs
        uses: actions/setup-node@v2
        with:
          node-version: 14.x

      - name: Cache dependencies
        id: cache
        uses: actions/cache@v2
        with:
          path: ./node_modules
          key: modules-${{ hashFiles('yarn.lock') }}

      - name: Install yarn dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: rm -rf node_modules && yarn install --frozen-lockfile

      - name: Check Solidity code formatting
        run: yarn fmt:sol

      - name: Run solhint
        run: yarn lint:sol
