From 6996e1ac77e67aa0cd9894c5d8cdbbfe06b1cb39 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Thu, 6 Mar 2025 13:54:58 -0500 Subject: [PATCH] Test several versions of CMake --- .../cmake_build_versions/Dockerfile | 45 +++++++++++++++++++ .../cmake_build_versions/aws_lc_rs_build.sh | 26 +++++++++++ .../cmake_build_versions/cmake_build.sh | 16 +++++++ .../cmake_build_versions/entry.sh | 10 +++++ .github/workflows/cmake.yml | 40 +++++++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 .github/docker_images/cmake_build_versions/Dockerfile create mode 100755 .github/docker_images/cmake_build_versions/aws_lc_rs_build.sh create mode 100755 .github/docker_images/cmake_build_versions/cmake_build.sh create mode 100755 .github/docker_images/cmake_build_versions/entry.sh create mode 100644 .github/workflows/cmake.yml diff --git a/.github/docker_images/cmake_build_versions/Dockerfile b/.github/docker_images/cmake_build_versions/Dockerfile new file mode 100644 index 00000000000..23a4bc166cd --- /dev/null +++ b/.github/docker_images/cmake_build_versions/Dockerfile @@ -0,0 +1,45 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +FROM amazonlinux:2023 + +ARG CMAKE_VERSION +ARG CMAKE_DOWNLOAD_URL +ARG CMAKE_SHA256 + +VOLUME ["/awslc"] + +RUN dnf install -y tar ninja-build golang gcc gcc-c++ libcurl-devel libarchive-devel zlib-devel xz-devel + +RUN mkdir /cmake + +COPY cmake_build.sh / +COPY aws_lc_rs_build.sh / +COPY entry.sh / + +WORKDIR /cmake + +RUN curl -L -o source.tar.gz "${CMAKE_DOWNLOAD_URL}" && \ + echo "${CMAKE_SHA256} source.tar.gz" | sha256sum -c - && \ + mkdir source && \ + tar -x -f source.tar.gz -v --strip-components=1 -C source + +WORKDIR /cmake/source + +RUN /cmake_build.sh + +RUN useradd -m docker +USER docker +RUN cd "${HOME}" && \ + git config --global --add safe.directory '*' && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ./rustup.sh && \ + chmod +x ./rustup.sh && \ + ./rustup.sh -y && \ + . "${HOME}/.cargo/env" && \ + cargo install --locked bindgen-cli && \ + rustup component add rustfmt clippy && \ + rm ./rustup.sh + +ENV AWS_LC_SYS_CMAKE_BUILDER=1 + +ENTRYPOINT ["/entry.sh"] diff --git a/.github/docker_images/cmake_build_versions/aws_lc_rs_build.sh b/.github/docker_images/cmake_build_versions/aws_lc_rs_build.sh new file mode 100755 index 00000000000..7987e7417cf --- /dev/null +++ b/.github/docker_images/cmake_build_versions/aws_lc_rs_build.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +set -ex -o pipefail + +echo "Building with CMake Version: $(cmake --version)" + +. "${HOME}/.cargo/env" +SRC_DIR="${SRC_DIR:-/aws_lc_rs}" + +sudo chown "$USER":"$USER" "${SRC_DIR}" -R + +pushd "${SRC_DIR}" +cargo clean +cargo test -p aws-lc-rs --features=unstable +cargo clean +cargo test -p aws-lc-rs --features=unstable,fips +cargo clean +cargo test -p aws-lc-rs --release --features=unstable +cargo clean +cargo test -p aws-lc-rs --release --features=unstable,fips + + +popd # ${BUILD_DIR} diff --git a/.github/docker_images/cmake_build_versions/cmake_build.sh b/.github/docker_images/cmake_build_versions/cmake_build.sh new file mode 100755 index 00000000000..cc737dcbe37 --- /dev/null +++ b/.github/docker_images/cmake_build_versions/cmake_build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +set -ex -o pipefail + +echo "Building CMake Version: ${CMAKE_VERSION:-unknown}" + +NUM_CPU_THREADS=$(grep -c ^processor /proc/cpuinfo) + +# At the moment this works fine for all versions, in the future build logic can be modified to +# look at it ${CMAKE_VERSION}. +./configure --prefix=/opt/cmake --system-curl --system-libarchive +make -j"${NUM_CPU_THREADS}" +make install diff --git a/.github/docker_images/cmake_build_versions/entry.sh b/.github/docker_images/cmake_build_versions/entry.sh new file mode 100755 index 00000000000..03e92ebf427 --- /dev/null +++ b/.github/docker_images/cmake_build_versions/entry.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +set -ex -o pipefail + +export PATH="/opt/cmake/bin:${PATH}" + +/aws_lc_rs_build.sh "${argv[@]}" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000000..ba6191d3f31 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,40 @@ +name: CMake Compatability +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true +env: + DOCKER_BUILDKIT: 1 + GOPROXY: https://proxy.golang.org,direct +jobs: + cmake: + if: github.repository_owner == 'aws' + name: CMake ${{ matrix.cmake.version}} build with ${{ matrix.generator}} + strategy: + fail-fast: false + matrix: + cmake: + - { version: "3.5", url: "https://cmake.org/files/v3.5/cmake-3.5.0.tar.gz", hash: "92c83ad8a4fd6224cf6319a60b399854f55b38ebe9d297c942408b792b1a9efa" } + - { version: "3.28", url: "https://cmake.org/files/v3.28/cmake-3.28.1.tar.gz", hash: "15e94f83e647f7d620a140a7a5da76349fc47a1bfed66d0f5cdee8e7344079ad" } + - { version: "4.0", url: "https://cmake.org/files/v4.0/cmake-4.0.0-rc3.tar.gz", hash: "d1ae66637fb083efde5c12b45a76ab9bcd419970979c93b14a0d0d21eb8c6c08" } + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: 1 + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - name: Build Docker Image + working-directory: .github/docker_images/cmake_build_versions + run: | + docker build -t "cmake-${{ matrix.cmake.version }}" --build-arg CMAKE_VERSION=${{ matrix.cmake.version }} --build-arg CMAKE_DOWNLOAD_URL=${{ matrix.cmake.url }} --build-arg CMAKE_SHA256=${{ matrix.cmake.hash }} . + - name: Test - Debug + run: | + docker run -v "${{ github.workspace }}:/aws_lc_rs" "cmake-${{ matrix.cmake.version }}" + - name: Test - Release + run: | + docker run -v "${{ github.workspace }}:/aws_lc_rs" "cmake-${{ matrix.cmake.version }}"