name: Windows arm64

env:
  DEBUG: 'napi:*'

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  build_and_test:
    name: stable - windows-latest - arm64 - node@18
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v3

      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version: 18
          check-latest: true
          cache: 'yarn'

      - name: 'Install dependencies'
        run: yarn install --mode=skip-build --immutable

      - name: 'Build TypeScript'
        run: yarn build

      - name: Install
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true
          target: aarch64-pc-windows-msvc

      - name: Cache cargo
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: stable-windows-arm64-node@16-cargo-cache

      - name: Check build
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: --all --bins --examples --tests --target aarch64-pc-windows-msvc -vvv

      - name: Build release target
        run: cargo build --release --target aarch64-pc-windows-msvc

      - name: Clear the cargo caches
        run: |
          cargo install cargo-cache --no-default-features --features ci-autoclean
          cargo-cache