Skip to content

Commit

Permalink
refactor cmake behavior to resuable action
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonRadtke committed Oct 14, 2024
1 parent e25059a commit 041f03f
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 40 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Composite CMake
inputs:
cmake_generator:
required: false
type: string
default: 'Unix Makefiles'
cmake_build_type:
required: true
type: string
default: ''
cmake_cxx_compiler:
required: false
type: string
gsl_cxx_standard:
required: true
type: number
extra_cmake_args:
required: false
type: string
default: ''
cmake_configure_only:
required: false
type: boolean
default: false

runs:
using: composite
steps:
- name: Create build directory
run: mkdir build
shell: bash

- name: Configure CMake
working-directory: build
run: |
cmake \
-G "${{ inputs.cmake_generator }}" \
-DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} \
-DCMAKE_CXX_COMPILER=${{ inputs.cmake_cxx_compiler }} \
-DGSL_CXX_STANDARD=${{ inputs.gsl_cxx_standard }} \
-DCI_TESTING:BOOL=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-Werror=dev \
${{ inputs.extra_cmake_args }} \
..
shell: bash

- name: Build
if: "!${{ inputs.cmake_configure_only }}"
working-directory: build
run: make
shell: bash

- name: Test
if: "!${{ inputs.cmake_configure_only }}"
working-directory: build
run: make test
shell: bash

85 changes: 45 additions & 40 deletions .github/workflows/compilers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ on:
pull_request:
branches: [ main ]

# TODO (@carsonradtke)
# - [ ] flesh out strategy.matrix
# - [ ] Update README with latest versions actively tested
# - [ ] Do not use '*-latest' for runs-on
jobs:

# TODO (@carsonradtke)
# - [ ] Xcode
# - [ ] VS_LLVM
# - [ ] Update README with latest versions actively tested
# - [ ] Do not use '*-latest' for runs-on

gcc:
strategy:
matrix:
Expand All @@ -28,21 +25,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: create build directory
run: mkdir build

- name: cmake configure
working-directory: build
run: cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DGSL_CXX_STANDARD=${{ matrix.cxx_version }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev -DCMAKE_CXX_COMPILER=g++-${{ matrix.gcc_version }} ..

- name: build
working-directory: build
run: make

- name: test
working-directory: build
run: make test

- name: Run CMake (configure, build, test)
uses: ./.github/workflows/cmake
with:
cmake_build_type: ${{ matrix.build_type }}
cmake_cxx_compiler: g++-${{ matrix.gcc_version }}
gsl_cxx_standard: ${{ matrix.cxx_version }}

clang:
strategy:
matrix:
Expand All @@ -53,38 +42,54 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: create build directory
run: mkdir build
- name: Run CMake (configure, build, test)
uses: ./.github/workflows/cmake
with:
cmake_build_type: ${{ matrix.build_type }}
cmake_cxx_compiler: clang++-${{ matrix.clang_version }}
gsl_cxx_standard: ${{ matrix.cxx_version }}

- name: cmake configure
working-directory: build
run: cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DGSL_CXX_STANDARD=${{ matrix.cxx_version }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev -DCMAKE_CXX_COMPILER=clang++-${{ matrix.clang_version }} ..
xcode:
strategy:
matrix:
cxx_version: [ 17 ] # 14, 17, 20
build_type: [ 'Debug' ] # 'Debug', 'Release'
xcode_version: [ "15.4" ] # "14.3.1", "15.4"
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: build
working-directory: build
run: make
- name: select xcode version
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode_version }}.app

- name: test
working-directory: build
run: make test
- name: Run CMake (configure, build, test)
uses: ./.github/workflows/cmake
with:
cmake_build_type: ${{ matrix.build_type }}
cmake_cxx_compiler: clang++
gsl_cxx_standard: ${{ matrix.cxx_version }}

VS_MSVC:
VisualStudio:
strategy:
matrix:
cxx_version: [ 17 ] # 14, 17, 20
generator: [ "Visual Studio 17 2022" ] # "Visual Studio 16 2019", "Visual Studio 17 2022"
build_type: [ 'Debug' ] # 'Debug', 'Release'
extra_args: [ "", "-T ClangCL" ]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v1

- name: create build directory
run: mkdir build
- name: Run CMake (configure only)
uses: ./.github/workflows/cmake
with:
cmake_generator: ${{ matrix.generator }}
cmake_build_type: ${{ matrix.build_type }}
cmake_configure_only: true
gsl_cxx_standard: ${{ matrix.cxx_version }}
extra_cmake_args: ${{ matrix.extra_args }}

- name: cmake configure
working-directory: build
run: cmake -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DGSL_CXX_STANDARD=${{ matrix.cxx_version }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ..
- uses: microsoft/setup-msbuild@v1

- name: build
working-directory: build
Expand Down

0 comments on commit 041f03f

Please sign in to comment.