diff --git a/.github/docker/alpine-3.21.Dockerfile b/.github/docker/alpine-3.21.Dockerfile new file mode 100644 index 000000000..fef981070 --- /dev/null +++ b/.github/docker/alpine-3.21.Dockerfile @@ -0,0 +1,46 @@ +# Copyright (C) 2025 Intel Corporation +# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# Dockerfile - a 'recipe' for Docker to build an image of Alpine +# environment for building the Unified Memory Framework project. +# + +# Pull base Alpine image version 3.21 +FROM registry.hub.docker.com/library/alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c + +# Set environment variables +ENV OS=alpine +ENV OS_VER=3.21 + +# Base development packages +ARG BASE_DEPS="\ + bash \ + cmake \ + git \ + g++ \ + make \ + sudo" + +# UMF's dependencies +ARG UMF_DEPS="\ + hwloc-dev" + +# Dependencies for tests +ARG TEST_DEPS="\ + numactl-dev" + +# Update and install required packages +RUN apk update \ + && apk add --no-cache \ + ${BASE_DEPS} \ + ${TEST_DEPS} \ + ${UMF_DEPS} + +# Add a new (non-root) 'test_user' +ENV USER=test_user +RUN adduser -D -G wheel ${USER} +RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +USER test_user diff --git a/.github/scripts/alpine_build.sh b/.github/scripts/alpine_build.sh new file mode 100755 index 000000000..4bfdb4461 --- /dev/null +++ b/.github/scripts/alpine_build.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright (C) 2025 Intel Corporation +# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# alpine_build.sh - Script for building UMF on Alpine image + +set -e + +UMF_BUILD_TYPE=$1 +WORKDIR=$2 + +sudo chown $USER $WORKDIR +cd unified-memory-framework + +cmake -B build -DCMAKE_BUILD_TYPE=$UMF_BUILD_TYPE -DUMF_BUILD_TESTS=ON -DUMF_BUILD_EXAMPLES=ON +cmake --build build diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 76e6bef16..bd28544f0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -370,3 +370,28 @@ jobs: SYCL: uses: ./.github/workflows/reusable_sycl.yml + + alpine: + name: Alpine + env: + HOST_WORKDIR: ${{github.workspace}} + WORKDIR: /unified-memory-framework + strategy: + matrix: + build_type: [Debug, Release] + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Build Alpine image + run: | + docker build . -f .github/docker/alpine-3.21.Dockerfile -t umf-alpine-3.21 + + - name: Run UMF build on Alpine image + run: | + docker run --rm -i -v $HOST_WORKDIR:$WORKDIR \ + umf-alpine-3.21 $WORKDIR/.github/scripts/alpine_build.sh ${{matrix.build_type}} $WORKDIR diff --git a/.github/workflows/reusable_trivy.yml b/.github/workflows/reusable_trivy.yml index fb425c1e0..1024d62b9 100644 --- a/.github/workflows/reusable_trivy.yml +++ b/.github/workflows/reusable_trivy.yml @@ -19,6 +19,12 @@ jobs: with: fetch-depth: 0 + - name: Manual Trivy Setup + uses: aquasecurity/setup-trivy@9ea583eb67910444b1f64abf338bd2e105a0a93d + with: + cache: true + version: v0.61.0 + - name: Run Trivy uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # v0.30.0 with: @@ -26,6 +32,7 @@ jobs: hide-progress: false format: 'sarif' output: 'trivy-results.sarif' + skip-setup-trivy: true exit-code: 1 # Fail if issue found # file with suppressions: .trivyignore (in root dir) diff --git a/src/utils/utils_log.c b/src/utils/utils_log.c index 2fd28fc2c..5fc5d6639 100644 --- a/src/utils/utils_log.c +++ b/src/utils/utils_log.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -10,7 +10,6 @@ #ifdef _WIN32 #include #else -#define _GNU_SOURCE 1 #include #include #include @@ -153,13 +152,21 @@ static void utils_log_internal(utils_log_level_t level, int perror, } errno = saveno; #else - char err_buff[1024]; // max size according to manpage. int saveno = errno; errno = 0; +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE + char err[1024]; + int err_ret = strerror_r(saveno, err, sizeof(err)); + if (err_ret == ERANGE) { + postfix = "[truncated...]"; + } +#else + char err_buff[1024]; // max size according to manpage. const char *err = strerror_r(saveno, err_buff, sizeof(err_buff)); if (errno == ERANGE) { postfix = "[truncated...]"; } +#endif errno = saveno; #endif strncpy(b_pos, err, b_size);