# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  push:
  pull_request:
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  vezzal:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: Pulling the docker image
        run: docker pull vezzal/vezzal:v1

      - name: Start the container with the docker image
        run: docker run -id --name test_magic vezzal/vezzal:v1 bash | exit

      - name: Run the testing on the container and send the mail
        run: docker exec test_magic /vezzal/test_magic.sh "lankasaicharan123@gmail.com,tim@opencircuitdesign.com" ${{secrets.MAILING_KEY}}
  simple_build_linux:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - name: Get Dependencies
        run: |
          sudo apt-get install -y tcl-dev tk-dev libcairo-dev
      - name: Build
        run: |
          ./configure
          make database/database.h
          make -j$(nproc)
  simple_build_wasm:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - name: Get Dependencies
        run: |
          git clone https://github.com/emscripten-core/emsdk.git
          cd emsdk
          ./emsdk install latest
          ./emsdk activate latest
      - name: Build
        run: |
          source ./emsdk/emsdk_env.sh
          emconfigure ./configure --without-cairo --without-opengl --without-x --disable-readline --disable-compression --target=asmjs-unknown-emscripten
          echo "===== defs.mak ====="
          cat defs.mak
          echo "===== defs.mak ====="
          emmake make
      - name: archive wasm bundle
        uses: actions/upload-artifact@v4
        with:
          name: magic-wasm-bundle
          path: |
            ${{ github.workspace }}/magic/magic.wasm
