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

GRIDEDIT-892: Reusable build and test workflow #295

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4229403
Reusable build and test workflow
ahmad-el-sayed Feb 5, 2024
f1f4065
Renamed script
ahmad-el-sayed Feb 5, 2024
b526ff4
remove reference to branch
ahmad-el-sayed Feb 5, 2024
1172a53
try GITHUB_REF
ahmad-el-sayed Feb 5, 2024
13b53c2
hardcode branch name
ahmad-el-sayed Feb 7, 2024
0cf2617
hardcode previous commit hash
ahmad-el-sayed Feb 7, 2024
c5c4e50
Reference reusable action from local repo
ahmad-el-sayed Feb 7, 2024
ff0fdb2
Fix workflow path
ahmad-el-sayed Feb 7, 2024
5c9f15a
Really fix workflow path
ahmad-el-sayed Feb 7, 2024
b711197
quote strings in strategy matrix
ahmad-el-sayed Feb 7, 2024
78b8e1d
remove strategy matrix temporarily
ahmad-el-sayed Feb 7, 2024
6ec1f5c
Try to include steps
ahmad-el-sayed Feb 7, 2024
097bfb7
Add on push
ahmad-el-sayed Feb 7, 2024
dbca9ed
Remove unneccessary builds from feature branches workflow
ahmad-el-sayed Feb 7, 2024
72b43cd
add workflow for master and release branches
ahmad-el-sayed Feb 7, 2024
c8bb535
Make cache keys unique (by platform-build_type)
ahmad-el-sayed Feb 7, 2024
54dcfba
Reinstate ubuntu and debug builds to test cache keys
ahmad-el-sayed Feb 7, 2024
144b0c8
remove on pull_request from master and release workflows
ahmad-el-sayed Feb 7, 2024
9a49b9e
misc improvements
ahmad-el-sayed Feb 7, 2024
258e504
cache build for testing and deployment then clear
ahmad-el-sayed Feb 7, 2024
31751c8
Revert "cache build for testing and deployment then clear"
ahmad-el-sayed Feb 7, 2024
9fa450f
Revert "misc improvements"
ahmad-el-sayed Feb 7, 2024
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
31 changes: 31 additions & 0 deletions .github/workflows/build-and-test-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and test

on:
push:
branches:
- "feature/**"
pull_request:
types:
- opened # triggers build when opened
- synchronize # triggers build when commits are pushed to HEAD
branches:
- "feature/**"
# Manual trigger
workflow_dispatch:

jobs:

build:

strategy:
fail-fast: false
matrix:
platform:
- macos-12
build_type:
- Release

uses: ./.github/workflows/build-and-test-workflow.yml
with:
platform: ${{ matrix.platform }}
build_type: ${{ matrix.build_type }}
27 changes: 27 additions & 0 deletions .github/workflows/build-and-test-master-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and test

on:
push:
branches:
- master
- "release/v[0-9].[0-9].[0-9]"
# Manual trigger
workflow_dispatch:

jobs:

build:

strategy:
fail-fast: false
matrix:
platform:
- macos-12
- macos-13-xlarge
build_type:
- Release

uses: ./.github/workflows/build-and-test-workflow.yml
with:
platform: ${{ matrix.platform }}
build_type: ${{ matrix.build_type }}
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
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:
description: "Platform"
required: true
type: string
build_type:
description: "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 All @@ -45,7 +28,7 @@ jobs:
CC: gcc-11
CXX: g++-11

# Build steps
# Build steps
steps:

# Step: Checkout
Expand Down Expand Up @@ -77,8 +60,8 @@ jobs:
uses: actions/cache/restore@v3
id: restore-cached-external-dependencies
with:
key: ${{ runner.os }}-cache-key
restore-keys: ${{ runner.os }}-cache-key
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key
restore-keys: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key
path: ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c

# Step: Build and install user-provided dependencies, executes only if no cache restored
Expand All @@ -89,15 +72,15 @@ 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
- name: Cache user-provided dependencies
uses: actions/cache/save@v3
if: runner.os != 'macOS' && steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
with:
key: ${{ runner.os }}-cache-key
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key
path: ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c

# Step: CMake configuration
Expand All @@ -106,17 +89,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 +116,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
Loading