Skip to content

Commit

Permalink
Add GitHub actions to CI (celeritas-project#1020)
Browse files Browse the repository at this point in the history
* Don't default CMake presets to "debug"

* Rename CI presets

* Use CMake BUILD_TESTING to decide to add testing tree

This allows more granularity for building unit tests or just testing the apps

* First iteration of GHA CI

* Integrate style workflow

* Try again

* Fix things, thanks vscode

* Fix exclusion

* Disable clang-format, try different docker url

* REVERTME: single job

* Run as root

see actions/checkout#956

```
Post job cleanup.
/usr/bin/docker exec  8a93ca44215e080743610d80ccea33c624f5d3fce1aa4038cd018c06b13a75a6 sh -c "cat /etc/*release | grep ^ID"
node:internal/fs/utils:347
    throw err;
    ^

Error: EACCES: permission denied, open '/__w/_temp/_runner_file_commands/save_state_56877b46-0efb-448b-8122-6d4d35217f1e'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at Object.appendFileSync (node:fs:2264:6)
    at Object.issueFileCommand (/__w/_actions/actions/checkout/v3/dist/index.js:2950:8)
    at Object.saveState (/__w/_actions/actions/checkout/v3/dist/index.js:2867:31)
    at Object.8647 (/__w/_actions/actions/checkout/v3/dist/index.js:2326:10)
    at __nccwpck_require__ (/__w/_actions/actions/checkout/v3/dist/index.js:18256:43)
    at Object.2565 (/__w/_actions/actions/checkout/v3/dist/index.js:146:34)
    at __nccwpck_require__ (/__w/_actions/actions/checkout/v3/dist/index.js:18256:43)
    at Object.9210 (/__w/_actions/actions/checkout/v3/dist/index.js:1141:36) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/__w/_temp/_runner_file_commands/save_state_56877b46-0efb-448b-8122-6d4d35217f1e'
}
```

* Introspect

* Try a different shell

* Source the fucking profile perhaps since it might ignore entrypoint

* No source I guess

* use github env, run tests

* Try to fix environment

* Try again

* Fix (I think?) openmp variables for celer-sim app

* Disable GPU tests at configure time if CELER_DISABLE_DEVICE

* Automatically skip device tests if CELER_DISABLE_DEVICE

* Update versions

* Use std allocateor rather than pinned when no device is available

* Use MPI max numprocs when setting NP default

github runner only has 2

* Disable more tests when GPU unavailable

* fixup! Use std allocateor rather than pinned when no device is available

* Enable all jobs

* Support root disabling (and initialization) from error handler

* Disable device tests if device is disabled at runtime

* Fix thread count for celer-sim with ROOT

* REVERTME: disable all but one ROCM image

* Downgrade to checkout v3

* Fix rocm json and jenkins build names

* Fix root/shared options

* fixup! Disable device tests if device is disabled at runtime

* Fix json

* Dubious ownership

* Fix CELERITAS_TEST_VERBOSE

* Fix matrix and tag fetch

* Try fetch depth

* Try single fetch depth, and fix use of accel example

* Try more fetch depth

* Add ld flags

* Disable example builds that don't currently work

* Fix syntax errors

* Add vecgeom-reldb and fix asan diabling

* Disable reldeb example too

* Remove to-dos

* Exclude changes to rst/md in check

* REVERTME: don't disable device

* Revert "REVERTME: don't disable device"

This reverts commit fbdea2d.

* Update 'special' annotations

* Add conflict between hip+assertions and update CI matrix

* Remove profile source and update working dirs

* Update documentation

* Fix image selection and parallelism

* fixup! Fix image selection and parallelism

* Reverse ordering so fine-grained is first
  • Loading branch information
sethrj committed Nov 20, 2023
1 parent aa3395c commit 82e9d34
Show file tree
Hide file tree
Showing 42 changed files with 553 additions and 549 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ IncludeCategories:
Priority: 5
SortPriority: 9
IncludeIsMainRegex: '(\.[^.]+)?$'
IncludeIsMainSourceRegex: '\.cu$' # Allow CU files as main
IncludeIsMainSourceRegex: '(\.cu|\.t\.hh)$' # Allow CU/template files as main
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: ci

on:
push:
branches:
- develop
- backports/**
pull_request:
branches:
- develop
- backports/**
paths-ignore:
- '**.rst'
- '**.md'
- 'scripts/dev'
merge_group:
types: [checks_requested]

concurrency:
group: ${{github.ref}}-${{github.event.pull_request.number || github.run_number}}-${{github.workflow}}
cancel-in-progress: true

jobs:
build:
name: CI
strategy:
matrix:
special: [null]
geometry: ['orange', 'vecgeom']
buildtype: ['debug', 'ndebug']
image: ['ubuntu-cuda', 'centos-rocm']
exclude:
- geometry: 'vecgeom'
image: 'centos-rocm' # VecGeom not installed on HIP
- buildtype: 'debug'
image: 'centos-rocm' # Debug builds don't work with HIP
include:
- special: 'asan'
geometry: 'orange'
buildtype: 'reldeb'
image: 'centos-rocm'
- special: 'minimal'
geometry: 'orange'
buildtype: 'debug'
image: 'centos-rocm'
- special: 'float'
geometry: 'orange'
buildtype: 'debug'
image: 'centos-rocm'
- special: 'float'
geometry: 'orange'
buildtype: 'ndebug'
image: 'centos-rocm'
- geometry: 'geant4'
buildtype: 'reldeb'
image: 'centos-rocm'
- geometry: 'vecgeom'
buildtype: 'reldeb'
image: 'ubuntu-cuda'
env:
ASAN_OPTIONS: "detect_leaks=0"
# CCACHE_DIR: "${{github.workspace}}/.ccache"
# CCACHE_MAXSIZE: "10G"
CELER_TEST_STRICT: 1
CELER_DISABLE_DEVICE: 1 # IMPORTANT
CMAKE_PRESET: >-
${{matrix.buildtype}}-${{matrix.geometry}}${{matrix.special && '-' || ''}}${{matrix.special}}
runs-on: ubuntu-latest
container:
image: >-
docker.io/celeritas/${{
matrix.image == 'ubuntu-cuda' && 'ci-jammy-cuda11:2023-08-02'
|| matrix.image == 'centos-rocm' && 'ci-centos7-rocm5:2022-12-14.2'
|| null
}}
# See https://github.com/actions/checkout/issues/956
options: --user root
steps:
- name: Set up environment
run: |
. /etc/profile
echo "/opt/view/bin" >> $GITHUB_PATH
echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV
# NOTE: checkout must occur *after* setting up environment for git tags to work
# NOTE: checkout v4 fails: https://github.com/actions/checkout/issues/1487
# NOTE: depth must be enough to include the previous tag
- name: Check out Celeritas
uses: actions/checkout@v3
with:
fetch-depth: 255
fetch-tags: true
- name: Configure Celeritas
run: |
git config --global --add safe.directory ${PWD}
ln -fs scripts/cmake-presets/ci-${{matrix.image}}.json CMakeUserPresets.json
cmake --preset=${CMAKE_PRESET}
- name: Build Celeritas
working-directory: build
run: |
ninja
- name: Test Celeritas
working-directory: build
run: |
ctest --parallel 2 --timeout 180 --output-on-failure \
--test-output-size-passed=65536 --test-output-size-failed=1048576
- name: Install Celeritas
working-directory: build
run: |
cmake --install .
- name: Check installation
working-directory: install
run: |
for exe in orange-update celer-export-geant celer-dump-data \
celer-sim celer-g4; do
test -x "bin/${exe}"
done
./bin/celer-sim --version
- name: Build examples
# TODO: asan needs -fsanitize=address
# TODO: rocm+ndebug fails to propagate HIP library link
# TODO: logger gets initialized in SimpleOffload::Build before run manager
if: >-
${{ matrix.special != 'asan'
&& !(matrix.image == 'centos-rocm' && matrix.buildtype == 'ndebug')
&& !(matrix.geometry == 'vecgeom' && matrix.buildtype != 'ndebug')
}}
run: |
if [ "${{matrix.geometry}}" = "vecgeom" ]; then
# TODO: vecgeom is loosey goosey about symbols whereas Ubuntu is strict
export LDFLAGS=-Wl,--no-as-needed
fi
./scripts/ci/test-examples.sh
# vim: set nowrap tw=100:
26 changes: 13 additions & 13 deletions .jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ pipeline {
stages {
stage('Build') {
parallel {
stage('clang-minitest') {
stage('clang-minimal') {
agent {
docker {
image 'celeritas/ci-centos7-rocm5:2022-12-14.2'
// Note: this image does not require CUDA or HIP
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm minitest'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm debug-orange'
}
post {
always {
Expand All @@ -32,7 +32,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm asan'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm asan-orange'
}
post {
always {
Expand All @@ -47,7 +47,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm float'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm debug-orange-float'
}
post {
always {
Expand All @@ -64,7 +64,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm ndebug'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm ndebug-orange'
}
post {
always {
Expand All @@ -75,12 +75,12 @@ pipeline {
stage('full-novg') {
agent {
docker {
image 'celeritas/ci-jammy-cuda11:2023-03-13'
image 'celeritas/ci-jammy-cuda11:2023-08-02'
label 'NVIDIA_Tesla_V100-PCIE-32GB && nvidia-docker && large_images'
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda full-novg'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda debug-orange'
}
post {
always {
Expand All @@ -91,12 +91,12 @@ pipeline {
stage('full-novg-ndebug') {
agent {
docker {
image 'celeritas/ci-jammy-cuda11:2023-03-13'
image 'celeritas/ci-jammy-cuda11:2023-08-02'
label 'NVIDIA_Tesla_V100-PCIE-32GB && nvidia-docker && large_images'
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda full-novg-ndebug'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda ndebug-orange'
}
post {
always {
Expand All @@ -112,7 +112,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda vecgeom-reldeb'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda reldeb-vecgeom'
}
post {
always {
Expand All @@ -128,7 +128,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda vecgeom-demos'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda ndebug-vecgeom'
}
post {
always {
Expand All @@ -144,7 +144,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda vecgeom-tests'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh ubuntu-cuda debug-vecgeom'
}
post {
always {
Expand All @@ -160,7 +160,7 @@ pipeline {
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm geant4'
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm reldeb-geant4'
}
post {
always {
Expand Down
27 changes: 25 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ celeritas_set_default(CMAKE_FIND_USE_PACKAGE_REGISTRY FALSE)
celeritas_set_default(CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY FALSE)

### Build flags ###
# Default to building CTest tree if using Celeritas tests
celeritas_set_default(BUILD_TESTING ${CELERITAS_BUILD_TESTS})
# Default to debug or released based on value of CELERITAS_DEBUG
if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE)
if(CELERITAS_DEBUG)
Expand Down Expand Up @@ -228,6 +230,11 @@ set(CELERITAS_RUNTIME_OUTPUT_DIRECTORY
# DEPENDENCIES
#----------------------------------------------------------------------------#

if(BUILD_TESTING)
# Build the test tree for unit and/or app tests
include(CTest)
endif()

if(CELERITAS_USE_CUDA)
# Use host compiler by default to ensure ABI consistency
set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}" CACHE STRING
Expand All @@ -236,6 +243,14 @@ if(CELERITAS_USE_CUDA)
find_package(CUDAToolkit REQUIRED QUIET)
elseif(CELERITAS_USE_HIP)
enable_language(HIP)
# NOTE: known broken up to 5.6; unknown after
if(CELERITAS_DEBUG AND "${hip-lang_VERSION}" VERSION_LESS 5.7)
celeritas_error_incompatible_option(
"HIP cannot build debug code (unhandled SGPR spill to memory)"
CELERITAS_DEBUG
OFF
)
endif()
endif()

if(CELERITAS_USE_Geant4 AND NOT Geant4_FOUND)
Expand Down Expand Up @@ -278,6 +293,13 @@ if(CELERITAS_USE_Python)
endif()

if(CELERITAS_USE_ROOT)
if(NOT BUILD_SHARED_LIBS)
celeritas_error_incompatible_option(
"ROOT PCM fails at runtime without shared libraries"
BUILD_SHARED_LIBS
ON
)
endif()
# Older ROOT versions are missing CMake macros
find_package(ROOT 6.24 REQUIRED)
endif()
Expand Down Expand Up @@ -364,7 +386,7 @@ endif()
if(CELERITAS_BUILD_TESTS)
# TODO: download and build GTest as a subproject if not available
if(NOT GTest_FOUND)
find_package(GTest)
find_package(GTest 1.10)
endif()
if(NOT GTest_FOUND)
celeritas_error_incompatible_option(
Expand Down Expand Up @@ -406,6 +428,8 @@ elseif(CELERITAS_USE_HIP)
set(CELERITAS_HAVE_ROCTX ON)
target_link_libraries(celeritas_device_toolkit INTERFACE ${ROCTX_LIBRARY})
endif()
# TODO: downstream libs don't link against correct HIP dependencies when using
# static libraries
endif()

install(TARGETS celeritas_device_toolkit
Expand All @@ -429,7 +453,6 @@ endif()
#----------------------------------------------------------------------------#

if(CELERITAS_BUILD_TESTS)
include(CTest)
add_subdirectory(test)
endif()

Expand Down
18 changes: 13 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
"configurePresets": [
{
"name": "default",
"displayName": "Automatic options (debug with tests)",
"displayName": "Automatic options",
"description": "Dependencies are enabled based on environment probing",
"binaryDir": "${sourceDir}/build-${presetName}",
"generator": "Ninja",
"cacheVariables": {
"BUILD_SHARED_LIBS": {"type": "BOOL", "value": "ON"},
"Celeritas_GIT_DESCRIBE": "",
"CELERITAS_BUILD_TESTS":{"type": "BOOL", "value": "ON"},
"CELERITAS_DEBUG": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_SWIG": {"type": "BOOL", "value": "OFF"},
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Debug"},
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install-${presetName}"
}
},
Expand Down Expand Up @@ -83,8 +80,9 @@
{
"name": ".ndebug",
"hidden": true,
"description": "Disable debug mode",
"description": "Build with optimizations and without debug assertions",
"cacheVariables": {
"BUILD_SHARED_LIBS":{"type": "BOOL", "value": "OFF"},
"CELERITAS_DEBUG": {"type": "BOOL", "value": "OFF"},
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Release"},
"CMAKE_CUDA_FLAGS_RELEASE": "-O3 -DNDEBUG",
Expand All @@ -101,6 +99,16 @@
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "RelWithDebInfo"}
}
},
{
"name": ".debug",
"hidden": true,
"description": "Enable debug mode",
"cacheVariables": {
"BUILD_SHARED_LIBS":{"type": "BOOL", "value": "ON"},
"CELERITAS_DEBUG": {"type": "BOOL", "value": "ON"},
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Debug"}
}
},
{
"name": ".spack-base",
"description": "Setup for using spack environment",
Expand Down
Loading

0 comments on commit 82e9d34

Please sign in to comment.