Bring up an OS from matrix in step1 , compile code in step2 depends on step1, run tests from matrix

What I want to do:

  • Bring up 1 system based on matrix.os in step ‘build’

  • Run N test cases using matrix.test-name in step ‘tests’

What I don’t want:

  • Bringing up N system that each run 1 test case which is what I get now.

  • Having to write a script to wrap all the test cases

Eventually, I want:

A. Bring up all the systems in matrix.os and matrix.python-version and matrix.cflag-options

B. Run N test cases on each of the systems in A

Can someone point me to a good example of how to do this or what I can try?

My action.yml below fails

name: Build

on:
  push:
    branches: [master]

jobs:
  build:
    name: Compile Code
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        #os: [ubuntu-latest, macOS-latest]
        #os: [ubuntu-latest, macOS-latest, windows-latest]
        #python-version: [3.6, 3.7]
        python-version: [3.6]
        cflag-options:
          - ' -DENABLE_GEOFLOW=ON -DENABLE_BEM=ON -DGET_MSMS=ON -DENABLE_FETK=ON -DENABLE_PBSAM=OFF -DENABLE_PBAM=OFF -DENABLE_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-fPIC"'
# - ' -DENABLE_GEOFLOW=OFF -DENABLE_BEM=OFF -DGET_MSMS=OFF -DENABLE_FETK=ON -DENABLE_PBSAM=OFF -DENABLE_PBAM=OFF -DENABLE_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-fPIC"'
test-name :
          - born
          - geoflow
# - actin-dimer-auto
# - actin-dimer-parallel
# - alkanes
# - FKBP
# - hca-bind
# - ion-pmf
# - ion-protein
# - ionize
# - pka-lig
# - point-pmf
# - solv
# - protein-rn
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Prereqs
        uses: mstksg/get-package@v1
        with:
          apt-get: bison flex swig libreadline-dev
      - name: Build and Install
        run: |
          echo "==================================== WHERE AM I ==================================== "
          pwd
          # Make the install directory
          mkdir -p $HOME/local

          echo "==================================== VERSIONS: ==================================== "
          echo "==================================== PYTHON VERSION"
          python -c "import sys; print(sys.version)"
          echo "==================================== CMAKE VERSION"
          cmake --version
          echo "==================================== Gcc VERSION"
          gcc --version
          echo "==================================== G++ VERSION"
          g++ --version
          echo "==================================== SWIG VERSION"
          swig -version

          echo "==================================== Install Python requirements ==================================== "
          pip3 install -U pip
          pip3 install -U pytest
          pip3 install -U virtualenv
          pip3 install -U numpy
          pip3 install -r pdb2pqr/requirements.txt

          # Just build APBS for now
          echo "==================================== PWD FOR TOP DIR ==================================== "
          pwd

          echo "==================================== Get External SubModules ==================================== "
          git submodule init
          git submodule update
          mkdir build
          cd build
          cmake ..
          make VERBOSE=1
          cd ..

          cd apbs
          echo "==================================== PWD FOR APBS src==================================== "
          pwd
          mkdir build
          cd build
          echo "==================================== BUILD DIR ==================================== "
          pwd

          echo "==================================== RUN CMAKE ==================================== "
          pwd
          cmake ${{ matrix.cflag-options }} -DCMAKE_INSTALL_PREFIX:PATH=$HOME/local .. || exit 1

          echo "==================================== RUN MAKE ==================================== "
          pwd
          VERBOSE=1 make -j 1 install
  tests:
    name: Test Code
    needs: build
    runs-on: ${{ matrix.os }}
    steps:
      - name: Run the tests
        run: |
          # Assume we are in the User's home directory where the top of the repository
          echo "==================================== LOOK for APBS binary ==================================== "
          #pwd
          #echo find $HOME -type f -name apbs
          #find $HOME -type f -name apbs
          echo find $HOME -type f -name libmaloc.so
          find $HOME -type f -name libmaloc\*
          echo cd apbs/tests
          cd apbs/tests
          echo pwd
          pwd
          echo ls
          ls
          echo bash run_travis_test.sh $HOME/local/bin ${{ matrix.test-name }}
          bash run_travis_test.sh $HOME/local/bin ${{ matrix.test-name }}

Hello @intendo 

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the Github Actions board. No action is needed on your part; you can continue the conversation as normal here.

Let me know if you have any other questions or if I can help with anything else.

Greatly appreciated,

-MChevy422

@intendo ,

When configuring a workflow, you need to understand:
1) You must and only can specify runner on job-level, and each job runs on only one runner.

2) The runner is assigned when the job startup, and you can’t change the runner during the job is running via a step in this job.

3) You can’t define matrix on workflow-level, you can only define matrix on each job.

4) Each job in the matrix can only take one value from the array of each configuration option, can’t take multiple values from a same configuration option.

5) The matrix configuration options defined on a job can’t available to another job. If you want other jobs can execute the same configuration options, you need to directly define the same matrix on those jobs.

In summary, I think your requests are difficult to achieve.
More details, you can reference the docs about Workflow syntax for GitHub Actions.

1 Like