condatest #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: condatest | |
on: | |
# on: push | |
schedule: | |
- cron: '30 23 * * 0' # 23:30 every Sunday | |
workflow_dispatch: | |
inputs: | |
platform-choice: | |
type: choice | |
description: Platforms (software) to use | |
# IMPORTANT: DO NOT FORGET TO CHANGE THE 'MATRIX_DEFAULTS' AND 'MATRIX_ALL' VARIABLES BELOW ALONG WITH ANY PLATFORM CHANGE! # | |
default: 'defaults' | |
options: ['defaults', 'all', | |
'{ "os": "ubuntu-20.04", "CC": "gcc-10", "CXX": "g++-10", "python": "3.8" }', | |
'{ "os": "ubuntu-22.04", "CC": "gcc", "CXX": "g++", "python": "3.9" }', | |
'{ "os": "ubuntu-latest", "CC": "gcc", "CXX": "g++", "python": "3.10" }', | |
'{ "os": "ubuntu-latest", "CC": "clang", "CXX": "clang++", "python": "3.11" }', | |
'{ "os": "ubuntu-latest", "CC": "gcc-12", "CXX": "g++-12", "python": "3.11" }', | |
'{ "os": "macos-11", "CC": "clang", "CXX": "clang++", "python": "3.10" }', | |
'{ "os": "macos-12", "CC": "clang", "CXX": "clang++", "python": "3.11" }'] | |
include-filter-any: | |
type: string | |
description: Platform filter - include if it has ANY of the keywords (comma separated) | |
exclude-filter-any: | |
type: string | |
description: Platform filter - exclude if it has ANY of the keywords (comma separated) | |
default: '' | |
simplebuild-options: | |
type: string | |
description: Simplebuild options. Don't use quotes! | |
default: '-vtj1 --testexcerpts=100 ' | |
manual-debugging: | |
type: boolean | |
description: Launch manual debugging tmate session on failure | |
default: false | |
use-mamba: | |
type: boolean | |
description: Use Mamba instead of Conda(with the libmamba solver) | |
default: true | |
# Workflow which pip installs the source code in a conda environment and checks that both bundles build | |
# and runs tests in both release and debug mode. | |
jobs: | |
create-platform-matrix: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create platform (software) matrix | |
id: create-matrix | |
run: | | |
MATRIX_DEFAULTS=' | |
{ "os": "ubuntu-20.04", "CC": "gcc-10", "CXX": "g++-10", "python": "3.8" }, | |
{ "os": "ubuntu-22.04", "CC": "gcc", "CXX": "g++", "python": "3.9" }, | |
{ "os": "macos-12", "CC": "clang", "CXX": "clang++", "python": "3.11" }' | |
MATRIX_ALL=' | |
{ "os": "ubuntu-20.04", "CC": "gcc-10", "CXX": "g++-10", "python": "3.8" }, | |
{ "os": "ubuntu-22.04", "CC": "gcc", "CXX": "g++", "python": "3.9" }, | |
{ "os": "ubuntu-latest", "CC": "gcc", "CXX": "g++", "python": "3.10" }, | |
{ "os": "ubuntu-latest", "CC": "clang", "CXX": "clang++", "python": "3.11" }, | |
{ "os": "ubuntu-latest", "CC": "gcc-12", "CXX": "g++-12", "python": "3.11" }, | |
{ "os": "macos-11", "CC": "clang", "CXX": "clang++", "python": "3.10" }, | |
{ "os": "macos-12", "CC": "clang", "CXX": "clang++", "python": "3.11" }' | |
if [[ '${{ inputs.platform-choice }}' == 'all' || '${{ inputs.platform-choice }}' == '' ]]; then | |
MATRIX=$MATRIX_ALL | |
elif [[ '${{ inputs.platform-choice }}' == 'defaults' ]]; then | |
MATRIX=$MATRIX_DEFAULTS | |
else | |
MATRIX='${{ inputs.platform-choice }}' | |
fi | |
echo "Matrix to start with: $MATRIX" | |
MATRIX=$(python -c "print('\n'.join([l for l in '''$MATRIX'''.split('\n') if l and any([f.strip() in l for f in '$INCLUDE_FILTER_ANY'.split(',')]) ]))") | |
EXCLUDE_FILTER_ANY=$(if [ "$EXCLUDE_FILTER_ANY" != '' ]; then echo "$EXCLUDE_FILTER_ANY" ; else echo 'do not exclude any' ; fi) | |
MATRIX=$(python -c "print('\n'.join([l for l in '''$MATRIX'''.split('\n') if l and not any([f.strip() in l for f in '$EXCLUDE_FILTER_ANY'.split(',')]) ]))") | |
MATRIX=$(echo $MATRIX | tr '\n' ' ') | |
echo "platform-matrix={\"include\":[$MATRIX]}" >> $GITHUB_OUTPUT | |
echo "Final matrix: $MATRIX" | |
env: | |
INCLUDE_FILTER_ANY: ${{ inputs.include-filter-any }} | |
EXCLUDE_FILTER_ANY: ${{ inputs.exclude-filter-any }} | |
outputs: | |
platform-matrix: ${{ steps.create-matrix.outputs.platform-matrix }} | |
build: | |
needs: create-platform-matrix | |
name: ${{ matrix.os }}.${{ matrix.CC }}.python-${{ matrix.python }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.create-platform-matrix.outputs.platform-matrix) }} | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -el {0} | |
env: | |
SHELL: /bin/bash | |
CC: ${{ matrix.CC }} | |
CXX: ${{ matrix.CXX }} | |
CONDA_SOLVER: libmamba | |
# MAIN_DIR: ./src | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# with: | |
# path: ${{ env.MAIN_DIR }} | |
- name: Setup conda environment | |
uses: ./.github/actions/setup | |
with: | |
PYTHON_VERSION: ${{ matrix.python }} | |
USE_MAMBA: ${{ inputs.use-mamba == true }} | |
- name: Install simple-build-dgcode package | |
run: pip install simple-build-dgcode | |
- name: Build and test Core only | |
id: build-and-test-core-only | |
working-directory: ./devel/example_project_core_only | |
run: | | |
IFS=' ' read -ra SIMPLEBUILD_OPTIONS_ARRAY <<< "$SIMPLEBUILD_OPTIONS" | |
simplebuild ${SIMPLEBUILD_OPTIONS_ARRAY[@]} | |
sbenv sb_core_queryenv system langs c | |
env: | |
SIMPLEBUILD_OPTIONS: ${{ inputs.simplebuild-options }} | |
- name: Build and test release mode | |
id: build-and-test-release-mode | |
working-directory: ./devel/example_project_release_mode | |
run: | | |
IFS=' ' read -ra SIMPLEBUILD_OPTIONS_ARRAY <<< "$SIMPLEBUILD_OPTIONS" | |
simplebuild ${SIMPLEBUILD_OPTIONS_ARRAY[@]} | |
sbenv sb_core_extdeps --require-disabled NCrystal Numpy matplotlib Geant4 | |
sbenv sb_core_extdeps --require ZLib | |
env: | |
SIMPLEBUILD_OPTIONS: ${{ inputs.simplebuild-options }} | |
- name: Build-and-test-debug-mode | |
id: build-and-test-debug-mode | |
working-directory: ./devel/example_project_debug_mode | |
run: | | |
IFS=' ' read -ra SIMPLEBUILD_OPTIONS_ARRAY <<< "$SIMPLEBUILD_OPTIONS" | |
sb ${SIMPLEBUILD_OPTIONS_ARRAY[@]} | |
sbenv sb_core_extdeps --require-disabled Geant4 | |
sbenv sb_core_extdeps --require NCrystal Numpy matplotlib ZLib | |
env: | |
SIMPLEBUILD_OPTIONS: ${{ inputs.simplebuild-options }} | |
- name: Setup tmate session for manual debugging | |
uses: mxschmitt/action-tmate@v3 | |
if: always() && inputs.manual-debugging == true && (steps.build-and-test-core-only.outcome != 'success' || steps.build-and-test-release-mode.outcome != 'success' || steps.build-and-test-debug-mode.outcome != 'success') | |
with: | |
limit-access-to-actor: true |