name: qemu port

on:
  push:
  pull_request:
    paths:
      - '.github/workflows/*.yml'
      - 'tools/**'
      - 'py/**'
      - 'extmod/**'
      - 'shared/**'
      - 'lib/**'
      - 'drivers/**'
      - 'ports/qemu/**'
      - 'tests/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build_and_test_arm:
    strategy:
      fail-fast: false
      matrix:
        ci_func:  # names are functions in ci.sh
          - bigendian
          - sabrelite
          - thumb
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install packages
      run: source tools/ci.sh && ci_qemu_setup_arm
    - name: Build and run test suite ci_qemu_build_arm_${{ matrix.ci_func }}
      run: source tools/ci.sh && ci_qemu_build_arm_${{ matrix.ci_func }}
    - name: Print failures
      if: failure()
      run: tests/run-tests.py --print-failures

  build_and_test_rv32:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install packages
      run: source tools/ci.sh && ci_qemu_setup_rv32
    - name: Build and run test suite
      run: source tools/ci.sh && ci_qemu_build_rv32
    - name: Print failures
      if: failure()
      run: tests/run-tests.py --print-failures
