CI/CD Workflows#
After successfully building the scrample binary, we need to ensure, that future changes do not breakt the build.
To achieve this, we create a CI/CD workflow that triggers a GitHub action to build the scrample application whenever a new PR is opened.
To achieve this, first create a workflow file named build.yml in the .github folder.
Then fill the workflow file with the following content:
1name: Scrample Build
2on:
3 pull_request:
4 types: [opened, reopened, synchronize]
5 merge_group:
6 types: [checks_requested]
7jobs:
8 build_target:
9 runs-on: ubuntu-latest
10 steps:
11 - name: Checkout repository
12 uses: actions/checkout@v4.2.2
13 - name: Setup Bazel
14 uses: bazel-contrib/setup-bazel@0.9.1
15 - name: Setup QNX License
16 env:
17 SCORE_QNX_LICENSE: ${{ secrets.SCORE_QNX_LICENSE }}
18 run: |
19 mkdir -p /opt/score_qnx/license
20 echo "${SCORE_QNX_LICENSE}" | base64 --decode > /opt/score_qnx/license/licenses
21 - name: Bazel build scrample with qnx toolchain
22 env:
23 SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }}
24 SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }}
25 run: |
26 bazel build --config x86_64-qnx --credential_helper=*.qnx.com=${{ github.workspace }}/.github/tools/qnx_credential_helper.py -- \
27 //src:scrample
28 - name: Cleanup QNX License
29 if: always()
30 run: rm -rf /opt/score_qnx
First, as shown in line 2 we define when the workflow should run. In this case, it is triggered whenever a PR is opened, created or synchronized.
Next, we specify the job to be executed. For now, there is a single job that builds the scrample application, as shown in the line 8. Finally, we need to define the steps of the build job:
Line 11: checkout the repository.
Line 13: set up bazel.
Line 15: set up the QNX license using the CI secrets stored in the CI infrastructure.
Line 21: uild the scrample binary using the same bazel command executed locally.
Line 28: clean-up temporary QNX files from the remote build machine.
Once the workflow is merged into the repository, every new PR we will automatically trigger the build and its result in the Actions sections.