name: CI

on:
  push:
    branches: [main]
    paths-ignore:
      - "README.md"
      - "example/**"
  pull_request:
    branches: [main]

jobs:
  build:
    strategy:
      matrix:
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]
    runs-on: ${{ matrix.os }}

    steps:
      - name: Install V
        uses: vlang/setup-v@v1
        with:
          check-latest: true

      - name: Checkout ${{ github.event.repository.name }}
        uses: actions/checkout@v3

      - name: Install deps
        run: v install

      - name: Check if code is formatted
        run: |
          v fmt -diff .
          v fmt -verify .          

      - name: Build ${{ github.event.repository.name }}
        run: v .

      - name: Run Tests
        run: v test .