name: Windows

on:
  pull_request:
  push:
    branches: main

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        arch: [x64, x86]
        vs_runtime: [MT, MD]

    runs-on: windows-latest

    concurrency:
        group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Windows-${{ matrix.arch }}-${{ matrix.vs_runtime }}
        cancel-in-progress: true

    steps:
      - uses: actions/checkout@v1
      - uses: xmake-io/github-action-setup-xmake@v1
        with:
          xmake-version: branch@master

      - name: Configure Pagefile
        uses: al-cheb/configure-pagefile-action@v1.2
        with:
          minimum-size: 8GB
          maximum-size: 32GB
          disk-root: "D:"

      - name: Prepare XMake
        run: xmake f -p windows -a ${{ matrix.arch }} --vs_runtime=${{ matrix.vs_runtime }} -y

      - name: Build
        run: xmake

      - name: Test
        run: xmake test
