1+ name : Build with CMake and GCC
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ runner :
7+ description : ' Which runner to use'
8+ required : false
9+ default : ' ubuntu-24.04'
10+ type : string
11+ ref_everest_ci :
12+ description : ' The reference of the everest-ci repository to checkout'
13+ required : true
14+ type : string
15+ is_fork :
16+ description : ' Whether the current repository is a fork'
17+ required : true
18+ type : string
19+ build-kit-artifact-name :
20+ description : ' The name of the build-kit artifact to download'
21+ required : true
22+ type : string
23+ build_kit_image_tag :
24+ description : ' The tag of the build-kit image to use for building the project'
25+ required : true
26+ type : string
27+ build_kit_scripts_directory :
28+ description : ' Directory in the repository where the build kit scripts are located'
29+ required : false
30+ default : ' .ci/build-kit/scripts'
31+ type : string
32+ ctest_report_path :
33+ description : ' The path to the ctest report, relative to the github workspace'
34+ required : false
35+ default : ' build/Testing/Temporary/LastTest.log'
36+ type : string
37+ coverage_report_path :
38+ description : ' The path to the coverage report, relative to the github workspace'
39+ required : false
40+ default : ' build/gcovr-coverage'
41+ type : string
42+ coverage_xml_path :
43+ description : ' The path to the coverage xml, relative to the github workspace'
44+ required : false
45+ default : ' build/coverage.xml'
46+ type : string
47+ artifact_deploy_target_repo :
48+ description : ' Repository to deploy artifacts to'
49+ required : true
50+ type : string
51+ wheels_path :
52+ description : ' The path to the wheels directory, relative to the github workspace'
53+ required : false
54+ default : ' wheels'
55+ type : string
56+ secrets :
57+ coverage_deploy_token :
58+ description : ' The token to use to deploy the coverage report'
59+ required : true
60+ SA_GITHUB_SSH_KEY :
61+ description : ' The ssh key to use for git operations'
62+ required : false
63+ outputs :
64+ ctest_report_artifact_name :
65+ description : ' The name of the ctest report artifact uploaded'
66+ value : ${{ jobs.build-cmake-gcc.outputs.ctest_report_artifact_name }}
67+ coverage_report_artifact_name :
68+ description : ' The name of the coverage report artifact uploaded'
69+ value : ${{ jobs.build-cmake-gcc.outputs.coverage_report_artifact_name }}
70+ coverage_xml_artifact_name :
71+ description : ' The name of the coverage xml artifact uploaded'
72+ value : ${{ jobs.build-cmake-gcc.outputs.coverage_xml_artifact_name }}
73+ dist_artifact_name :
74+ description : ' The name of the dist artifact uploaded'
75+ value : ${{ jobs.build-cmake-gcc.outputs.dist_artifact_name }}
76+ wheels_artifact_name :
77+ description : ' The name of the wheels artifact uploaded'
78+ value : ${{ jobs.build-cmake-gcc.outputs.wheels_artifact_name }}
79+
80+ jobs :
81+ build-cmake-gcc :
82+ name : Build with CMake and GCC, Unit Tests and Install
83+ runs-on : ${{ inputs.runner }}
84+ env :
85+ CTEST_REPORT_ARTIFACT_NAME : ctest-report
86+ COVERAGE_REPORT_ARTIFACT_NAME : coverage-report
87+ COVERAGE_XML_ARTIFACT_NAME : coverage-xml
88+ DIST_ARTIFACT_NAME : dist
89+ WHEELS_ARTIFACT_NAME : wheels
90+ BUILD_KIT_IMAGE : ${{ inputs.build_kit_image_tag }}
91+ SSH_AUTH_SOCK : /tmp/ssh_agent.sock
92+ outputs :
93+ ctest_report_artifact_name : ${{ env.CTEST_REPORT_ARTIFACT_NAME }}
94+ coverage_report_artifact_name : ${{ env.COVERAGE_REPORT_ARTIFACT_NAME }}
95+ coverage_xml_artifact_name : ${{ env.COVERAGE_XML_ARTIFACT_NAME }}
96+ dist_artifact_name : ${{ env.DIST_ARTIFACT_NAME }}
97+ wheels_artifact_name : ${{ env.WHEELS_ARTIFACT_NAME }}
98+ steps :
99+ - name : Setup SSH Agent, optional with SSH key
100+ env :
101+ SSH_KEY : ${{ secrets.SA_GITHUB_SSH_KEY }}
102+ run : |
103+ ssh-agent -a $SSH_AUTH_SOCK > /dev/null
104+ if [ -z "${{ env.SSH_KEY }}" ]; then
105+ echo "No SSH key provided, skipping SSH key setup"
106+ exit 0
107+ fi
108+ mkdir -p ~/.ssh
109+ echo "${{ env.SSH_KEY }}" > ~/.ssh/id_ed25519
110+ chmod 600 ~/.ssh/id_ed25519
111+ # Check if github.com is already in known_hosts, if not, add it
112+ if ! grep -q "^github.com " ~/.ssh/known_hosts; then
113+ ssh-keyscan github.com >> ~/.ssh/known_hosts
114+ fi
115+ ssh-add ~/.ssh/id_ed25519
116+ - name : Checkout local github actions
117+ uses : actions/checkout@v4
118+ with :
119+ repository : everest/everest-ci
120+ ref : ${{ inputs.ref_everest_ci }}
121+ path : everest-ci
122+ - name : Format branch name for cache key
123+ run : |
124+ BRANCH_NAME_FOR_CACHE="${GITHUB_REF_NAME//-/_}"
125+ echo "branch_name_for_cache=${BRANCH_NAME_FOR_CACHE}" >> "$GITHUB_ENV"
126+ - name : Setup cache
127+ uses : actions/cache@v4
128+ with :
129+ path : cache
130+ key : compile-${{ env.branch_name_for_cache }}-${{ github.sha }}
131+ restore-keys : |
132+ compile-${{ env.branch_name_for_cache }}-
133+ compile-
134+ - name : Checkout repository
135+ uses : actions/checkout@v4
136+ with :
137+ path : source
138+ - name : Setup run scripts
139+ run : |
140+ mkdir scripts
141+ rsync -a source/${{ inputs.build_kit_scripts_directory }}/ scripts
142+ - name : Download build-kit image
143+ uses : actions/download-artifact@v5
144+ with :
145+ name : ${{ inputs.build-kit-artifact-name }}
146+ - name : Load build-kit image
147+ run : |
148+ docker load -i build-kit.tar
149+ docker image tag ${{ env.BUILD_KIT_IMAGE }} build-kit
150+ - name : Compile
151+ run : |
152+ docker run \
153+ --mount type=bind,source=$SSH_AUTH_SOCK,target=/ssh-agent \
154+ --env SSH_AUTH_SOCK=/ssh-agent \
155+ --volume "${{ github.workspace }}:/ext" \
156+ --name compile-container \
157+ build-kit run-script compile
158+ - name : Run unit tests
159+ id : run_unit_tests
160+ run : |
161+ docker run \
162+ --mount type=bind,source=$SSH_AUTH_SOCK,target=/ssh-agent \
163+ --env SSH_AUTH_SOCK=/ssh-agent \
164+ --volume "${{ github.workspace }}:/ext" \
165+ --name unit-test-container \
166+ build-kit run-script run_unit_tests
167+ - name : Archive test results
168+ if : ${{ always() && (steps.run_unit_tests.outcome == 'success' || steps.run_unit_tests.outcome == 'failure') }}
169+ uses : actions/upload-artifact@v4
170+ with :
171+ if-no-files-found : error
172+ name : ${{ env.CTEST_REPORT_ARTIFACT_NAME }}
173+ path : ${{ inputs.ctest_report_path }}
174+ # - name: Run coverage
175+ # id: run_coverage
176+ # run: |
177+ # docker run \
178+ # --mount type=bind,source=$SSH_AUTH_SOCK,target=/ssh-agent \
179+ # --env SSH_AUTH_SOCK=/ssh-agent \
180+ # --volume "${{ github.workspace }}:/ext" \
181+ # --name coverage-container \
182+ # build-kit run-script run_coverage
183+ # - name: Archive coverage report
184+ # if: ${{ always() && (steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure') }}
185+ # uses: actions/upload-artifact@v4
186+ # with:
187+ # if-no-files-found: error
188+ # name: ${{ env.COVERAGE_REPORT_ARTIFACT_NAME }}
189+ # path: ${{ inputs.coverage_report_path }}
190+ # - name: Archive coverage xml
191+ # if: ${{ always() && (steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure') }}
192+ # uses: actions/upload-artifact@v4
193+ # with:
194+ # if-no-files-found: error
195+ # name: ${{ env.COVERAGE_XML_ARTIFACT_NAME }}
196+ # path: ${{ inputs.coverage_xml_path}}
197+ # - name: Deploy html coverage report
198+ # id: deploy_coverage_report
199+ # if: ${{ always() && ( steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure' ) && inputs.is_fork == 'false' }}
200+ # uses: ./everest-ci/github-actions/deploy-ci-artifact
201+ # with:
202+ # target_repo: ${{ inputs.artifact_deploy_target_repo }}
203+ # github_token: ${{ secrets.coverage_deploy_token }}
204+ # artifact_name: coverage-report
205+ # artifact_directory: ${{ inputs.coverage_report_path }}
206+ # - name: Write summary coverage
207+ # if: ${{ always() && (steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure') }}
208+ # run: |
209+ # echo "Coverage report deployed to: [everest.github.io](https://everest.github.io/${{ steps.deploy_coverage_report.outputs.deployed_path }})" >> $GITHUB_STEP_SUMMARY
210+ - name : Create dist
211+ id : create_dist
212+ run : |
213+ docker run \
214+ --mount type=bind,source=$SSH_AUTH_SOCK,target=/ssh-agent \
215+ --env SSH_AUTH_SOCK=/ssh-agent \
216+ --volume "${{ github.workspace }}:/ext" \
217+ --name dist-container \
218+ build-kit run-script install
219+ - name : Tar dist dir and keep permissions
220+ if : ${{ always() && (steps.create_dist.outcome == 'success' || steps.create_dist.outcome == 'failure') }}
221+ run : |
222+ tar -czf dist.tar.gz dist
223+ - name : Upload dist artifact
224+ if : ${{ always() && (steps.create_dist.outcome == 'success' || steps.create_dist.outcome == 'failure') }}
225+ uses : actions/upload-artifact@v4.6.2
226+ with :
227+ if-no-files-found : error
228+ path : dist.tar.gz
229+ name : ${{ env.DIST_ARTIFACT_NAME }}
230+ - name : Create wheels
231+ id : create_wheels
232+ run : |
233+ docker run \
234+ --mount type=bind,source=$SSH_AUTH_SOCK,target=/ssh-agent \
235+ --env SSH_AUTH_SOCK=/ssh-agent \
236+ --volume "${{ github.workspace }}:/ext" \
237+ --name wheels-container \
238+ build-kit run-script install_wheels
239+ - name : Upload wheels artifact
240+ if : ${{ always() && (steps.create_wheels.outcome == 'success' || steps.create_wheels.outcome == 'failure') }}
241+ uses : actions/upload-artifact@v4.6.2
242+ with :
243+ if-no-files-found : error
244+ path : ${{ inputs.wheels_path }}
245+ name : ${{ env.WHEELS_ARTIFACT_NAME }}
0 commit comments