Skip to content

Commit 42fb152

Browse files
committed
Temp commit 1
1 parent ebc90cd commit 42fb152

9 files changed

Lines changed: 341 additions & 52 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
3+
# *******************************************************************************
4+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
5+
#
6+
# See the NOTICE file(s) distributed with this work for additional
7+
# information regarding copyright ownership.
8+
#
9+
# This program and the accompanying materials are made available under the
10+
# terms of the Apache License Version 2.0 which is available at
11+
# https://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# SPDX-License-Identifier: Apache-2.0
14+
# *******************************************************************************
15+
16+
import http.cookiejar
17+
import json
18+
import netrc
19+
import os
20+
import sys
21+
import urllib.parse
22+
import urllib.request
23+
24+
25+
def eprint(*args, **kwargs):
26+
print(*args, file=sys.stderr, **kwargs)
27+
28+
29+
if __name__ == "__main__":
30+
data = json.load(sys.stdin)
31+
32+
if "qnx.com" not in data["uri"]:
33+
eprint("Unsupported domain")
34+
sys.exit(1)
35+
36+
if "SCORE_QNX_USER" in os.environ and "SCORE_QNX_PASSWORD" in os.environ:
37+
login = os.environ["SCORE_QNX_USER"]
38+
password = os.environ["SCORE_QNX_PASSWORD"]
39+
else:
40+
try:
41+
nrc = netrc.netrc()
42+
auth = nrc.authenticators("qnx.com")
43+
if auth:
44+
login, _, password = auth
45+
else:
46+
raise Exception("No credential found for QNX")
47+
except Exception as excp:
48+
eprint(excp)
49+
eprint("Failed getting credentials from .netrc")
50+
sys.exit(1)
51+
52+
data = urllib.parse.urlencode(
53+
{"userlogin": login, "password": password, "UseCookie": "1"}
54+
)
55+
data = data.encode("ascii")
56+
57+
cookie_jar = http.cookiejar.CookieJar()
58+
cookie_processor = urllib.request.HTTPCookieProcessor(cookie_jar)
59+
opener = urllib.request.build_opener(cookie_processor)
60+
urllib.request.install_opener(opener)
61+
62+
r = urllib.request.urlopen("https://www.qnx.com/account/login.html", data)
63+
if r.status != 200:
64+
eprint("Failed to login to QNX")
65+
sys.exit(1)
66+
67+
cookies = {c.name: c.value for c in list(cookie_jar)}
68+
if not "myQNX" in cookies:
69+
eprint("Failed to get myQNX cookie from login page")
70+
sys.exit(1)
71+
72+
myQNX = cookies["myQNX"]
73+
print(
74+
json.dumps(
75+
{
76+
"headers": {
77+
"Cookie": [f"myQNX={myQNX}"],
78+
}
79+
}
80+
)
81+
)

.github/workflows/qnx.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
name: Bazel Build (QNX)
14+
on:
15+
pull_request:
16+
types: [opened, reopened, synchronize]
17+
push:
18+
branches:
19+
- main
20+
merge_group:
21+
types: [checks_requested]
22+
workflow_call:
23+
jobs:
24+
qnx-build:
25+
name: Build and Test ${{ matrix.bazel-config }}
26+
runs-on: ${{ vars.runner_labels_ghub_standard_x64 && fromJSON(vars.runner_labels_ghub_standard_x64) || vars.REPO_RUNNER_LABELS && fromJSON(vars.REPO_RUNNER_LABELS) || 'ubuntu-latest' }}
27+
permissions:
28+
contents: read
29+
pull-requests: read
30+
# Bazel test targets live in the separate `tests` module, so run all Bazel
31+
# commands from that directory. `defaults.run.working-directory` applies to
32+
# `run:` steps only; `uses:` action steps still execute from the repo root.
33+
defaults:
34+
run:
35+
working-directory: ./tests
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
include:
40+
- bazel-config: x86_64-qnx
41+
bazel-test-target: "//:all_tests"
42+
- bazel-config: aarch64-qnx
43+
bazel-test-target: "//:all_tests"
44+
extra-bazel-test-flags: "--test_timeout=120,600,1800,7200" # Increase test timeout due to QEMU emulation
45+
steps:
46+
- uses: eclipse-score/more-disk-space@6a3b48901846bf7f8cc985925157d71a8973e61f # v1
47+
with:
48+
level: 2
49+
- name: Checkout repository (Handle all events)
50+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
51+
with:
52+
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }}
53+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
54+
- name: Setup Bazel with shared caching
55+
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 #v0.19.0
56+
with:
57+
disk-cache: ${{ matrix.bazel-config }}
58+
repository-cache: true
59+
bazelisk-cache: true
60+
cache-save: ${{ github.event_name == 'push' }}
61+
- uses: eclipse-score/cicd-actions/unblock-user-namespace-for-linux-sandbox@30ed908edcf367bc38ebff5b386a244f9b6417a7 # 2025-06-04
62+
- name: Setup QNX SDP usage
63+
uses: eclipse-score/cicd-actions/setup-qnx-sdp@a2b3c36fc7d1b9d03880d19935c7ac9cfffe58c6 # 2026-05-19
64+
with:
65+
qnx-license: ${{ secrets.SCORE_QNX_LICENSE }}
66+
qnx-user: ${{ secrets.SCORE_QNX_USER }}
67+
qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }}
68+
qnx-credential-helper: .github/tools/qnx_credential_helper.py
69+
qnx-license-dir: /opt/score_qnx/license
70+
- name: Build with QNX toolchain
71+
run: |
72+
set -euo pipefail
73+
74+
bazel build --config ${{ matrix.bazel-config }} \
75+
--credential_helper=*.qnx.com="${QNX_CREDENTIAL_HELPER}" -- \
76+
//:all_tests
77+
- name: Install qemu
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get install -y qemu-system
81+
- name: Enable KVM group permissons
82+
run: |
83+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
84+
sudo udevadm control --reload-rules
85+
sudo udevadm trigger --name-match=kvm
86+
- name: Test with QNX toolchain
87+
run: |
88+
set -euo pipefail
89+
90+
bazel test --config ${{ matrix.bazel-config }} \
91+
--test_output=errors \
92+
--credential_helper=*.qnx.com="${QNX_CREDENTIAL_HELPER}" ${{ matrix.extra-bazel-test-flags }} -- \
93+
${{ matrix.bazel-test-target }}
94+
- name: Dump test logs on failure
95+
if: failure()
96+
run: |
97+
echo "===== Bazel test logs ====="
98+
# `bazel-testlogs` is a convenience symlink in the workspace root (./tests).
99+
find -L bazel-testlogs -name 'test.log' -print | while read -r log; do
100+
echo ""
101+
echo "----- ${log} -----"
102+
cat "${log}"
103+
done

tests/.bazelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,27 @@ build:x86_64-linux-bp --extra_toolchains=@score_gcc_toolchain_bp//:x86_64-linux
4747
build:x86_64-qnx --config=x86_64-linux
4848
build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix
4949
build:x86_64-qnx --extra_toolchains=@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0
50+
build:x86_64-qnx --extra_toolchains=@score_qnx_x86_64_ifs_toolchain//:ifs-x86_64-qnx-sdp_8.0.0
51+
# QNX binaries cannot run natively on the x86_64 Linux host; execute them under
52+
# the QNX emulator (requires qemu-system + KVM on the runner).
53+
test:x86_64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
54+
# Only run native (cc) test binaries under the QNX emulator. Host-side tests
55+
# such as the bash-script guardrail cannot execute inside the QNX VM.
56+
test:x86_64-qnx --test_lang_filters=cc
5057

5158
# -------------------------------------------------------------------------------
5259
# Toolchain configuration for aarch64-qnx (target)
5360
# -------------------------------------------------------------------------------
5461
build:aarch64-qnx --config=x86_64-linux
5562
build:aarch64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix
5663
build:aarch64-qnx --extra_toolchains=@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0
64+
build:aarch64-qnx --extra_toolchains=@score_qnx_aarch64_ifs_toolchain//:ifs-aarch64-qnx-sdp_8.0.0
65+
# QNX binaries cannot run natively on the x86_64 Linux host; execute them under
66+
# the QNX emulator (requires qemu-system + KVM on the runner).
67+
test:aarch64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
68+
# Only run native (cc) test binaries under the QNX emulator. Host-side tests
69+
# such as the bash-script guardrail cannot execute inside the QNX VM.
70+
test:aarch64-qnx --test_lang_filters=cc
5771

5872
# -------------------------------------------------------------------------------
5973
# Toolchain configuration for aarch64-linux (target)

tests/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,19 @@ test_suite(
6363
"//guardrails:no_legacy_features_guard_test",
6464
],
6565
)
66+
67+
# ============================================================================
68+
# Aggregate Test Suite
69+
#
70+
# Combines every test category into a single target. CI should depend on this
71+
# target so new tests only need to be added to the relevant suite above.
72+
# ============================================================================
73+
74+
test_suite(
75+
name = "all_tests",
76+
tests = [
77+
":feature_verification_tests",
78+
":guardrail_tests",
79+
":language_and_standards_tests",
80+
],
81+
)

tests/MODULE.bazel

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bazel_dep(name = "rules_go", version = "0.61.1")
2525
# *******************************************************************************
2626
# Common useful functions and rules for Bazel
2727
# *******************************************************************************
28-
bazel_dep(name = "bazel_skylib", version = "1.8.2")
28+
bazel_dep(name = "bazel_skylib", version = "1.9.0")
2929

3030
# *******************************************************************************
3131
# Constraint values for specifying platforms and toolchains
@@ -39,6 +39,12 @@ bazel_dep(name = "score_bazel_platforms", version = "0.1.2")
3939
bazel_dep(name = "rules_cc", version = "0.2.17")
4040
bazel_dep(name = "googletest", version = "1.17.0")
4141

42+
# *******************************************************************************
43+
# QNX unit-test runner (provides //src:run_under_qnx used to execute QNX test
44+
# binaries under emulation via --run_under on the QNX configs).
45+
# *******************************************************************************
46+
bazel_dep(name = "score_qnx_unit_tests", version = "0.2.0", dev_dependency = True)
47+
4248
# *******************************************************************************
4349
# Set dependency to Bazel C/C++ Toolchain repository - with overriding path
4450
# *******************************************************************************
@@ -133,7 +139,7 @@ gcc.toolchain(
133139
# *******************************************************************************
134140
gcc.toolchain(
135141
name = "score_qcc_arm_toolchain",
136-
sdp_version = "8.0.0",
142+
sdp_version = "8.0.4",
137143
target_cpu = "aarch64",
138144
target_os = "qnx",
139145
use_default_package = True,
@@ -170,5 +176,38 @@ use_repo(
170176
"score_gcc_toolchain",
171177
"score_gcc_toolchain_bp",
172178
"score_qcc_arm_toolchain",
179+
"score_qcc_arm_toolchain_pkg",
173180
"score_qcc_toolchain",
181+
"score_qcc_toolchain_pkg",
182+
)
183+
184+
# *******************************************************************************
185+
# Set dependency to Bazel ImageFS repository
186+
# *******************************************************************************
187+
bazel_dep(name = "score_rules_imagefs", version = "0.0.3", dev_dependency = True)
188+
189+
# *******************************************************************************
190+
# Setting ImageFS toolchains (CPU:x86_64|OS:QNX|version(sdp):8.0.0)
191+
# *******************************************************************************
192+
imagefs = use_extension("@score_rules_imagefs//extensions:imagefs.bzl", "imagefs", dev_dependency = True)
193+
imagefs.toolchain(
194+
name = "score_qnx_x86_64_ifs_toolchain",
195+
sdp_to_import = "@score_qcc_toolchain_pkg",
196+
sdp_version = "8.0.0",
197+
target_cpu = "x86_64",
198+
target_os = "qnx",
199+
type = "ifs",
200+
)
201+
202+
# *******************************************************************************
203+
# Setting ImageFS toolchains (CPU:aarch64|OS:QNX|version(sdp):8.0.0)
204+
# *******************************************************************************
205+
imagefs.toolchain(
206+
name = "score_qnx_aarch64_ifs_toolchain",
207+
sdp_to_import = "@score_qcc_arm_toolchain_pkg",
208+
sdp_version = "8.0.0",
209+
target_cpu = "aarch64",
210+
target_os = "qnx",
211+
type = "ifs",
174212
)
213+
use_repo(imagefs, "score_qnx_aarch64_ifs_toolchain", "score_qnx_x86_64_ifs_toolchain")

0 commit comments

Comments
 (0)