Skip to content

Commit

Permalink
Reusable build and test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-el-sayed committed Feb 5, 2024
1 parent 48a02dc commit 4229403
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 31 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-and-test-master-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and test

on:
# push:
# branches:
# - master
# - "release/v[0-9].[0-9].[0-9]"
pull_request:
types:
- opened # triggers build when opened
- synchronize # triggers build when commits are pushed to HEAD
branches:
#- master
#- "release/v[0-9].[0-9].[0-9]"
- "feature/**"
# Manual trigger
workflow_dispatch:

jobs:

build:

strategy:
fail-fast: false
matrix:
platform:
# - ubuntu-latest
- macos-latest
#- macos-13-xlarge
build_type:
- Release
- Debug
#- DebugWithRelInfo

uses: Deltares/MeshKernel/.github/workflows/build-and-test-workflow.yml@${GITHUB_REF##*/}
with:
platform: ${{ matrix.platform }}
build_type: ${{ matrix.build_type }}
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
name: Build and test on macos
name: Build and test workflow

on:
push:
branches:
- master
- "release/v[0-9].[0-9].[0-9]"
pull_request:
types:
- opened # triggers build when opened
- synchronize # triggers build when commits are pushed to HEAD
branches:
- master
- "release/v[0-9].[0-9].[0-9]"
- "feature/**"
# Manual trigger
workflow_dispatch:
workflow_call:

inputs:
platform:
required: true
type: string
build_type:
required: true
type: string

jobs:

build:

# Build strategy
strategy:
fail-fast: false
matrix:
platform:
# - ubuntu-latest
- macos-latest
- macos-13-xlarge
build_type:
- 'Release'
#- 'Debug'
#- 'DebugWithRelInfo '

# Build platform
runs-on: ${{ matrix.platform }}
runs-on: ${{ inputs.platform }}

name: ${{ matrix.platform }}-${{ matrix.build_type }}
name: ${{ inputs.platform }}-${{ inputs.build_type }}

# The default compiler on macos is clang, switch to gcc 11. Specifying the version is necessary.
# It seems like gcc and g++ are symbolic links to the default clang and clang++ compilers, respectively.
Expand Down Expand Up @@ -89,7 +75,7 @@ jobs:
pwsh ${{ github.workspace }}/scripts/install_netcdf_static.ps1
-WorkDir ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/work
-InstallDir ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install
-BuildType '${{ matrix.build_type }}'
-BuildType '${{ inputs.build_type }}'
-ParallelJobs 10
# Step: Cache user-provided dependencies, executes only if no cache restored
Expand All @@ -106,17 +92,17 @@ jobs:
cmake
-S ${{ github.workspace }}
-B ${{ steps.paths.outputs.build_dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }}
-DCMAKE_PREFIX_PATH=${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c
-DCMAKE_INSTALL_PREFIX=${{ steps.paths.outputs.install_dir }}
# Step: CMake build
- name: Build
run: cmake --build ${{ steps.paths.outputs.build_dir }} --config ${{ matrix.build_type }} -j
run: cmake --build ${{ steps.paths.outputs.build_dir }} --config ${{ inputs.build_type }} -j

# Step: Test
# Works if runner.os == 'Linux' or runner.os == 'macOS'
# if runner.os == 'Windows', /matrix.build_type needs to be inserted before /tests
# if runner.os == 'Windows', /inputs.build_type needs to be inserted before /tests
- name: Test
run: |
echo -e "\n*************** MeshKernel Tests ***************\n"
Expand All @@ -133,6 +119,6 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: meshkernel-${{ matrix.platform }}-${{ matrix.build_type }}
name: meshkernel-${{ inputs.platform }}-${{ inputs.build_type }}
path: ${{ steps.paths.outputs.install_dir }}
if-no-files-found: error

0 comments on commit 4229403

Please sign in to comment.