Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
aws-region: us-west-2
role-duration-seconds: 3600
- name: Vector Tests ${{ matrix.platform.distribution }}${{ matrix.version }}
id: codebuild
uses: aws-actions/aws-codebuild-run-build@v1
timeout-minutes: 60
with:
Expand All @@ -58,6 +59,34 @@ jobs:
env-vars-for-codebuild: JAVA_ENV_VERSION
env:
JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }}
- name: Write the line coverage report
# The CodeBuild build prints its lcov report, gzipped and base64
# encoded, between two marker lines in its log.
if: matrix.version == 17
env:
BUILD_ID: ${{ steps.codebuild.outputs.aws-build-id }}
run: |
read -r group stream < <(aws codebuild batch-get-builds --ids "$BUILD_ID" \
--query 'builds[0].logs.[groupName,streamName]' --output text)
token=""
: > build.log
while :; do
page=$(aws logs get-log-events --log-group-name "$group" --log-stream-name "$stream" \
--start-from-head ${token:+--next-token "$token"} --output json)
jq -r '.events[].message' <<< "$page" >> build.log
next=$(jq -r '.nextForwardToken' <<< "$page")
[ "$next" = "$token" ] && break
token=$next
done
mkdir -p coverage
sed -n '/^LCOV-GZ-BASE64-BEGIN$/,/^LCOV-GZ-BASE64-END$/{//!p}' build.log | base64 -d | gunzip > coverage/esdk.lcov
grep -c '^SF:' coverage/esdk.lcov
- name: Upload the line coverage report
if: matrix.version == 17
uses: actions/upload-artifact@v4
with:
name: local-coverage-esdk
path: coverage/*.lcov
vectorTestsMasterKeyProvider:
name: Vector Tests MasterKeyProvider
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions codebuild/ci/jacoco_lcov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Print a JaCoCo XML report as lcov.

Usage: jacoco_lcov.py <jacoco.xml> <source root relative to the repository>

A line counts as hit when its tests covered at least one of its instructions;
JaCoCo keeps no hit counts.
"""
import sys
import xml.etree.ElementTree as ElementTree

report, source_root = sys.argv[1], sys.argv[2]
for package in ElementTree.parse(report).getroot().iter("package"):
for sourcefile in package.findall("sourcefile"):
print("SF:%s/%s/%s" % (source_root, package.get("name"), sourcefile.get("name")))
for line in sourcefile.findall("line"):
print("DA:%s,%d" % (line.get("nr"), int(line.get("ci")) > 0))
print("end_of_record")
11 changes: 11 additions & 0 deletions codebuild/ci/vectors-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ phases:
commands:
# NOTE: We need to pass the absolute path of the vectors
- mvn install -T 8 -Dgpg.skip=true -ntp "-DtestVectorZip=file://$CODEBUILD_SRC_DIR/src/test/resources/aws-encryption-sdk-test-vectors/vectors/awses-decrypt/python-2.3.0.zip"
post_build:
commands:
# The GitHub workflow reads the line coverage report back out of this
# build's log and uploads it.
- |
cd "$CODEBUILD_SRC_DIR"
if [ -f target/site/jacoco/jacoco.xml ]; then
echo LCOV-GZ-BASE64-BEGIN
python3 codebuild/ci/jacoco_lcov.py target/site/jacoco/jacoco.xml src/main/java | gzip | base64
echo LCOV-GZ-BASE64-END
fi
Loading