name: "Test riscv64  "

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - main

jobs:
  basic-test:
    runs-on: ubuntu-latest
    container:
      image: asterinas/asterinas:0.17.0-20260114
      options: --device=/dev/kvm --privileged
      volumes:
        # Map the following directories on the host into the container so that
        # the container can remove them to save some precious disk space (~16GB),
        # which is quite limited on free-tier Github runners.
        - /usr/lib/google-cloud-sdk:/usr/lib/google-cloud-sdk
        - /usr/local/lib/android:/usr/local/lib/android
        - /usr/share/dotnet:/usr/share/dotnet
    strategy:
      matrix:
        id: ['lint', 'compile', 'usermode_test', 'ktest']
      fail-fast: false
    steps:
      - name: Free disk space
        # Remove unused packages from the host to save disk space.
        run: rm -rf /usr/lib/google-cloud-sdk/* /usr/local/lib/android/* /usr/share/dotnet/*
      - uses: actions/checkout@v4
      - name: Run basic tests
        uses: ./.github/actions/test
        with:
          auto_test: 'general'
          arch: 'riscv64'

  integration-test:
    runs-on: ubuntu-latest
    container:
      image: asterinas/asterinas:0.17.0-20260114
      options: --device=/dev/kvm --privileged
      volumes:
        # Map the following directories on the host into the container so that
        # the container can remove them to save some precious disk space (~16GB),
        # which is quite limited on free-tier Github runners.
        - /usr/lib/google-cloud-sdk:/usr/lib/google-cloud-sdk
        - /usr/local/lib/android:/usr/local/lib/android
        - /usr/share/dotnet:/usr/share/dotnet
    strategy:
      matrix:
        include:
          - test_id: 'boot-debug-smp4'
            smp: 4

          - test_id: 'boot-release'
            release: true

          - test_id: 'syscall-release'
            release: true

          - test_id: 'syscall-release-smp4'
            release: true
            smp: 4
      fail-fast: false
    steps:
      - name: Free disk space
        # Remove unused packages from the host to save disk space.
        run: rm -rf /usr/lib/google-cloud-sdk/* /usr/local/lib/android/* /usr/share/dotnet/*
      - uses: actions/checkout@v4
      - name: Run integration tests ${{ (startsWith(matrix.test_id, 'syscall') && 'with LTP') || '' }}
        uses: ./.github/actions/test
        with:
          auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') || 'syscall' }}
          release: ${{ !contains(matrix.release, 'false') }}
          arch: 'riscv64'
          syscall_test_suite: 'ltp'
