Skip to content

Commit 35d0739

Browse files
committed
[ci] Add github ci workflow to compile plugin using SOFA master
1 parent 6dace03 commit 35d0739

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

.github/workflows/ci.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build-and-test:
8+
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-22.04, macos-14, windows-2022]
14+
sofa_branch: [master]
15+
16+
steps:
17+
- name: Setup SOFA and environment
18+
id: sofa
19+
uses: sofa-framework/sofa-setup-action@v5
20+
with:
21+
sofa_root: ${{ github.workspace }}/sofa
22+
sofa_version: ${{ matrix.sofa_branch }}
23+
sofa_scope: 'standard'
24+
- name: Checkout source code
25+
uses: actions/checkout@v2
26+
with:
27+
path: ${{ env.WORKSPACE_SRC_PATH }}
28+
29+
- name: Build and install
30+
id: build-install
31+
shell: bash
32+
run: |
33+
if [[ "$RUNNER_OS" == "Windows" ]]; then
34+
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
35+
&& cd /d $WORKSPACE_BUILD_PATH \
36+
&& cmake \
37+
-GNinja \
38+
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
39+
-DCMAKE_BUILD_TYPE=Release \
40+
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
41+
../src \
42+
&& ninja install"
43+
else
44+
cd "$WORKSPACE_BUILD_PATH"
45+
ccache -z
46+
cmake \
47+
-GNinja \
48+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
49+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
50+
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
51+
-DCMAKE_BUILD_TYPE=Release \
52+
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
53+
../src
54+
ninja install
55+
echo ${CCACHE_BASEDIR}
56+
ccache -s
57+
fi
58+
59+
- name: Sanitize artifact name
60+
id: sanitize
61+
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
62+
# Characters removed: " : < > | * ? \r \n \ /
63+
# Spaces are replaced with underscores
64+
# This sanitization prevents errors in artifact creation and retrieval
65+
shell: pwsh
66+
run: |
67+
$originalName = "CollisionAlgorithm_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
68+
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
69+
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
70+
71+
- name: Create artifact
72+
id: create-artifact
73+
uses: actions/[email protected]
74+
with:
75+
name: ${{ steps.sanitize.outputs.artifact_name }}
76+
path: ${{ env.WORKSPACE_INSTALL_PATH }}
77+
78+
- name: Install artifact
79+
id: install-artifact
80+
uses: actions/[email protected]
81+
with:
82+
name: ${{ steps.sanitize.outputs.artifact_name }}
83+
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}
84+
85+
- name: Set env vars for tests
86+
shell: bash
87+
run: |
88+
# Set env vars for tests
89+
if [[ "$RUNNER_OS" == "Windows" ]]; then
90+
echo "$WORKSPACE_ARTIFACT_PATH/lib" >> $GITHUB_PATH
91+
echo "$WORKSPACE_ARTIFACT_PATH/bin" >> $GITHUB_PATH
92+
echo "$SOFA_ROOT/plugins/SofaPython3/bin" >> $GITHUB_PATH
93+
echo "SOFA_PLUGIN_PATH=$WORKSPACE_ARTIFACT_PATH/bin" | tee -a $GITHUB_ENV
94+
else
95+
echo "SOFA_PLUGIN_PATH=$WORKSPACE_ARTIFACT_PATH/lib" | tee -a $GITHUB_ENV
96+
fi
97+
98+
if [[ "$RUNNER_OS" == "macOS" ]]; then
99+
echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV
100+
fi
101+
102+
if [[ "$RUNNER_OS" == "Linux" ]]; then
103+
echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
104+
fi
105+
106+
deploy:
107+
name: Deploy artifacts
108+
if: always() && startsWith(github.ref, 'refs/heads/main') # we are on a branch (not a PR)
109+
needs: [build-and-test]
110+
runs-on: ubuntu-latest
111+
continue-on-error: true
112+
steps:
113+
- name: Get artifacts
114+
uses: actions/[email protected]
115+
with:
116+
path: artifacts
117+
118+
- name: Zip artifacts
119+
shell: bash
120+
run: |
121+
cd $GITHUB_WORKSPACE/artifacts
122+
for artifact in *; do
123+
zip $artifact.zip -r $artifact/*
124+
done
125+
- name: Upload release
126+
uses: softprops/action-gh-release@v1
127+
with:
128+
name: ${{ github.ref_name }}
129+
tag_name: release-${{ github.ref_name }}
130+
fail_on_unmatched_files: true
131+
files: |
132+
artifacts/CollisionAlgorithm_*_Linux.zip
133+
artifacts/CollisionAlgorithm_*_Windows.zip
134+
artifacts/CollisionAlgorithm_*_macOS.zip
135+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Delete old workflow runs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
days:
6+
description: 'Days-worth of runs to keep for each workflow'
7+
required: true
8+
default: '30'
9+
minimum_runs:
10+
description: 'Minimum runs to keep for each workflow'
11+
required: true
12+
default: '6'
13+
delete_workflow_pattern:
14+
description: 'Name or filename of the workflow (if not set, all workflows are targeted)'
15+
required: false
16+
delete_workflow_by_state_pattern:
17+
description: 'Filter workflows by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
18+
required: true
19+
default: "ALL"
20+
type: choice
21+
options:
22+
- "ALL"
23+
- active
24+
- deleted
25+
- disabled_inactivity
26+
- disabled_manually
27+
delete_run_by_conclusion_pattern:
28+
description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
29+
required: true
30+
default: "ALL"
31+
type: choice
32+
options:
33+
- "ALL"
34+
- "Unsuccessful: action_required,cancelled,failure,skipped"
35+
- action_required
36+
- cancelled
37+
- failure
38+
- skipped
39+
- success
40+
dry_run:
41+
description: 'Logs simulated changes, no deletions are performed'
42+
required: false
43+
44+
jobs:
45+
del_runs:
46+
runs-on: ubuntu-latest
47+
permissions:
48+
actions: write
49+
contents: read
50+
steps:
51+
- name: Delete workflow runs
52+
uses: Mattraks/delete-workflow-runs@v2
53+
with:
54+
token: ${{ github.token }}
55+
repository: ${{ github.repository }}
56+
retain_days: ${{ github.event.inputs.days }}
57+
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
58+
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
59+
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
60+
delete_run_by_conclusion_pattern: >-
61+
${{
62+
startsWith(github.event.inputs.delete_run_by_conclusion_pattern, 'Unsuccessful:')
63+
&& 'action_required,cancelled,failure,skipped'
64+
|| github.event.inputs.delete_run_by_conclusion_pattern
65+
}}
66+
dry_run: ${{ github.event.inputs.dry_run }}

0 commit comments

Comments
 (0)