Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github Action on macOS and clang #842

Merged
merged 14 commits into from
Aug 18, 2023
97 changes: 97 additions & 0 deletions .github/workflows/macos_clang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Clang macOS Build and Test
on: [push, pull_request, workflow_dispatch]


# Use custom shell with -l so .bash_profile is sourced
# without having to do it in manually every step
defaults:
run:
shell: bash -leo pipefail {0}

env:
cache_key: clang
CC: clang
FC: gfortran-11
CXX: clang

# The jobs are split into:
# 1. a dependency build step (setup), and
# 2. a UFS-utils build and test step (ufs_utils)
# The setup is run once and the environment is cached,
# so each subsequent build and test of UFS-utils can reuse the cached
# dependencies to save time (and compute).

jobs:
setup:
runs-on: macos-12

steps:
- name: checkout # this is to get the ci/spack.yaml file
uses: actions/checkout@v3
with:
path: ufs_utils

# Cache spack, compiler and dependencies
- name: cache-env
id: cache-env
uses: actions/cache@v3
with:
path: |
spack
~/.spack
key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }}

# Install dependencies using Spack
- name: install-dependencies-with-spack
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
git clone -c feature.manyFiles=true https://github.com/JCSDA/spack.git
source spack/share/spack/setup-env.sh
sed "s/\[intel, gcc@10:10, apple-clang@14\]/\[apple-clang@14\]/g" ufs_utils/ci/spack.yaml > spack_ci.yaml
spack env create ufs_utils-env spack_ci.yaml
spack env activate ufs_utils-env
spack external find
spack add [email protected]
spack concretize
spack install -v --fail-fast --dirty
spack clean --all

ufs_utils:
needs: setup
runs-on: macos-12

steps:
- name: checkout
uses: actions/checkout@v3
with:
path: ufs_utils
submodules: recursive

- name: cache-env
id: cache-env
uses: actions/cache@v3
with:
path: |
spack
~/.spack
key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }}

- name: build
run: |
source spack/share/spack/setup-env.sh
spack env activate ufs_utils-env
export CC=mpicc
export FC=mpif90
cd ufs_utils
mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j2 VERBOSE=1
make install

- name: ctest
run: |
source spack/share/spack/setup-env.sh
spack env activate ufs_utils-env
cd ufs_utils
cd build
ctest --verbose --rerun-failed --output-on-failure
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Cache spack, compiler and dependencies
- name: cache-env
id: cache-env
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
spack
Expand All @@ -47,7 +47,8 @@ jobs:
run: |
git clone -c feature.manyFiles=true https://github.com/JCSDA/spack.git
source spack/share/spack/setup-env.sh
spack env create ufs_utils-env ufs_utils/ci/spack.yaml
sed "s/\[intel, gcc@10:10, apple-clang@14\]/\[gcc@10:10\]/g" ufs_utils/ci/spack.yaml > spack_ci.yaml
spack env create ufs_utils-env spack_ci.yaml
spack env activate ufs_utils-env
sudo apt install cmake
spack external find
Expand All @@ -69,7 +70,7 @@ jobs:

- name: cache-env
id: cache-env
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
spack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
run: |
git clone -c feature.manyFiles=true https://github.com/NOAA-EMC/spack.git
source spack/share/spack/setup-env.sh
spack env create ufs_utils-env ufs_utils/ci/spack.yaml
sed "s/\[intel, gcc@10:10, apple-clang@14\]/\[intel\]/g" ufs_utils/ci/spack.yaml > spack_ci.yaml
spack env create ufs_utils-env spack_ci.yaml
spack env activate ufs_utils-env
spack compiler find
sudo apt install cmake
Expand Down
4 changes: 1 addition & 3 deletions ci/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
spack:
packages:
all:
compiler:
- intel
- gcc@10:10
compiler: [intel, gcc@10:10, apple-clang@14]
specs:
- [email protected]
- [email protected]
Expand Down
Loading