name: Test Fuel Contract

on:
  pull_request:
    paths:
      - target_chains/fuel/**
  push:
    branches:
      - main

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: target_chains/fuel/contracts/
    steps:
      - uses: actions/checkout@v2
        with:
          cache-workspaces: "target_chains/fuel/contracts -> target"
      - name: Install Fuel toolchain
        run: |
          curl https://install.fuel.network | sh
          echo "$HOME/.fuelup/bin" >> $GITHUB_PATH
      - name: Build with Forc
        run: forc build --verbose
      - name: Run tests with Forc
        run: forc test --verbose
      - name: Rust add wasm32-unknown-unknown target
        run: rustup target add wasm32-unknown-unknown
      - name: Build
        run: cargo build --verbose
      - name: Run tests
        run: cargo test --verbose
