Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
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
22 changes: 11 additions & 11 deletions .devcontainer/cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
ARM_GNU_TOOLCHAIN_SHA256="d061559d814b205ed30c5b7c577c03317ec447ca51cd5a159d26b12a5bbeb20c"
fi

wget --no-hsts -qO "${ARM_GNU_TOOLCHAIN_TAR}" "${ARM_GNU_TOOLCHAIN_URL}"
wget --no-hsts --https-only -qO "${ARM_GNU_TOOLCHAIN_TAR}" "${ARM_GNU_TOOLCHAIN_URL}"
Comment thread
rjaegers marked this conversation as resolved.
Outdated
echo "${ARM_GNU_TOOLCHAIN_SHA256} ${ARM_GNU_TOOLCHAIN_TAR}" | sha256sum -c -

tar xJf "${ARM_GNU_TOOLCHAIN_TAR}" --exclude="*arm-none-eabi-gdb*" --exclude="share"
Expand Down Expand Up @@ -156,12 +156,12 @@
fi

# Install include-what-you-use (iwyu) from source
apt-get update && apt-get install -y --no-install-recommends libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev
wget --no-hsts -qO - https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/${INCLUDE_WHAT_YOU_USE_VERSION}.tar.gz | tar xz -C /tmp
CC=clang CXX=clang++ cmake -S /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION} -B /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build
cmake --build /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build --target install
rm -rf /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}
apt-get purge -y libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev
apt-get update && apt-get install -y --no-install-recommends "libclang-${CLANG_VERSION}-dev" "llvm-${CLANG_VERSION}-dev"

Check warning on line 159 in .devcontainer/cpp/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Line is too long. Split it into multiple lines using backslash continuations.

See more on https://sonarcloud.io/project/issues?id=philips-software_amp-devcontainer&issues=AZ-Ecn0bAPPx-5A18tQ0&open=AZ-Ecn0bAPPx-5A18tQ0&pullRequest=1374
wget --no-hsts --https-only -qO - "https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/${INCLUDE_WHAT_YOU_USE_VERSION}.tar.gz" | tar xz -C /tmp
CC=clang CXX=clang++ cmake -S "/tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}" -B "/tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build"
cmake --build "/tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build" --target install
rm -rf "/tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}"
apt-get purge -y "libclang-${CLANG_VERSION}-dev" "llvm-${CLANG_VERSION}-dev"
apt-get autoremove -y
apt-get clean

Expand All @@ -172,9 +172,9 @@
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-15 10 \
--slave /usr/bin/c++ c++ /usr/bin/g++-15
update-alternatives --install /usr/bin/iwyu iwyu /usr/local/bin/include-what-you-use 10
update-alternatives --install /usr/bin/mull-runner mull-runner /usr/bin/mull-runner-${CLANG_VERSION} 10 \
--slave /usr/bin/mull-reporter mull-reporter /usr/bin/mull-reporter-${CLANG_VERSION} \
--slave /usr/lib/mull-ir-frontend mull-ir-frontend /usr/lib/mull-ir-frontend-${CLANG_VERSION}
update-alternatives --install /usr/bin/mull-runner mull-runner "/usr/bin/mull-runner-${CLANG_VERSION}" 10 \
--slave /usr/bin/mull-reporter mull-reporter "/usr/bin/mull-reporter-${CLANG_VERSION}" \
--slave /usr/lib/mull-ir-frontend mull-ir-frontend "/usr/lib/mull-ir-frontend-${CLANG_VERSION}"
update-alternatives --install /usr/bin/python python /usr/bin/python3 10

# Add a dummy compile_commands.json file to the default location so that tools like SonarLint and Clangd can find it.
Expand All @@ -189,7 +189,7 @@
# CMake module (not an ELF binary), so it cannot carry a `.note.package` ELF
# section and Syft has no cataloger for standalone `.cmake` files. Its version is
# pinned and tracked via the CPM_VERSION build argument above.
wget --no-hsts -qP /usr/local/lib/python*/dist-packages/cmake/data/share/cmake-*/Modules/ https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake
wget --no-hsts --https-only -qP /usr/local/lib/python*/dist-packages/cmake/data/share/cmake-*/Modules/ "https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake"
conan profile detect
echo -e "\n[conf]\ntools.cmake.cmaketoolchain:generator=Ninja" >> "$(conan profile path default)"

Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN --mount=type=bind,source=.devcontainer/rust/apt-requirements.json,target=/tm

# Install rust
rustup set profile minimal
rustup default ${RUST_VERSION}
rustup default "${RUST_VERSION}"
rustup component add clippy llvm-tools rustfmt

if [[ "${BUILD_EMBEDDED_FLAVOR}" == "true" ]]; then
Expand All @@ -46,7 +46,7 @@ RUN --mount=type=bind,source=.devcontainer/rust/apt-requirements.json,target=/tm
rustup target add thumbv7em-none-eabihf
fi

wget -qO - "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-$(uname -m)-unknown-linux-gnu.tgz" | tar xz -C "/usr/bin"
wget --no-hsts --https-only -qO - "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-$(uname -m)-unknown-linux-gnu.tgz" | tar xz -C "/usr/bin"
cargo-binstall -y --locked "cargo-binutils@${CARGO_BINUTILS_VERSION}" \
"cargo-mutants@${CARGO_MUTANTS_VERSION}"

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/container-size-diff/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runs:
cache-dependency-path: package.json
node-version: 22.x

- run: npm install
- run: npm install --ignore-scripts
shell: bash

- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
Expand Down
84 changes: 84 additions & 0 deletions .github/actions/generate-tool-inventory/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: Generate tool inventory
description: >-
Derive a curated, per-flavor tool inventory from a Syft SPDX SBOM and write it
to a JSON file.

inputs:
sbom:
description: Path to the Syft SPDX SBOM
required: true
allowlist:
description: >-
Path to the flavor's tool allowlist JSON, relative to the caller
repository root. The file is sparse-checked-out by this action.
required: true
flavor:
description: Name of the flavor the inventory is generated for
required: true
output-file:
description: Path the generated tool inventory is written to
required: false
default: tool-inventory.json

outputs:
inventory-file:
description: Path to the generated tool inventory JSON file
value: ${{ inputs.output-file }}

runs:
using: composite
steps:
# The allowlist lives in the caller repository; check out just that file so
# the action is self-contained and callers need no separate checkout step.
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
sparse-checkout: ${{ inputs.allowlist }}
sparse-checkout-cone-mode: false
- shell: bash
Comment thread
rjaegers marked this conversation as resolved.
run: |
set -Eeuo pipefail

# Keep only packages whose name is on the flavor allowlist and project them
# to {name, version, purl}. Versions come straight from the SBOM, so the
# inventory can never disagree with it.
inventory="$(jq -n \
--slurpfile sbom "${SBOM}" \
--slurpfile allow "${ALLOWLIST}" \
--arg flavor "${FLAVOR}" '
($allow[0] | map(ascii_downcase)) as $names
| [ $sbom[0].packages[]
| select(.name != null)
| . as $pkg
| select($names | index($pkg.name | ascii_downcase))
| { name: $pkg.name,
version: $pkg.versionInfo,
purl: ([ $pkg.externalRefs[]? | select(.referenceType == "purl") | .referenceLocator ] | first) } ]
| unique_by(.name | ascii_downcase)
| sort_by(.name | ascii_downcase)
| { flavor: $flavor, tools: . }')"

# Fail if an allowlisted tool is absent from the SBOM. This turns a version
# bump that renames a package (e.g. clang-22 -> clang-23) or a tool that
# silently dropped out of the image into a hard, actionable CI error.
missing="$(jq -rn \
--argjson inventory "${inventory}" \
--slurpfile allow "${ALLOWLIST}" '
($inventory.tools | map(.name | ascii_downcase)) as $found
| $allow[0]
| map(select((ascii_downcase) as $name | ($found | index($name)) | not))
| .[]')"

if [ -n "${missing}" ]; then
echo "error: the following allowlisted tools were not found in the SBOM:" >&2
echo "${missing}" | sed 's/^/ - /' >&2
exit 1
fi

echo "${inventory}" | tee "${OUTPUT_FILE}"
env:
SBOM: ${{ inputs.sbom }}
ALLOWLIST: ${{ inputs.allowlist }}
FLAVOR: ${{ inputs.flavor }}
OUTPUT_FILE: ${{ inputs.output-file }}
63 changes: 63 additions & 0 deletions .github/actions/merge-devcontainer-metadata/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
name: Merge devcontainer.metadata
description: >-
Assemble the devcontainer.metadata image label for a flavor by concatenating
the base image's existing metadata array with the flavor's own metadata entry.

inputs:
base-image:
description: Reference of the image this flavor is built FROM (may be empty)
required: false
default: ""
devcontainer-metadata-file:
description: Path to the flavor's devcontainer-metadata.json (may be absent)
required: false
default: ""

outputs:
label:
description: >-
The `devcontainer.metadata=<json-array>` label value, or empty when no
metadata file is provided.
value: ${{ steps.merge.outputs.label }}

runs:
using: composite
steps:
- id: merge
shell: bash
run: |
set -Eeuo pipefail

if [ -z "${DEVCONTAINER_METADATA_FILE:-}" ] || [ ! -f "${DEVCONTAINER_METADATA_FILE}" ]; then
echo "devcontainer-metadata-file input not set or file does not exist, skipping devcontainer.metadata label"
echo "label=" >> "$GITHUB_OUTPUT"
exit 0
fi

# Extract the base image's existing devcontainer.metadata array. Falls back
# to an empty array when no base image is given or it carries no such label.
base_metadata="[]"
if [ -n "${BASE_IMAGE:-}" ]; then
# `.Image` is the image config for single-platform references and a map of
# `platform -> config` for multi-platform references; the label is identical
# across platforms, so any entry works.
config="$(docker buildx imagetools inspect "${BASE_IMAGE}" --format '{{json .Image}}')"
base_metadata="$(jq -c '
(if has("config") then . else (to_entries[0].value) end)
| (.config.Labels["devcontainer.metadata"] // "") as $raw
| if $raw == "" then [] else (try ($raw | fromjson) catch []) end
| if type == "array" then . else [] end
' <<< "${config}")"
fi

# Concatenate base entries with the flavor entry and emit the label value.
# The gsub adds a space after each comma so `docker buildx build --label`
# does not misinterpret the array and produce invalid JSON (e.g.
# ["x","y"] -> ["x",y]).
merged="$(jq -cr --slurpfile flavor "${DEVCONTAINER_METADATA_FILE}" '. + $flavor | @json | gsub("\",\""; "\", \"")' <<< "${base_metadata}")"

echo "label=devcontainer.metadata=${merged}" >> "$GITHUB_OUTPUT"
env:
BASE_IMAGE: ${{ inputs.base-image }}
DEVCONTAINER_METADATA_FILE: ${{ inputs.devcontainer-metadata-file }}
50 changes: 0 additions & 50 deletions .github/scripts/generate-tool-inventory.sh

This file was deleted.

58 changes: 0 additions & 58 deletions .github/scripts/merge-devcontainer-metadata.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/wc-acceptance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24.8.0
- run: npm ci
- run: npm ci --ignore-scripts
- run: npx playwright install --with-deps
- name: Wait for Codespace to be active
run: |
Expand Down
Loading
Loading