Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ inputs:
and keeps the original URL as fallback.
required: false
default: ""
repository-cache:
description: >
Whether to enable Bazel repository cache in setup-bazel.
Values: "true" or "false".
required: false
default: "false"

runs:
using: "composite"
Expand Down Expand Up @@ -73,7 +79,7 @@ runs:
with:
bazelisk-cache: true
disk-cache: false
repository-cache: false
repository-cache: ${{ fromJSON(inputs.repository-cache) }}
cache-save: ${{ env.CACHE_MODE != 'read-only' && env.CACHE_MODE != 'disabled' }}

- name: Register post cache save hook and restore caches
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: "Setup QNX and QEMU environment"
description: "Installs QEMU/KVM prerequisites, configures QNX license, and cleans up in post step."

inputs:
qnx-license:
description: "Base64-encoded QNX license payload."
required: true
license-dir:
description: "QNX license directory."
required: false
default: "/opt/score_qnx/license"

runs:
using: "node24"
main: "main.js"
post: "post.js"
post-if: "always()"
49 changes: 49 additions & 0 deletions .github/actions/00_infrastructure/setup_qnx_environment/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************

const { execSync } = require("node:child_process");
const { appendFileSync } = require("node:fs");

function run(command) {
execSync(command, { stdio: "inherit" });
}

function main() {
const licenseDir = process.env["INPUT_LICENSE-DIR"] || "/opt/score_qnx/license";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: We are defining the default here but also in the yml file.

const qnxLicense = process.env["INPUT_QNX-LICENSE"] || "";
const githubState = process.env.GITHUB_STATE;

if (!qnxLicense) {
throw new Error("Input 'qnx-license' is required.");
}
if (!githubState) {
throw new Error("GITHUB_STATE is not available.");
}

appendFileSync(githubState, `LICENSE_DIR=${licenseDir}\n`, { encoding: "utf-8" });

run("sudo apt-get update");
run("sudo apt-get install -y qemu-system");
run(
"echo 'KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0666\", OPTIONS+=\"static_node=kvm\"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules",
);
run("sudo udevadm control --reload-rules");
run("sudo udevadm trigger --name-match=kvm");

const escapedLicenseDir = `'${licenseDir.replace(/'/g, `'\\''`)}'`;
const escapedLicense = qnxLicense.replace(/'/g, `'\\''`);
run(`sudo mkdir -p ${escapedLicenseDir}`);
run(`echo '${escapedLicense}' | base64 --decode | sudo tee ${escapedLicenseDir}/licenses >/dev/null`);
}

main();
22 changes: 22 additions & 0 deletions .github/actions/00_infrastructure/setup_qnx_environment/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************

const { execSync } = require("node:child_process");

function main() {
const licenseDir = process.env.STATE_LICENSE_DIR || "/opt/score_qnx/license";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: And as in 1cb242a#r3680485623, we also define the default one more time

const escapedLicenseDir = `'${licenseDir.replace(/'/g, `'\\''`)}'`;
execSync(`sudo rm -rf ${escapedLicenseDir}`, { stdio: "inherit" });
}

main();
24 changes: 4 additions & 20 deletions .github/workflows/build_and_test_qnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ concurrency:
group: build_and_test_qnx-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

env:
LICENSE_DIR: "/opt/score_qnx/license"
jobs:
precheck:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -134,21 +132,10 @@ jobs:
with:
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Install QEMU
run: |
sudo apt-get update
sudo apt-get install -y qemu-system
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup QNX License
env:
SCORE_QNX_LICENSE: ${{ secrets.SCORE_QNX_LICENSE }}
run: |
sudo mkdir -p "${{ env.LICENSE_DIR }}"
echo "${SCORE_QNX_LICENSE}" | base64 --decode | sudo tee "${{ env.LICENSE_DIR }}/licenses" >/dev/null
- name: Setup QNX and QEMU environment
uses: ./.github/actions/00_infrastructure/setup_qnx_environment
with:
qnx-license: ${{ secrets.SCORE_QNX_LICENSE }}
- name: Setup Bazel environment
uses: ./.github/actions/00_infrastructure/prepare_bazel_environment
with:
Expand Down Expand Up @@ -179,6 +166,3 @@ jobs:
SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }}
SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }}
run: bazel build --nobuild --config=qnx -- //score/...
- name: Cleanup QNX License
if: always()
run: sudo rm -rf "${{ env.LICENSE_DIR }}"