Skip to content

Commit 312e7e2

Browse files
authored
[ci] new logic for ci workflow to use macOS only on demand or for releases (#59)
* [ci] new logic for ci workflow to use macOS only on demand or for releases * restore some wanted lines * update actions logic and condition * Yes — your version is much closer to the correct logic than mine, and it correctly preserves the “label is the gate” + “runs on subsequent pushes” behavior. * Fix indentation in CI workflow file * Update CI workflow to include artifact creation and tests Added steps for creating plugin artifacts and launching tests. * Remove unnecessary blank line in ci.yml * Update CI workflow to limit OS matrix Simplified the OS matrix for CI workflow to only include Ubuntu and Windows. * Update CI workflow to include macOS support Add conditional environment variable for macOS builds. * Update CI workflow OS selection conditions Refactor CI workflow to simplify OS selection logic. * Add prepare job to set OS list for CI workflow * Add debug step in CI workflow Add debug step to output OS list for CI workflow
1 parent 36c6668 commit 312e7e2

1 file changed

Lines changed: 47 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,46 @@ on:
55
branches:
66
- main
77
- master
8-
98
tags:
10-
- 'v*' #release tags in format of 'v25.12.00' for example
9+
- 'v*' #release tags in format of e.g: 'v25.12.00'
1110

1211
pull_request:
1312
types: [opened, synchronize, reopened, labeled]
1413

14+
workflow_dispatch:
15+
inputs:
16+
full_build:
17+
description: "Run full build (including macOS)"
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
1523
jobs:
24+
prepare:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
os_list: ${{ steps.set.outputs.os_list }}
28+
steps:
29+
- id: set
30+
run: |
31+
if [[ "${{ github.event_name }}" == "pull_request" ]] ||
32+
[[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" != refs/tags/v* ]] ||
33+
[[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.full_build }}" != "true" ]]; then
34+
echo 'os_list=["ubuntu-22.04","windows-2022"]' >> $GITHUB_OUTPUT
35+
else
36+
echo 'os_list=["ubuntu-22.04","windows-2022","macos-14"]' >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Debug
40+
run: echo '${{ steps.set.outputs.os_list }}'
41+
1642
build-and-test:
43+
needs: prepare
1744
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} / MeshRefinement=${{ matrix.with_mesh_refinement }}
45+
1846
if: >
19-
github.event_name == 'push' ||
47+
github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') ||
2048
(
2149
github.event_name == 'pull_request' &&
2250
(
@@ -32,8 +60,10 @@ jobs:
3260

3361
strategy:
3462
fail-fast: false
63+
3564
matrix:
36-
os: [ubuntu-22.04, macos-14, windows-2022]
65+
os: ${{ fromJSON(needs.prepare.outputs.os_list) }}
66+
3767
sofa_branch: [master]
3868
with_mesh_refinement: [ON, OFF]
3969

@@ -66,16 +96,15 @@ jobs:
6696
if [[ "$RUNNER_OS" == "Windows" ]]; then
6797
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
6898
&& cd /d %GITHUB_WORKSPACE%/deps/MeshRefinement/build \
69-
&& cmake \
70-
-GNinja \
99+
&& cmake -GNinja \
71100
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
72101
-DCMAKE_BUILD_TYPE=Release \
73102
-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%/deps/MeshRefinement/install \
74103
.. \
75104
&& ninja install"
76105
# Temp hack
77106
cp deps/MeshRefinement/install/bin/MeshRefinement.dll "$WORKSPACE_BUILD_PATH/"
78-
107+
79108
else
80109
cd deps/MeshRefinement/build
81110
cmake \
@@ -92,17 +121,16 @@ jobs:
92121
- name: Checkout current source code
93122
uses: actions/checkout@v4
94123
with:
95-
path: ${{ env.WORKSPACE_SRC_PATH }}
96-
124+
path: ${{ env.WORKSPACE_SRC_PATH }}
125+
97126
################ Build and install current plugin ##############
98127
- name: Build and install
99128
shell: bash
100129
run: |
101130
if [[ "$RUNNER_OS" == "Windows" ]]; then
102131
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
103132
&& cd /d %GITHUB_WORKSPACE%/build \
104-
&& cmake \
105-
-GNinja \
133+
&& cmake -GNinja \
106134
-DCMAKE_PREFIX_PATH=%SOFA_ROOT%/lib/cmake;%GITHUB_WORKSPACE%/deps/MeshRefinement/install \
107135
-DCMAKE_BUILD_TYPE=Release \
108136
-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%/install \
@@ -122,10 +150,10 @@ jobs:
122150
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$WORKSPACE_BUILD_PATH/lib" \
123151
../src
124152
ninja install
125-
echo ${CCACHE_BASEDIR}
126153
ccache -s
127154
fi
128-
155+
156+
################### Artifact naming ##############
129157
- name: Sanitize artifact name
130158
id: sanitize
131159
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
@@ -158,10 +186,9 @@ jobs:
158186
with:
159187
name: ${{ steps.sanitize.outputs.artifact_name }}
160188
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}
161-
162189

163-
- name: Launch test
164-
id: tests
190+
################### Tests ##############
191+
- name: Launch test
165192
uses: sofa-framework/sofa-test-action@v1.0
166193
with:
167194
sofa_root: ${{ github.workspace }}/sofa
@@ -173,13 +200,14 @@ jobs:
173200
nb_parallel_threads: '4'
174201

175202

176-
203+
################### Create plugin artifacts ##############
177204
deploy:
178205
name: Deploy artifacts
179-
if: always() && startsWith(github.ref, 'refs/tags/')
206+
if: startsWith(github.ref, 'refs/tags/v')
180207
needs: [build-and-test]
181208
runs-on: ubuntu-latest
182209
continue-on-error: true
210+
183211
steps:
184212
- name: Get artifacts
185213
uses: actions/download-artifact@v4.1.7
@@ -193,6 +221,7 @@ jobs:
193221
for artifact in *; do
194222
zip $artifact.zip -r $artifact/*
195223
done
224+
196225
- name: Upload release
197226
uses: softprops/action-gh-release@v1
198227
with:
@@ -204,4 +233,3 @@ jobs:
204233
artifacts/InfinyToolkit_*_Linux.zip
205234
artifacts/InfinyToolkit_*_Windows.zip
206235
artifacts/InfinyToolkit_*_macOS.zip
207-

0 commit comments

Comments
 (0)