name: CI Clarinet

# Controls when the action will run.
on:
  push:

concurrency:
  group: 'ci-${{ github.ref }}'
  cancel-in-progress: true

jobs:
  check:
    name: check - ${{ github.ref_name }}
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - uses: sergeysova/jq-action@v2
      - uses: wei/curl@v1
      - name: Install Deps
        run: |
          cd clarity && ./scripts/clarinet_manager.sh install
      - name: "Check contract"
        uses: docker://hirosystems/clarinet:1.7.1
        with:
          entrypoint: "bash"
          args: -c "cd clarity && clarinet check"
  test:
    name: test - ${{ github.ref_name }}
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - uses: sergeysova/jq-action@v2
      - uses: wei/curl@v1
      - name: Install Deps
        run: |
          cd clarity && ./scripts/clarinet_manager.sh install
      - name: "Set CI env"
        run: |
          echo "ci_env=$(bash <(curl -s https://codecov.io/env))" >> $GITHUB_ENV
      - name: "Execute test suite"
        uses: docker://hirosystems/clarinet:1.7.1
        with:
          entrypoint: "bash"
          #args: -c "cd clarity && clarinet test --coverage && curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && ./codecov -t ${{ secrets.CODECOV_TOKEN }} -f coverage.lcov"
          args: -c "cd clarity && clarinet test --coverage"
