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

78 test installation using workflows #79

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5344ced
Merge pull request #6 from MetOffice/main
bencopl Dec 15, 2022
f409633
Several new workflows and a system test [untested] (#78)
bencopl Dec 20, 2022
4645bf0
Correcting artifact download path & some cosmetic changes (#78)
bencopl Jan 5, 2023
0454320
Adding changes to branch 78 (#10)
bencopl Feb 20, 2023
9741b0c
Removing redundant install workflow (#78)
bencopl Feb 20, 2023
277b406
Merge branch 'main' into 78-test-installation-using-workflows
bencopl Feb 21, 2023
6082fea
Removing vscode folder from commit and cutting readme changes for use…
bencopl Feb 21, 2023
a94b3fa
Adding some debugging flags to mpifort step (#78)
bencopl Feb 21, 2023
0890115
Adding copyright banners to system tests (#78)
bencopl Feb 21, 2023
6cbc632
Printing additional info in system.yml for debugging (#78)
bencopl Feb 21, 2023
7661034
ÂAdding -lprofiler to list of mpifort flags (#78)
bencopl Feb 21, 2023
3813c47
Changing where ld path is updated in system.yml (#78)
bencopl Feb 21, 2023
dcf1169
Changing upload artifact action version and adding fexceptions flag t…
bencopl Feb 21, 2023
efeff73
Adding mpifort -show flag to see full command (#78)
bencopl Feb 21, 2023
a2d9963
Adding lstdc++ flag to mpifort command (#78)
bencopl Feb 21, 2023
a011a8c
Seeing if an install of libstdc++ ought to be done first (#78)
bencopl Feb 21, 2023
05583ad
Un-doing previous changes (#78)
bencopl Feb 21, 2023
66287d0
Tidying up a couple of blank lines (#78)
bencopl Feb 21, 2023
38ee934
Putting compiler matrix into an environment variable (#78)
bencopl Feb 22, 2023
d3f7e79
Setting up compiler matrix from job output (#80)
bencopl Feb 22, 2023
f0c5f77
Added dummy step to setup job in top-level workflow (#78)
bencopl Feb 22, 2023
9a11305
Typo in setup job
bencopl Feb 22, 2023
a9b9eb1
Changing initial matrix declaration to be in json format (#78)
bencopl Feb 22, 2023
de95d68
Removing step from setup job and setting output straight from env var…
bencopl Feb 22, 2023
898fe0c
Testing new row of compilers to check workflow works as intended (#78)
bencopl Feb 22, 2023
52fa939
Finishing touches to system.yml and deploy test (#78)
bencopl Feb 22, 2023
aa12a1c
Moving system notes to Profiler.md (#78)
bencopl Feb 22, 2023
f988b60
Updating documentation workflow (#78)
bencopl Feb 22, 2023
d153c34
Slight alteration to f90 sys test write statement (#78)
bencopl Feb 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 86 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,113 @@
name: Build and Test
name: Build and install

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_call:
inputs:
# A host of inputs to this workflow are provided that allow various CMake
# options to be changed.
c_compiler:
description:
'Provide a C compiler to use for the DCMAKE_C_COMPILER CMake option.'
required: true
type: string
cpp_compiler:
description:
'Provide a C++ compiler to use for the DCMAKE_CXX_COMPILER CMake option.'
required: true
type: string
fortran_compiler:
description:
'Provide a Fortran compiler to use for the DCMAKE_Fortran_COMPILER CMake option.'
required: true
type: string
shared_libs:
description:
'Determines the DBUILD_SHARED_LIBS option.'
required: true
type: boolean

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [
{c: gcc-10, cpp: g++-10, fortran: gfortran-10},
{c: clang-12, cpp: clang++-12, fortran: gfortran-10}
]

name: "${{ inputs.shared_libs && 'dynamic' || 'static' }}"
# The CMake configure and build commands are platform agnostic and should
# work equally well on Windows or Mac. You can convert this to a matrix
# build if you need cross-platform coverage. See:
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install libomp-devel
- name: Install libomp-devel and mpich
# Ensure that the OpenMP development libraries are installed.
run: |
sudo apt-get update
sudo apt-get install -y libomp-12-dev
sudo apt update
sudo apt install -y libomp-12-dev
sudo apt install -y mpich

- name: Setup
# The name of the build directory and uploaded artifact depends on both
# the compiler and the 'shared_libs' input.
run: |
if [[ ${{ inputs.shared_libs }} ]]
then
LINKING=dynamic
else
LINKING=static
fi
COMPILER=${{ inputs.cpp_compiler }}
echo "BUILD_NAME=${COMPILER:0:-3}_${LINKING}_build" >> $GITHUB_ENV
echo "INSTALL_NAME=${COMPILER:0:-3}_${LINKING}_install" >> $GITHUB_ENV

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only
# required if you are using a single-configuration generator such as
# make. See:
# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DCMAKE_C_COMPILER=${{ matrix.compiler.c }}
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }}
-DCMAKE_Fortran_COMPILER=${{ matrix.compiler.fortran }}
cmake -B ${{ github.workspace }}/${{ env.BUILD_NAME }}
-DCMAKE_INSTALL_PREFIX="/home/runner/work/${{ env.INSTALL_NAME }}"
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
-DCMAKE_C_COMPILER=${{ inputs.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ inputs.cpp_compiler }}
-DCMAKE_Fortran_COMPILER=${{ inputs.fortran_compiler }}
-DBUILD_TESTS=ON
-DBUILD_FORTRAN_TESTS=OFF
-DINCLUDE_GTEST=ON
-DWARNINGS_AS_ERRORS=ON
-DUSE_SANITIZERS=ON
-DUSE_SANITIZERS=OFF
-DENABLE_DOXYGEN=OFF
-DBUILD_SHARED_LIBS=${{ inputs.shared_libs }}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{ github.workspace }}/${{ env.BUILD_NAME }} --config ${{ env.BUILD_TYPE }}

# Run tests on a single thread
- name: "Test (1 thread)"
env:
OMP_NUM_THREADS: 1
working-directory: ${{github.workspace}}/build
run: ctest -VV -C ${{env.BUILD_TYPE}}
- name: Perform installation
# Install the public headers and profiler libraries.
run: cmake --install ${{ github.workspace }}/${{ env.BUILD_NAME }} --config ${{ env.BUILD_TYPE }}

- name: Tar build & install files
# Massively speeds up the subsequent artifact uploads.
run: |
tar czvf ${{ env.BUILD_NAME }}.tar.gz ${{ github.workspace }}/${{ env.BUILD_NAME }}/*
tar czvf ${{ env.INSTALL_NAME }}.tar.gz /home/runner/work/${{ env.INSTALL_NAME }}/*

# Run tests on 4 threads
- name: "Test (4 threads)"
env:
OMP_NUM_THREADS: 4
working-directory: ${{github.workspace}}/build
run: ctest -VV -C ${{env.BUILD_TYPE}}
- name: Upload build artifact
uses: actions/[email protected]
with:
name: ${{ env.BUILD_NAME }}
path: ${{ env.BUILD_NAME }}.tar.gz
retention-days: 1
if-no-files-found: error

- name: Upload install artifact
uses: actions/[email protected]
with:
name: ${{ env.INSTALL_NAME }}
path: ${{ env.INSTALL_NAME }}.tar.gz
retention-days: 1
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
paths:
- 'src/**.h'
- 'src/**.cpp'
- 'tests/**'
- 'tests/unit_tests/**'
- '.github/workflows/coverage.yml'

env:
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/deploy_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy all tests

on:
workflow_dispatch:
push:
branches: [ main ]
paths-ignore:
- '.github/workflows/documentation.yml'
- '.github/workflows/coverage.yml'
pull_request:
branches: [ main ]
paths-ignore:
- '.github/workflows/documentation.yml'
- '.github/workflows/coverage.yml'

env:
# Define the compiler matrix here as it is regularly reused. Additional
# configurations can easily be added by adding a new row of entries that
# follow the same format as shown.
COMPILER_MATRIX: >
[ {"c": "gcc-10", "cpp": "g++-10", "fortran": "gfortran-10" },
{"c": "clang-12", "cpp": "clang++-12", "fortran": "gfortran-10" } ]

jobs:

setup:
runs-on: ubuntu-20.04
outputs:
compiler_matrix: ${{ env.COMPILER_MATRIX }}
steps:
- name: Setup
run: echo "Adding matrix to this jobs output for use in subsequent jobs"

build-install:
# The reusable build workflow is called for each compiler configuration
# and for both static and dynamic linking.
name: "Build/install: ${{ matrix.compiler.cpp }}"
needs: [ setup ]
strategy:
matrix:
compiler: ${{ fromJSON(needs.setup.outputs.compiler_matrix) }}
shared_libs: [ true, false ]
uses: ./.github/workflows/build.yml
with:
c_compiler: ${{ matrix.compiler.c }}
cpp_compiler: ${{ matrix.compiler.cpp }}
fortran_compiler: ${{ matrix.compiler.fortran }}
shared_libs: ${{ matrix.shared_libs }}

unit_test:
# Unit tests ran for the same compiler configurations as before, but only
# the dynamic build is tested.
name: "Unit test: ${{ matrix.compiler.cpp }}"
needs: [ setup, build-install ]
strategy:
matrix:
compiler: ${{ fromJSON(needs.setup.outputs.compiler_matrix) }}
uses: ./.github/workflows/unit.yml
with:
cpp_compiler: ${{ matrix.compiler.cpp }}

system_test:
# System test is compiled and ran for all compiler configurations, using
# both the static and dynamic artifacts.
name: "System test: ${{ matrix.compiler.cpp }}"
needs: [ setup, build-install ]
strategy:
matrix:
compiler: ${{ fromJSON(needs.setup.outputs.compiler_matrix) }}
shared_libs: [ true, false ]
uses: ./.github/workflows/system.yml
with:
cpp_compiler: ${{ matrix.compiler.cpp }}
fortran_compiler: ${{ matrix.compiler.fortran }}
shared_libs: ${{ matrix.shared_libs}}
13 changes: 7 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ jobs:

- name: Update Doxygen Pages
run: |
mkdir -p ${{github.workspace}}/docs/documentation
cp -rf ${{github.workspace}}/build/html/* ${{github.workspace}}/docs/documentation/.
mkdir -p ${{ github.workspace }}/docs/documentation
cp -rf ${{ github.workspace }}/build/html/* ${{ github.workspace }}/docs/documentation/.
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global user.email 'github-actions[bot]'
git remote update
git add --force docs/documentation
git stash
git remote update
git checkout gh-pages
rm -rf docs/documentation
git rm -r --ignore-unmatch docs/documentation/
rm -rf docs/documentation/
git stash pop
git reset
git add --force docs/documentation
git commit -a --allow-empty -m "Update Doxygen documentation"
git commit --allow-empty -m "Update Doxygen documentation"
git push
81 changes: 81 additions & 0 deletions .github/workflows/system.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Run system tests

on:
workflow_call:
inputs:
cpp_compiler:
description:
'Name of the C++ compiler used to build and install beforehand.'
required: true
type: string
fortran_compiler:
description:
'Name of the fortran compiler used to build and install.'
required: true
type: string
shared_libs:
description:
'Determines whether the static or dynamic binaries are downloaded.'
required: true
type: boolean

jobs:
run:
name: "${{ inputs.shared_libs && 'dynamic' || 'static' }}"
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3

- name: Install libomp and mpich
run: |
sudo apt update
sudo apt install -y libomp-12-dev
sudo apt install -y mpich

- name: Prepare to download correct artifact
run: |
if [[ ${{ inputs.shared_libs }} ]]
then
LINKING=dynamic
else
LINKING=static
fi
COMPILER=${{ inputs.cpp_compiler }}
echo "INSTALL_NAME=${COMPILER:0:-3}_${LINKING}_install" >> $GITHUB_ENV

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.INSTALL_NAME }}

- name: Unzip and setup PROF variable
run: |
tar xzvf ${{ env.INSTALL_NAME }}.tar.gz -C /
PROF="/home/runner/work/${{ env.INSTALL_NAME }}"
ls -al $PROF
echo "PROF=$PROF" >> $GITHUB_ENV

- name: Compile and run C++ test
# Test installed libraries using a C++ and fortran system test. Both use
# 2 OpenMP threads on 4 MPI ranks.
env:
OMP_NUM_THREADS: 2
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PROF/lib
mpicxx -o systest -cxx=${{ inputs.cpp_compiler }} -std=c++17 \
-L${PROF}/lib -I${PROF}/include ./tests/system_tests/system_test.cpp \
-lprofiler -fopenmp
mpirun -n 4 ./systest

- name: Compile and run Fortran test
env:
OMP_NUM_THREADS: 2
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PROF/lib
mpifort -fc=${{ inputs.fortran_compiler }} -o test -pedantic \
-L${PROF}/lib -I${PROF}/include ./tests/system_tests/system_test.f90 \
-lprofiler_f -lprofiler_c -lprofiler -fopenmp -lstdc++
mpirun -n 4 ./test
47 changes: 47 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Run unit tests

on:
workflow_call:
inputs:
cpp_compiler:
description:
'Name of the C++ compiler used to build beforehand.'
required: true
type: string

env:
BUILD_TYPE: Debug

jobs:
run:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Setup
# This time only the compiler matters, unit tests are only ran for the
# dynamic build directories.
run: |
COMPILER=${{ inputs.cpp_compiler }}
echo "BUILD_NAME=${COMPILER:0:-3}_dynamic_build" >> $GITHUB_ENV

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.BUILD_NAME }}

- name: Unzip
run: tar xzvf ${{ env.BUILD_NAME }}.tar.gz -C /

- name: Run Unit Tests (1 thread)
# Do single and multi threaded unit test runs
env:
OMP_NUM_THREADS: 1
working-directory: ${{ github.workspace }}/${{ env.BUILD_NAME}}
run: ctest -VV -C ${{ env.BUILD_TYPE }}

- name: Run Unit Tests (4 threads)
env:
OMP_NUM_THREADS: 4
working-directory: ${{ github.workspace}}/${{ env.BUILD_NAME}}
run: ctest -VV -C ${{ env.BUILD_TYPE }}
Loading