name: Run Test on Demand

on:
  workflow_dispatch:

jobs:
  build_and_test:
    runs-on: ubuntu-24.04
    steps:
    - name: Checkout the repo
      uses: actions/checkout@v5

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v3

    - name: Set up extension
      run: |
        echo "${{ secrets.extension }}" > extension.sh
        chmod 700 extension.sh
      shell: bash

    - name: Build base image
      run: script -e -c "./app.sh build base test"

    - name: Build sample image
      run: script -e -c "./app.sh build emulator test 11.0"

    - name: Run unit-test
      run: script -e -c "./app.sh test emulator test 11.0 && sudo mv tmp/* ."

    - name: Publish test result
      run: bash <(curl -s https://codecov.io/bash)
