name: ci

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: bacon-ls

jobs:
  # security-audit:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v4
  #     - uses: rustsec/audit-check@v2
  #       with:
  #         token: ${{ secrets.ACTIONS_TOKEN }}
  build-linux:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: Swatinem/rust-cache@v2
    - run: cargo test
      env:
        RUST_LOG: debug,globset=warn
    - run: cargo fmt --all -- --check
    - run: cargo clippy --all-targets
    - uses: actions/setup-node@v4
      with:
        node-version-file: package.json
    - run: npm ci
    - run: npm run lint
    # vscode requires an X Server
    # - name: npm test
      # run: xvfb-run npm test
    # ensure package can be built when package.json changes
    - name: npx vsce package
      run: npx vsce package
  build-mac:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v4
    - uses: Swatinem/rust-cache@v2
    - run: cargo test
      env:
        RUST_LOG: debug,globset=warn
        RUST_BACKTRACE: 1
  build-windows:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v4
    - uses: Swatinem/rust-cache@v2
    - run: cargo test
      env:
        RUST_LOG: debug,globset=warn
        RUST_BACKTRACE: 1
