improved github workflows #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit tests | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Install MPI | |
run: | | |
sudo apt install -y libmpich-dev | |
- name: Setup spack | |
uses: spack/setup-spack@v2 | |
with: | |
ref: develop | |
color: true | |
path: spack | |
- name: Find external packages | |
run: | | |
spack -e tests external find --not-buildable cmake | |
spack -e tests external find --not-buildable perl | |
spack -e tests external find --not-buildable m4 | |
spack -e tests external find --not-buildable libtool | |
spack -e tests external find --not-buildable autoconf | |
spack -e tests external find --not-buildable automake | |
spack -e tests external find --not-buildable pkg-config | |
spack -e tests external find --not-buildable gmake | |
spack -e tests external find --not-buildable mpich | |
- name: Add mochi-spack-packages | |
run: | | |
git clone https://github.com/mochi-hpc/mochi-spack-packages | |
spack -e tests repo add mochi-spack-packages | |
- name: Concretizing spack environment | |
run: | | |
spack -e tests concretize -f | |
- name: Create cache key from environment file | |
run: | | |
jq --sort-keys 'del(.spack.commit) | del(.roots)' tests/spack.lock > key.json | |
- name: Restore Spack cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.spack-ci | |
key: spack-${{ hashFiles('key.json') }} | |
- name: Install spack environment | |
run: | | |
spack -e tests install | |
- name: Show spack-installed packages for debugging | |
run: | | |
spack -e tests find -dlv | |
- name: Build code and run unit tests | |
run: | | |
eval `spack env activate --sh tests` | |
mkdir build | |
cd build | |
cmake .. -DENABLE_TESTS=ON \ | |
-DENABLE_EXAMPLES=ON \ | |
-DENABLE_BEDROCK=ON \ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo | |
make | |
ctest --output-on-failure |