From 2de323e95f4ed2f976213c833ebe870dafe1c20d Mon Sep 17 00:00:00 2001 From: James Mayclin Date: Thu, 16 Nov 2023 13:59:53 -0800 Subject: [PATCH] ci: add mainline coverage job (#4288) --- README.md | 2 ++ codebuild/bin/coverage_build.sh | 29 ---------------------- codebuild/bin/coverage_upload.sh | 25 ------------------- codebuild/spec/buildspec_generalbatch.yml | 8 ------ codebuild/spec/buildspec_unit_coverage.yml | 28 +++++++++++---------- 5 files changed, 17 insertions(+), 75 deletions(-) delete mode 100755 codebuild/bin/coverage_build.sh delete mode 100755 codebuild/bin/coverage_upload.sh diff --git a/README.md b/README.md index 414553ac97a..1c7a89c2dbb 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,8 @@ In addition to code reviews, s2n-tls is subject to regular static analysis, fuzz s2n-tls includes positive and negative unit tests and end-to-end test cases. +Unit test coverage can be viewed [here](https://dx1inn44oyl7n.cloudfront.net/main/index.html). Note that this represents unit coverage for a particular build. Since that build won't necessarily support all s2n-tls features, test coverage may be artificially lowered. + ##### Erase on read s2n-tls encrypts or erases plaintext data as quickly as possible. For example, decrypted data buffers are erased as they are read by the application. diff --git a/codebuild/bin/coverage_build.sh b/codebuild/bin/coverage_build.sh deleted file mode 100755 index f10d3a877d6..00000000000 --- a/codebuild/bin/coverage_build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"). -# You may not use this file except in compliance with the License. -# A copy of the License is located at -# -# http://aws.amazon.com/apache2.0 -# -# or in the "license" file accompanying this file. This file is distributed -# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -# express or implied. See the License for the specific language governing -# permissions and limitations under the License. - -set -e - -source codebuild/bin/s2n_setup_env.sh - -# LLVM complains about corrupt coverage information -# for static targets, so compile to a shared lib -# instead. -cmake . -Bbuild \ - -DCOVERAGE=ON \ - -DCMAKE_PREFIX_PATH=$LIBCRYPTO_ROOT \ - -DBUILD_SHARED_LIBS=ON - -cmake --build ./build -- -j $(nproc) - -echo "done with the build" diff --git a/codebuild/bin/coverage_upload.sh b/codebuild/bin/coverage_upload.sh deleted file mode 100755 index c29ea8761a5..00000000000 --- a/codebuild/bin/coverage_upload.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"). -# You may not use this file except in compliance with the License. -# A copy of the License is located at -# -# http://aws.amazon.com/apache2.0 -# -# or in the "license" file accompanying this file. This file is distributed -# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -# express or implied. See the License for the specific language governing -# permissions and limitations under the License. -# - -set -e -echo "The codebuild source version is ${CODEBUILD_SOURCE_VERSION}" - -CLOUDFRONT_DISTRIBUTION="https://dx1inn44oyl7n.cloudfront.net" - -aws s3 sync coverage_report s3://s2n-tls-public-coverage-artifacts/${CODEBUILD_SOURCE_VERSION}/report -aws s3 cp coverage_summary.txt s3://s2n-tls-public-coverage-artifacts/${CODEBUILD_SOURCE_VERSION}/summary.txt - -echo "report : is at ${CLOUDFRONT_DISTRIBUTION}/${CODEBUILD_SOURCE_VERSION}/report/index.html" -echo "summary: is at ${CLOUDFRONT_DISTRIBUTION}/${CODEBUILD_SOURCE_VERSION}/summary.txt" diff --git a/codebuild/spec/buildspec_generalbatch.yml b/codebuild/spec/buildspec_generalbatch.yml index 09e46019343..d1e6bc6b5fe 100644 --- a/codebuild/spec/buildspec_generalbatch.yml +++ b/codebuild/spec/buildspec_generalbatch.yml @@ -335,14 +335,6 @@ batch: S2N_NO_PQ: 1 TESTS: unit identifier: s2nUnitClang15 - - identifier: s2nUnitCoverage - buildspec: codebuild/spec/buildspec_unit_coverage.yml - env: - privileged-mode: true - compute-type: BUILD_GENERAL1_LARGE - image: 024603541914.dkr.ecr.us-west-2.amazonaws.com/docker:ubuntu22codebuild - variables: - S2N_LIBCRYPTO: openssl-1.1.1 - identifier: 32BitBuildAndUnit buildspec: codebuild/spec/buildspec_32bit_cross_compile.yml env: diff --git a/codebuild/spec/buildspec_unit_coverage.yml b/codebuild/spec/buildspec_unit_coverage.yml index d8fbf3fb6df..633e491abf0 100644 --- a/codebuild/spec/buildspec_unit_coverage.yml +++ b/codebuild/spec/buildspec_unit_coverage.yml @@ -14,8 +14,6 @@ version: 0.2 env: - parameter-store: - CODECOV_TOKEN : codecov-upload-token variables: # CODEBUILD_ is a reserved namespace. CB_BIN_DIR: "./codebuild/bin" @@ -23,21 +21,25 @@ env: CXX: "/usr/bin/clang++" phases: - pre_build: - commands: - - | - if [ -d "third-party-src" ]; then - cd third-party-src; - ln -s /usr/local $CODEBUILD_SRC_DIR/third-party-src/test-deps; - fi - - ln -s /usr/local $CODEBUILD_SRC_DIR/test-deps build: on-failure: ABORT commands: - - $CB_BIN_DIR/coverage_build.sh + # LLVM complains about corrupt coverage information + # for static targets, so compile to a shared lib + # instead. + - | + cmake . -Bbuild \ + -DCOVERAGE=ON \ + -DCMAKE_PREFIX_PATH=$LIBCRYPTO_ROOT \ + -DBUILD_SHARED_LIBS=ON + - cmake --build ./build -- -j $(nproc) post_build: on-failure: ABORT commands: - - LLVM_PROFILE_FILE="ut_%p.profraw" CTEST_PARALLEL_LEVEL=$(nproc) cmake --build ./build --target test ARGS="--output-on-failure -L unit" + - LLVM_PROFILE_FILE="ut_%8m.profraw" CTEST_PARALLEL_LEVEL=$(nproc) cmake --build ./build --target test ARGS="--output-on-failure -L unit" - $CB_BIN_DIR/coverage_report.sh - - $CB_BIN_DIR/coverage_upload.sh +artifacts: + # upload all files in the coverage_report directory + files: + - '**/*' + base-directory: coverage_report