Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3a1c167
Test action
bakpaul Sep 9, 2024
978ef1a
Fix action
bakpaul Sep 9, 2024
0c2f7f0
Test pre job hook
bakpaul Sep 9, 2024
1a874b1
Add setup_build step
bakpaul Sep 9, 2024
033bd3c
Fix action
bakpaul Sep 9, 2024
c5fda97
FIX when folders already exist + TODOS
bakpaul Sep 10, 2024
14d7d2a
Add filter action and scripts
hugtalbot Mar 10, 2025
9725eb2
replace sofa-framework by bakpaul
hugtalbot Mar 13, 2025
c0c5975
fix indentation
hugtalbot Mar 13, 2025
1fade70
add checkout code action
hugtalbot Mar 13, 2025
a521a1a
Add backbone
bakpaul Mar 18, 2025
6331407
Cloning SOFA working
bakpaul Mar 18, 2025
896e09c
Forgot to save
bakpaul Mar 18, 2025
7c2d16a
add chmod to run script
hugtalbot Mar 18, 2025
c2db438
Add call-workflow, refactor env variables, update python script
hugtalbot Mar 18, 2025
a40fb35
remove useless comment
hugtalbot Mar 18, 2025
9a68617
Apply suggestions from code review
hugtalbot Mar 19, 2025
08cf72e
Apply suggestions from code review
hugtalbot Mar 19, 2025
a901365
Update filter-build.yml
hugtalbot Mar 19, 2025
3ff4ae3
Finalize clone sofa and ci (#7)
bakpaul Mar 19, 2025
22aa451
Add build step (#8)
bakpaul Mar 21, 2025
8831138
Use step outputs to send variables in call workflow (#9)
hugtalbot Apr 7, 2025
949946a
Update checkPRInfoBeforeBuild.py (#11)
hugtalbot Apr 7, 2025
0ce7781
Fix build script (#13)
bakpaul Apr 8, 2025
93b612b
fix script + revert wrong changes (#15)
bakpaul Apr 8, 2025
3fab0e2
Update filter-build.yml (#16)
hugtalbot Apr 8, 2025
43dcd30
Fix sha when commit pushed in master (#17)
hugtalbot Apr 8, 2025
9fcf645
Temporarily change remote for non-PR (#18)
hugtalbot Apr 8, 2025
867f910
202505 evolve filter nightly (#19)
hugtalbot Apr 11, 2025
4c5ce49
Fix trigger through comments (#20)
hugtalbot Apr 11, 2025
bb10f39
move echo to read it
hugtalbot Apr 11, 2025
a32a3e5
attempt to access information PR comment
hugtalbot Apr 11, 2025
070f7ae
attempt to access information PR comment
hugtalbot Apr 11, 2025
7dba720
complete access information PR comment
hugtalbot Apr 11, 2025
8229d83
complete access information PR comment
hugtalbot Apr 11, 2025
37656b4
Update search of PR information when comment_issue
hugtalbot Apr 11, 2025
06b1e67
Remove empty env var
hugtalbot Apr 11, 2025
9bae225
add check on OWNER_NAME var
hugtalbot Apr 11, 2025
41dcada
add check on OWNER_NAME var
hugtalbot Apr 11, 2025
5675c33
last attempt to fill env var for comment_issue
hugtalbot Apr 11, 2025
67db07e
split in two steps for comment_issue
hugtalbot Apr 11, 2025
384f86c
add missing PR number for comment_issue (step 2)
hugtalbot Apr 11, 2025
7701642
Start work on docker use (#10)
bakpaul Apr 17, 2025
242503a
Filter build only if not schedule, PR comment linked steps (#21)
hugtalbot Apr 17, 2025
805ccd6
Fix when ci-depends-on is empty (#22)
bakpaul Apr 17, 2025
6232b5f
Manage out of tree plugins and simplify binaries generation (#23)
bakpaul Apr 17, 2025
9499d7d
Fix filter build
bakpaul Apr 17, 2025
0a14604
Restore changes
bakpaul Apr 17, 2025
fd5e726
Remove unnecessary checks in workflow dispatch
bakpaul Apr 17, 2025
b5f457e
Fix builder os matrix
bakpaul Apr 17, 2025
daee071
Fix builder os matrix
bakpaul Apr 17, 2025
1deb209
Activate plugins that are added (#25)
bakpaul Apr 17, 2025
398970d
fix adding external repo
bakpaul Apr 22, 2025
93b5b93
Force full build on workflow dispatch
bakpaul Apr 22, 2025
27a49f2
Add missing inputs to filter build action (#26)
bakpaul Apr 28, 2025
5be4476
Add test step (#28)
bakpaul Apr 29, 2025
2118d07
Add log publishing (#31)
bakpaul Apr 29, 2025
0636656
Fix log publish
bakpaul Apr 30, 2025
c3cb6b0
Update build-and-test.yml
bakpaul Apr 30, 2025
5ab678f
Prefix all ci actions
hugtalbot May 9, 2025
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
355 changes: 355 additions & 0 deletions .github/workflows/ci-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
name: Compile SOFA and run Tests
on:
workflow_call:
inputs:
sofa-branch-name:
type: string
required: true
sofa-commit-sha:
type: string
required: true
pr-owner-url:
type: string
required: false
pr-branch-name:
type: string
required: false
pr-commit-sha:
type: string
required: false
preset:
type: string
required: true
python-version:
type: string
required: true
ci-depends-on:
type: string
required: false
with-all-tests:
type: boolean
required: false
default: false
force-full-build:
type: boolean
required: false
default: false
generate-binaries:
type: boolean
required: false
default: false
external-plugins:
type: string
required: false
additionnal-cmake-flags:
type: string
required: false
builder-os:
type: string
required: true
default: '["sh-ubuntu_gcc_release"]'
dash-info:
type: string
required: false
default: 'NONE'
description: 'Json scructure with three parameters {"COMMIT_HASH":"fullhsashofthecommit", }'

jobs:
display-inputs:
runs-on: ubuntu-latest
steps:
- name: Display
shell: bash
run: |
echo "Build and test launched with following parameters:"
echo "sofa-branch-name : ${{ inputs.sofa-branch-name }}"
echo "sofa-commit-sha : ${{ inputs.sofa-commit-sha }}"
echo "pr-owner-url : ${{ inputs.pr-owner-url }}"
echo "pr-branch-name : ${{ inputs.pr-branch-name }}"
echo "pr-commit-sha : ${{ inputs.pr-commit-sha }}"
echo "preset : ${{ inputs.preset }}"
echo "python-version : ${{ inputs.python-version }}"
echo "ci-depends-on : ${{ inputs.ci-depends-on }}"
echo "with-all-tests : ${{ inputs.with-all-tests }}"
echo "force-full-build : ${{ inputs.force-full-build }}"
echo "generate-binaries : ${{ inputs.generate-binaries }}"
echo "external-plugins : ${{ inputs.external-plugins }}"
echo "additionnal-cmake-flags : ${{ inputs.additionnal-cmake-flags }}"
echo "builder-os : ${{ inputs.builder-os }}"

build:
strategy:
matrix:
os: ${{ fromJson(inputs.builder-os) }}
runs-on: ${{ matrix.os }}
steps:
- name: Configure builder
shell: bash
run: |
## Go to workspace given by the runner (this file is generated by the pre-build script)
WORKSPACE=$(cat $GITHUB_WORKFLOW_SHA)/${{ matrix.os }}
echo "WORKSPACE=$WORKSPACE" >> $GITHUB_ENV

if [ ! -d $WORKSPACE ]; then
mkdir -p $WORKSPACE
fi
cd $WORKSPACE

echo "Workspace folder for this build will be $WORKSPACE"

## Setup github
# Git config (needed by CMake ExternalProject)
if ! git config --get user.name; then
git config --system user.name 'SOFA Bot' > /dev/null 2>&1 ||
git config --global user.name 'SOFA Bot' > /dev/null 2>&1 ||
git config user.name 'SOFA Bot' > /dev/null 2>&1 ||
echo "WARNING: cannot setup git config"
fi
if ! git config --get user.email; then
git config --system user.email '<>' > /dev/null 2>&1 ||
git config --global user.email '<>' > /dev/null 2>&1 ||
git config user.email '<>' > /dev/null 2>&1 ||
echo "WARNING: cannot setup git config"
fi

##TODO (if required) fix path too long for windows (see main.sh:201)

- name: Clone SOFA and CI
shell: bash
run: |
cd $WORKSPACE

## Clone sofa and merge origin master
echo "Cloning SOFA at commit $GITHUB_WORKFLOW_SHA"
if [ -d $WORKSPACE/sofa ]; then
rm -rf $WORKSPACE/sofa
fi
SRC_DIR=$(pwd)/sofa
echo "SRC_DIR=$SRC_DIR" >> $GITHUB_ENV

if [ ! -z "${{ inputs.pr-owner-url }}" ]; then
echo "This is a PR, merging branch ${{ inputs.pr-branch-name }} from remote ${{ inputs.pr-owner-url }} into origin branch ${{ inputs.sofa-branch-name }}"
git clone -b ${{ inputs.sofa-branch-name }} --single-branch https://www.github.com/sofa-framework/sofa
cd sofa
git remote add pr ${{ inputs.pr-owner-url }}
git fetch pr

if [ "${{ inputs.pr-commit-sha }}" == "HEAD" ]; then
git merge ${{ inputs.pr-branch-name }}
else
git merge ${{ inputs.pr-commit-sha }}
fi
else
echo "This is not a PR: checking out sha ${{ inputs.sofa-commit-sha }} from branch ${{ inputs.sofa-branch-name }}"
git clone -b ${{ inputs.sofa-branch-name }} --single-branch https://www.github.com/bakpaul/sofa ## TODO : REMOVE THIS WITH SOFA_FRAMEWORK @@@@@@@@@@@@@
cd sofa
git checkout ${{ inputs.sofa-commit-sha }}
fi

cd $WORKSPACE

## Clone CI and use ci-depends-on structure
### TODO: UNCOMMENT THIS WHEN PUSHIN TO REAL SOFA
# ci_branch=${{ inputs.sofa-branch-name }}
# ci_repo_url="https://www.github.com/sofa-framework/ci"
### AND REMOVE THOSE
ci_branch=jenkins_gha_migration
ci_repo_url="https://www.github.com/bakpaul/ci"


# check if ci has a ci-depends-on
ci_ci_depends_on=$(echo "${{ inputs.ci-depends-on }}" | jq .ci)
if [ -n "${{ inputs.ci-depends-on }}" ] && [ "$ci_ci_depends_on" != "null" ]; then
echo "ci-depends-on for ci repository detected."
ci_repo_url=$(echo "${{ inputs.ci-depends-on }}" | jq .ci.repo_url)
ci_branch=$(echo "${{ inputs.ci-depends-on }}" | jq .ci.branch_name)
fi
echo "CI_BRANCH=$ci_branch" >> $GITHUB_ENV


echo "Cloning CI from remote ${ci_repo_url}, selecting branch ${ci_branch}"

if [ -d $WORKSPACE/ci ]; then
rm -rf $WORKSPACE/ci
fi
CI_DIR=$WORKSPACE/ci
echo "CI_DIR=$CI_DIR" >> $GITHUB_ENV

git clone -b ${ci_branch//\"} --single-branch ${ci_repo_url//\"}

cd $WORKSPACE

## Setup build folder
if [ "${{ inputs.force-full-build }}" == "true" ] && [ -d $WORKSPACE/build ]; then
rm -rf $WORKSPACE/build
fi
if [ ! -d $WORKSPACE/build ]; then
mkdir $WORKSPACE/build
fi

BUILD_DIR=$WORKSPACE/build
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV

if [ -n "${{ inputs.external-plugins }}" ]; then
echo "Setting up external plugins."
for plugin in ${{ inputs.external-plugins }}; do
plugin_base=${plugin%@*}
plugin_branch=${plugin##*@}
plugin_repo=$(basename "$plugin_base")

echo "Adding line 'sofa_add_external(plugin $plugin_repo GIT_REF $plugin_branch GIT_REPOSITORY $plugin_base ON)' to file ${SRC_DIR}/applications/CMakeLists.txt"
echo "sofa_add_external(plugin $plugin_repo GIT_REF $plugin_branch GIT_REPOSITORY $plugin_base ON)" >> "${SRC_DIR}/applications/CMakeLists.txt"
done
fi


- name: Notify dashboard
shell: bash
run: |
. ${CI_DIR}/scripts/utils.sh
. ${CI_DIR}/scripts/dashboard.sh

#Really necessary ?
#TODO
#Need more information. Might be good to

- name: Build
id: build-step
continue-on-error: true
shell: bash
run: |
## Configure the build: setup cmake variables
# retrive build type and compiler
BUILD_TYPE=$(echo ${{ matrix.os }} | awk -F '_' '{print $3}')
CONFIG=$(echo ${{ matrix.os }} | awk -F '_' '{print $1"_"$2}')
NODE_NAME="${{ runner.name }}" # Needed by configure-and-build --> TODO: be able to get hostname multiplatform
echo "NODE_NAME=$NODE_NAME" >> $GITHUB_ENV

## Deal with ci-depends-on
# Loop over each key-value pair in the JSON avoiding ci repository if inside
CMAKE_OPTIONS="${{inputs.additionnal-cmake-flags}}"
for key in $(echo "${{ inputs.ci-depends-on }}" | jq -r 'keys[]' | grep -v '^ci$'); do

repo_url=$(echo "${{ inputs.ci-depends-on }}" | jq -r ".\"$key\".repo_url")
branch_name=$(echo "${{ inputs.ci-depends-on }}" | jq -r ".\"$key\".branch_name")

# Format the CMake flags for this key and append to the result
fixed_name=$(echo "$key" | awk '{gsub(/\./, "_"); print toupper($0)}')
flag_repository="-D${fixed_name}_GIT_REPOSITORY=\"$repo_url\")"
flag_tag="-D${fixed_name}_GIT_TAG=\"$branch_name\")"

# Append both flags to the result string with a space
CMAKE_OPTIONS="$CMAKE_OPTIONS $flag_repository $flag_tag "
done

if [[ ! -n "$CMAKE_OPTIONS" ]]; then
CMAKE_OPTIONS="no-additionnal-cmake-flags"
echo "No ci-depends-on detected."
else
echo "Adding the following cmake variable : $CMAKE_OPTIONS"
fi

echo ""
echo "------ Before build (and docker) ------"
echo "Main folders:"
echo " - WORKSPACE = $WORKSPACE"
echo " - SRC_DIR = $SRC_DIR"
echo " - CI_DIR = $CI_DIR"
echo " - BUILD_DIR = $BUILD_DIR"
echo ""
echo "Configuration:"
echo " - NODE_NAME = $NODE_NAME"
echo " - BUILD_TYPE = $BUILD_TYPE"
echo " - CONFIG = $CONFIG"
echo " - PYTHON_VERSION = ${{ inputs.python-version }}"
echo " - PRESET = ${{ inputs.preset }}"
echo " - GENERATE_BINARIES = ${{ inputs.generate-binaries }}"
echo " - ADDITIONNAL_CMAKE_OPTIONS = $CMAKE_OPTIONS"
echo "---------------------------------------"
echo ""

#If os has got docker then use it
if [[ "${{ matrix.os }}" == *"ubuntu"* ]] || [[ "${{ matrix.os }}" == *"fedora"* ]]; then
builder_type=$(echo "${{ matrix.os }}" | awk -F '_' '{print $1}' | awk -F '-' '{print $2}')
if [[ "${{ inputs.sofa-branch-name }}" == "master" ]] || [[ "${{ inputs.sofa-branch-name }}" =~ ^v[0-9]{2}\.[0-9]{2}$ ]]; then
default_tag=${{ inputs.sofa-branch-name }}
else
default_tag=master
fi

echo "dckr_pat_ohBds9gXTs9Iy91QPKJZXGdVS5s" | docker login -u sofaframework --password-stdin

echo "Pulling Docker image sofaframework/sofabuilder_${builder_type}:${CI_BRANCH} ..."
docker pull --quiet sofaframework/sofabuilder_${builder_type}:${CI_BRANCH} || true
DOCKER_IMAGE="sofaframework/sofabuilder_${builder_type}:${CI_BRANCH}"

if [[ "$(docker image list --format "table {{.Repository}}:{{.Tag}}")" != *"sofaframework/sofabuilder_${builder_type}:${CI_BRANCH}"* ]]; then
echo "Docker image sofaframework/sofabuilder_${builder_type}:${CI_BRANCH} doesn't exist, pulling default tag ${default_tag} "
docker pull --quiet sofaframework/sofabuilder_${builder_type}:${default_tag}

DOCKER_IMAGE="sofaframework/sofabuilder_${builder_type}:${default_tag}"
fi

echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> $GITHUB_ENV


echo "Launching configuration and build through docker using image ${DOCKER_IMAGE}. Running ./ci/scripts/configure-and-build.sh /workspace/build/ /workspace/sofa/ /workspace/ci/scripts/ \"${NODE_NAME}\" \"${BUILD_TYPE}\" \"${CONFIG}\" \"${{ inputs.python-version }}\" \"${{ inputs.preset }}\" \"${{ inputs.generate-binaries }}\" \"${CMAKE_OPTIONS}\""
docker run --rm \
--user $(id -u):$(id -g) --network=host -v $WORKSPACE:/workspace \
${DOCKER_IMAGE} \
/bin/bash -c "env ; cd /workspace; /bin/bash ./ci/scripts/configure-and-build.sh /workspace/build/ /workspace/sofa/ /workspace/ci/scripts/ \"${NODE_NAME}\" \"${BUILD_TYPE}\" \"${CONFIG}\" \"${{ inputs.python-version }}\" \"${{ inputs.preset }}\" \"${{ inputs.generate-binaries }}\" \"${CMAKE_OPTIONS}\""
else
echo "Launching configuration and build"

bash ${CI_DIR}/scripts/configure-and-build.sh "${BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${BUILD_TYPE}" "${CONFIG}" "${{ inputs.python-version }}" "${{ inputs.preset }}" "${{ inputs.generate-binaries }}" "${CMAKE_OPTIONS}"
fi


- name: Notify dashboard
if: always()
shell: bash
run: |
#TODO

- name: Launch tests
continue-on-error: true
if: steps.build-step.outcome == 'success'
shell: bash
run: |
# If os has got docker then use it
# Here no need to fetch it because it has already been taken care of in the build step
if [[ "${{ matrix.os }}" == *"ubuntu"* ]] || [[ "${{ matrix.os }}" == *"fedora"* ]]; then

echo "Launching test suite through docker using image ${DOCKER_IMAGE}. Running ./ci/scripts/test.sh /workspace/build/ /workspace/sofa/ /workspace/ci/ ${NODE_NAME} ${{ inputs.python-version }}"
docker run --rm \
--user $(id -u):$(id -g) --network=host -v $WORKSPACE:/workspace \
${DOCKER_IMAGE} \
/bin/bash -c "env ; cd /workspace; /bin/bash ./ci/scripts/test.sh /workspace/build/ /workspace/sofa/ /workspace/ci/scripts/ ${NODE_NAME} ${{ inputs.python-version }} ${{ inputs.with-all-tests }}"
else
echo "Launching test suite"

bash ${CI_DIR}/scripts/test.sh "${BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" "${{ inputs.with-all-tests }}"
fi


- name: Publish artifacts
if: steps.build-step.outcome == 'success' && inputs.generate-binaries == true
shell: bash
run: |
#TODO

- name: Publish build logs
if: always()
uses: actions/upload-artifact@v4
with:
name: build-logs
path: |
${{ env.BUILD_DIR }}/make-output.txt

- name: Publish tests logs
if: always()
uses: actions/upload-artifact@v4
with:
name: tests-logs
path: |
${{ env.BUILD_DIR }}/tests_results/
File renamed without changes.
Loading
Loading