CI/CD Workflows#
After building and testing the module locally, we need to ensure that future changes do not break it. In Eclipse S-CORE, this is done by GitHub Actions workflows which run on every pull request. Instead of implementing the workflow logic in every repository, most workflows call the reusable workflows from eclipse-score/cicd-workflows.
Workflows of a module repository#
The module template already contains the basic workflows:
Workflow |
Purpose |
|---|---|
|
Runs the pre-commit checks on every pull request, e.g. whitespace, copyright and REUSE headers, YAML formatting and the Bazel lockfile |
|
Runs the license check with the Eclipse Dash license tool |
|
Builds the documentation and publishes it to GitHub Pages |
|
Daily maintenance, e.g. cleanup of outdated documentation previews |
|
Opens a pull request with the changes of the template once a month, see First Eclipse S-CORE Module |
The documentation workflow shows the typical pattern: a short workflow file in the module repository which calls a
reusable workflow, pinned to a commit of cicd-workflows:
1name: Documentation CI
2on:
3 pull_request:
4 push:
5 branches:
6 - main
7 tags:
8 - "v*"
9 release:
10 types: [published]
11 merge_group:
12 types: [checks_requested]
13
14jobs:
15 build-docs:
16 uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
17 permissions:
18 contents: write
19 pages: write
20 pull-requests: write
21 id-token: write
22 with:
23 bazel-target: "--lockfile_mode=error //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
24 retention-days: 3
Line 2 defines when the workflow runs: for every pull request, for changes on
main, for release tags and published releases, and in the merge queue.Line 16 calls the reusable workflow. Pin it to a commit (and note the version in a comment), so that changes in
cicd-workflowsdo not unexpectedly change your pipeline.Line 23 passes the Bazel command that the reusable workflow executes, here the documentation build from the documentation generation chapter.
Build and test workflow#
None of the template’s workflows compiles the code or runs the tests: they check formatting, headers and licenses
and build the documentation. Add a workflow which builds and tests your code for the supported platforms,
e.g. .github/workflows/build.yml.
The reusable workflows tests.yml and qnx-build.yml take care of the Bazel setup, the caches and,
for QNX, the license handling:
1name: Build & Test
2on:
3 pull_request:
4 types: [opened, reopened, synchronize]
5 merge_group:
6 types: [checks_requested]
7jobs:
8 linux:
9 uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
10 permissions:
11 contents: read
12 pull-requests: read
13 with:
14 bazel-target: "test --config=score-linux-x86_64 //score/..."
15
16 qnx:
17 # Pull requests from forks get no secrets: build QNX only for own branches and in the merge queue.
18 if: github.event_name == 'merge_group' || github.event.pull_request.head.repo.full_name == github.repository
19 uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
20 permissions:
21 contents: read
22 pull-requests: read
23 with:
24 bazel-target: "//score/..."
25 bazel-config: "score-qnx-x86_64"
26 secrets:
27 score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }}
28 score-qnx-user: ${{ secrets.SCORE_QNX_USER }}
29 score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }}
Lines 8 and 14: the job
linuxbuilds and runs all tests for Linux x86_64 with the same Bazel command you use locally.Line 16: the job
qnxcross-compiles the code with the QNX toolchain.Line 18: workflows triggered by
pull_requestdon’t get the repository secrets for pull requests from forks, so the QNX job only runs for pull requests from branches of your repository and in the merge queue. The persistency repository uses the same condition.qnx-build.ymlalso supports an approval-gated QNX build for forks, which needs a separate workflow triggered bypull_request_target.Line 25: the build configuration from the build and test chapter.
Line 27: the QNX license and credentials are provided as organization secrets by the CI infrastructure. The QNX job also expects the credential helper script
.github/tools/qnx_credential_helper.py, which is not part of the template; copy it e.g. from the persistency repository or pass another path with the inputcredential-helper.
Once the workflow is merged into the repository, every new pull request automatically triggers the build, and its result is shown in the Actions tab of your repository and in the checks of the pull request. The reusable workflows provide further checks, e.g. static code analysis, coverage and CodeQL scans; they are listed in the cicd-workflows README.
Attention
If the documentation should show the test results, as described in
documentation generation, the test results have to be handed over to the documentation
build: the reusable workflows run in separate jobs with separate workspaces. Upload the results in the test job
with upload-name and download them in the documentation job with tests-report-artifact. Both jobs must be
in the same workflow, and the documentation job has to wait for the test job (excerpt):
jobs:
linux:
uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
with:
bazel-target: "test --config=score-linux-x86_64 //score/..."
upload-name: "tests-report"
build-docs:
needs: linux
uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
with:
tests-report-artifact: "tests-report"
The template’s documentation workflow only builds the documentation, so its published documentation shows the links from requirements to code, but no test results.
The next chapter shows where to find examples of how the S-CORE modules are used and how your module gets into the S-CORE platform.