-
Notifications
You must be signed in to change notification settings - Fork 344
226 lines (200 loc) · 10.3 KB
/
trigger-build-and-tests.yml
File metadata and controls
226 lines (200 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Trigger build and tests
# ===============================================================
# ===============================================================
on:
# On-demand binary generation
workflow_dispatch:
inputs:
branch:
description: 'Specify the stable branch to use to generate the new binaries'
required: true
type: string
python_version:
description: 'Version of Python used'
required: true
default: '3.12'
type: string
external-plugins:
description: 'List of github repository and branch name to add to build tree, separated by a space. Syntax: https://www.github.com/me/myrepo@mybranch'
required: false
type: string
additionnal-cmake-flags:
description: 'CMake flags to add during the CMake call. This is to be used along external-plugins. The syntax is identical to a CMake call'
required: false
type: string
preset:
type: choice
description: Which preset to use for compilation
options:
- standard
- supported-plugins
- full
- standard-dev
- supported-plugins-dev
- full-dev
default: 'full-dev'
builder-os:
type: choice
description: On which OS run the binaries generation
options:
- '["sh-ubuntu_gcc_release"]'
- '["sh-macos_clang_release"]'
- '["sh-ubuntu_gcc_release","sh-macos_clang_release"]'
default: '["sh-ubuntu_gcc_release","sh-macos_clang_release"]'
# PR-related build (open, labels, push)
pull_request:
types: [opened, synchronize]
# CI for dashboard master
push:
branches:
- 'master'
- 'v25.12'
# ===============================================================
# ===============================================================
jobs:
# Filter build handling : push in master, commits in PR, comments in PR and dispatch
filter_build:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'sofa-framework' }}
outputs:
SOFA_BRANCH_NAME: ${{ steps.export-vars.outputs.SOFA_BRANCH_NAME }}
SOFA_COMMIT_SHA: ${{ steps.export-vars.outputs.SOFA_COMMIT_SHA }}
PRESET: ${{ steps.export-vars.outputs.PRESET }}
PYTHON_VERSION: ${{ steps.export-vars.outputs.PYTHON_VERSION }}
CI_DEPENDS_ON: ${{ steps.export-vars.outputs.CI_DEPENDS_ON }}
WITH_ALL_TESTS: ${{ steps.export-vars.outputs.WITH_ALL_TESTS }}
FORCE_FULL_BUILD: ${{ steps.export-vars.outputs.FORCE_FULL_BUILD }}
EXTERNAL_PLUGINS: ${{ steps.export-vars.outputs.EXTERNAL_PLUGINS }}
ADDITIONNAL_CMAKE_FLAGS: ${{ steps.export-vars.outputs.ADDITIONNAL_CMAKE_FLAGS }}
GENERATE_BINARIES: ${{ steps.export-vars.outputs.GENERATE_BINARIES }}
PR_OWNER_URL: ${{ steps.export-vars.outputs.PR_OWNER_URL }}
PR_BRANCH_NAME: ${{ steps.export-vars.outputs.PR_BRANCH_NAME }}
PR_COMMIT_SHA: ${{ steps.export-vars.outputs.PR_COMMIT_SHA }}
BUILDER_OS: ${{ steps.export-vars.outputs.BUILDER_OS }}
steps:
- name: Default values of environment variables
run: |
echo "SOFA_BRANCH_NAME=master" >> $GITHUB_ENV # SOFA_BRANCH_NAME: "master"
echo "SOFA_COMMIT_SHA=HEAD" >> $GITHUB_ENV # SOFA_COMMIT_SHA: "HEAD"
echo "PRESET=full-dev" >> $GITHUB_ENV # PRESET: "full-dev"
echo "PYTHON_VERSION=3.12" >> $GITHUB_ENV # PYTHON_VERSION: "3.12"
echo "CI_DEPENDS_ON=" >> $GITHUB_ENV # CI_DEPENDS_ON: ""
echo "WITH_ALL_TESTS=false" >> $GITHUB_ENV # WITH_ALL_TESTS: false
echo "FORCE_FULL_BUILD=false" >> $GITHUB_ENV # FORCE_FULL_BUILD: false
echo "EXTERNAL_PLUGINS=" >> $GITHUB_ENV # EXTERNAL_PLUGINS: ""
echo "ADDITIONNAL_CMAKE_FLAGS=" >> $GITHUB_ENV # ADDITIONNAL_CMAKE_FLAGS: ""
echo "GENERATE_BINARIES=false" >> $GITHUB_ENV # GENERATE_BINARIES: false
echo "PR_OWNER_URL=" >> $GITHUB_ENV # PR_OWNER_URL: ""
echo "PR_BRANCH_NAME=" >> $GITHUB_ENV # PR_BRANCH_NAME: ""
echo "PR_COMMIT_SHA=HEAD" >> $GITHUB_ENV # PR_COMMIT_SHA: "HEAD"
echo 'BUILDER_OS=["sh-ubuntu_gcc_release"]' >> $GITHUB_ENV # BUILDER_OS: ["sh-ubuntu_gcc_release"]
- name: Run on dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "This step runs only for binary generation."
BRANCH=${{ github.event.inputs.branch }}
PYTHON=${{ github.event.inputs.python_version }}
# Validate branch format (e.g., v25.06)
if [[ ! "$SOFA_BRANCH_NAME" =~ ^v[0-9]{2}\.[0-9]{2}$ && "$SOFA_BRANCH_NAME" != "master" ]]; then
echo "Error: Invalid branch name format: $BRANCH."
echo "Branch name should be either master or any release branch (e.g., v25.06)"
exit 1
fi
echo "Branch name $BRANCH is valid."
# Validate Python version format (e.g., 3.12)
if [[ ! "$PYTHON" =~ ^[0-9]{1}\.[0-9]{2}$ ]]; then
if [[ ! "$PYTHON" =~ ^3\.(9|1[0-8])$ ]]; then
echo "Error: Invalid Python version format: $PYTHON"
exit 1
fi
fi
echo "Python version $PYTHON is valid."
# Save all information in environment variables
echo "SOFA_BRANCH_NAME=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "SOFA_COMMIT_SHA=HEAD" >> $GITHUB_ENV
echo "PRESET=${{ github.event.inputs.preset }}" >> $GITHUB_ENV
echo "PYTHON_VERSION=${{ github.event.inputs.python_version }}" >> $GITHUB_ENV
echo "GENERATE_BINARIES=true" >> $GITHUB_ENV
echo 'BUILDER_OS=${{ github.event.inputs.builder-os }}' >> $GITHUB_ENV
echo "FORCE_FULL_BUILD=true" >> $GITHUB_ENV
echo "EXTERNAL_PLUGINS=${{ inputs.external-plugins }}" >> $GITHUB_ENV
echo "ADDITIONNAL_CMAKE_FLAGS=${{ inputs.additionnal-cmake-flags }}" >> $GITHUB_ENV
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install pip packages
run: |
pip install python-graphql-client
pip install requests
- name: Check out code
uses: actions/checkout@v5
with:
repository: sofa-framework/ci
ref: master
path: ./ci
- name: Check push on master case (e.g. merge)
if: ${{ github.event_name == 'push'}}
run: |
echo "This step runs only for push on the master branch."
echo "SOFA_COMMIT_SHA=${{ github.sha }}">> $GITHUB_ENV
echo "WITH_ALL_TESTS=true" >> $GITHUB_ENV
echo "FORCE_FULL_BUILD=true" >> $GITHUB_ENV
echo 'BUILDER_OS=["sh-ubuntu_gcc_release","sh-ubuntu_clang_release","sh-ubuntu_clang_debug","sh-fedora_clang_release","sh-macos_clang_release"]' >> $GITHUB_ENV
- name: Run when PR is opened or a commit is pushed in a PR
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
OWNER_NAME: ${{ github.event.pull_request.head.repo.owner.login }}
PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: |
echo "This step runs only when a PR is opened or synchronized."
# Trigger the Build action
# Warning ! This script also changes ENV variables
python ci/scripts/checkPRInfoBeforeBuild.py
- name: Export environment variables as outputs
id: export-vars
run: |
# Validate branch format (e.g., v25.06)
if [[ ! "$SOFA_BRANCH_NAME" =~ ^v[0-9]{2}\.[0-9]{2}$ && "$SOFA_BRANCH_NAME" != "master" ]]; then
echo "Error: Invalid branch name format: $SOFA_BRANCH_NAME."
echo "Branch name should be either master or any release branch (e.g., v25.06)"
exit 1
fi
echo "SOFA_BRANCH_NAME=${SOFA_BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "SOFA_COMMIT_SHA=${SOFA_COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "PRESET=${PRESET}" >> $GITHUB_OUTPUT
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_OUTPUT
echo "CI_DEPENDS_ON=${CI_DEPENDS_ON}" >> $GITHUB_OUTPUT
echo "WITH_ALL_TESTS=${WITH_ALL_TESTS}" >> $GITHUB_OUTPUT
echo "FORCE_FULL_BUILD=${FORCE_FULL_BUILD}" >> $GITHUB_OUTPUT
echo "EXTERNAL_PLUGINS=${EXTERNAL_PLUGINS}" >> $GITHUB_OUTPUT
echo "ADDITIONNAL_CMAKE_FLAGS=${ADDITIONNAL_CMAKE_FLAGS}" >> $GITHUB_OUTPUT
echo "GENERATE_BINARIES=${GENERATE_BINARIES}" >> $GITHUB_OUTPUT
echo "PR_OWNER_URL=${PR_OWNER_URL}" >> $GITHUB_OUTPUT
echo "PR_BRANCH_NAME=${PR_BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "PR_COMMIT_SHA=${PR_COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "BUILDER_OS=${BUILDER_OS}" >> $GITHUB_OUTPUT
# ===============================================================
# ===============================================================
# Trigger the build and sharing all parameters from filter_build > outputs
build-on:
needs: filter_build
if: ${{ github.repository_owner == 'sofa-framework' }}
uses: sofa-framework/sofa/.github/workflows/build-and-test.yml@master
with:
sofa-branch-name: ${{ needs.filter_build.outputs.SOFA_BRANCH_NAME }}
sofa-commit-sha: ${{ needs.filter_build.outputs.SOFA_COMMIT_SHA }}
preset: ${{ needs.filter_build.outputs.PRESET }}
python-version: ${{ needs.filter_build.outputs.PYTHON_VERSION }}
ci-depends-on: ${{ needs.filter_build.outputs.CI_DEPENDS_ON }}
with-all-tests: ${{ needs.filter_build.outputs.WITH_ALL_TESTS == 'true'}}
force-full-build: ${{ needs.filter_build.outputs.FORCE_FULL_BUILD == 'true'}}
external-plugins: ${{ needs.filter_build.outputs.EXTERNAL_PLUGINS }}
additionnal-cmake-flags: ${{ needs.filter_build.outputs.ADDITIONNAL_CMAKE_FLAGS }}
generate-binaries: ${{ needs.filter_build.outputs.GENERATE_BINARIES == 'true'}}
pr-owner-url: ${{ needs.filter_build.outputs.PR_OWNER_URL }}
pr-branch-name: ${{ needs.filter_build.outputs.PR_BRANCH_NAME }}
pr-commit-sha: ${{ needs.filter_build.outputs.PR_COMMIT_SHA }}
builder-os: ${{ needs.filter_build.outputs.BUILDER_OS }}