CI/CD Workflows#
After successfully building the binaries, we need to ensure that future changes do not break the build. 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 |
|
Keeps the repository in sync with later changes of the template |
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 merge_group:
10 types: [checks_requested]
11
12jobs:
13 build-docs:
14 uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
15 permissions:
16 contents: write
17 pages: write
18 pull-requests: write
19 id-token: write
20 with:
21 bazel-target: "--lockfile_mode=error //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
Line 2 defines when the workflow runs: for every pull request, for changes on
main, for release tags and in the merge queue.Line 14 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 21 passes the Bazel command that the reusable workflow executes, here the documentation build from the documentation generation chapter.
Build and test workflow#
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 uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3
18 permissions:
19 contents: read
20 pull-requests: read
21 with:
22 bazel-target: "//score/..."
23 bazel-config: "score-qnx-x86_64"
24 environment-name: "workflow-approval"
25 secrets:
26 score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }}
27 score-qnx-user: ${{ secrets.SCORE_QNX_USER }}
28 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 23: the build configuration from the building source code chapter.
Line 24: the QNX job runs in the GitHub environment
workflow-approval. It is created for every module repository and requires the approval of an S-CORE committer before the job gets access to the QNX secrets.Line 25: 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.
Workflows of the reference integration#
The running example is part of the reference integration, so it is checked by the workflows of that repository on every pull request:
Workflow |
What it checks for the example |
|---|---|
build_and_test_linux.yml,
|
Service and consumer build for every target platform and are packaged into the reference images |
Runs the platform integration tests ( |
|
|
Unpacks the release archives (platform and showcases) into plain Ubuntu and Debian containers,
runs all showcases there and requires |
|
Check that |
How the example gets into the reference images and how its test is defined is shown in the next chapter.