-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup X509 CodeBuild Project for Limbo Report Generation (#2171)
### Description of changes: Adds a new AWS CodeBuild Project which will build and run the x509-limbo project and produce a set of reports and alerts for pull requests and branch pushes. ### Testing: * Validated in my personal AWS account by deploying the CDK stack changes and testing using my fork. Reach out if you want to walk-through of what the reports look like. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
- Loading branch information
Showing
11 changed files
with
221 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from aws_cdk import Duration, Stack, aws_codebuild as codebuild, aws_s3 as s3 | ||
from constructs import Construct | ||
from util.build_spec_loader import BuildSpecLoader | ||
from util.metadata import ( | ||
GITHUB_PUSH_CI_BRANCH_TARGETS, | ||
GITHUB_REPO_NAME, | ||
GITHUB_REPO_OWNER, | ||
) | ||
|
||
|
||
class AwsLcGitHubX509CIStack(Stack): | ||
def __init__( | ||
self, | ||
scope: Construct, | ||
id: str, | ||
**kwargs, | ||
) -> None: | ||
super().__init__(scope, id, **kwargs) | ||
|
||
git_hub_source = codebuild.Source.git_hub( | ||
owner=GITHUB_REPO_OWNER, | ||
repo=GITHUB_REPO_NAME, | ||
webhook=True, | ||
webhook_filters=[ | ||
codebuild.FilterGroup.in_event_of( | ||
codebuild.EventAction.PULL_REQUEST_CREATED, | ||
codebuild.EventAction.PULL_REQUEST_UPDATED, | ||
codebuild.EventAction.PULL_REQUEST_REOPENED, | ||
), | ||
codebuild.FilterGroup.in_event_of( | ||
codebuild.EventAction.PUSH | ||
).and_branch_is(GITHUB_PUSH_CI_BRANCH_TARGETS), | ||
], | ||
webhook_triggers_batch_build=True, | ||
) | ||
|
||
self.reports_bucket = s3.Bucket( | ||
self, | ||
"aws-lc-x509-reports", | ||
block_public_access=s3.BlockPublicAccess.BLOCK_ALL, | ||
versioned=True, | ||
) | ||
|
||
self.reports_bucket.add_lifecycle_rule( | ||
enabled=True, | ||
prefix="x509-limbo/", | ||
transitions=[ | ||
s3.Transition( | ||
storage_class=s3.StorageClass.INTELLIGENT_TIERING, | ||
transition_after=Duration.days(30), | ||
), | ||
], | ||
noncurrent_version_transitions=[ | ||
s3.NoncurrentVersionTransition( | ||
storage_class=s3.StorageClass.INTELLIGENT_TIERING, | ||
transition_after=Duration.days(30), | ||
), | ||
], | ||
) | ||
self.reports_bucket.add_lifecycle_rule( | ||
enabled=True, | ||
prefix="x509-limbo/pr/", | ||
expiration=Duration.days(30), | ||
noncurrent_version_expiration=Duration.days(1), | ||
) | ||
|
||
# This is for the case of a manual build is triggered via CodeBuild console/API. | ||
self.reports_bucket.add_lifecycle_rule( | ||
enabled=True, | ||
prefix=f"x509-limbo/{id}:", | ||
expiration=Duration.days(30), | ||
noncurrent_version_expiration=Duration.days(1), | ||
) | ||
|
||
self.codebuild_project = codebuild.Project( | ||
self, | ||
id, | ||
project_name=id, | ||
source=git_hub_source, | ||
build_spec=BuildSpecLoader.load( | ||
"cdk/codebuild/github_ci_x509_omnibus.yaml" | ||
), | ||
environment=codebuild.BuildEnvironment( | ||
build_image=codebuild.LinuxBuildImage.STANDARD_6_0, | ||
compute_type=codebuild.ComputeType.LARGE, | ||
privileged=True, | ||
), | ||
artifacts=codebuild.Artifacts.s3( | ||
bucket=self.reports_bucket, | ||
package_zip=False, | ||
include_build_id=False, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
version: 0.2 | ||
|
||
# Doc for batch https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build-buildspec.html#build-spec.batch.build-list | ||
batch: | ||
build-list: | ||
|
||
- identifier: x509_limbo_report | ||
buildspec: ./tests/ci/codebuild/common/run_x509_limbo_reports_target.yml | ||
env: | ||
type: LINUX_CONTAINER | ||
privileged-mode: true | ||
compute-type: BUILD_GENERAL1_LARGE | ||
image: 620771051181.dkr.ecr.us-west-2.amazonaws.com/aws-lc-docker-images-linux-x86:amazonlinux-2023_x509_latest | ||
variables: | ||
AWS_LC_CI_TARGET: "tests/ci/run_x509_limbo.sh" |
23 changes: 23 additions & 0 deletions
23
tests/ci/codebuild/common/run_x509_limbo_reports_target.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
version: 0.2 | ||
|
||
env: | ||
variables: | ||
GOPROXY: https://proxy.golang.org,direct | ||
|
||
phases: | ||
install: | ||
commands: | ||
- nohup /usr/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 & | ||
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done" | ||
build: | ||
commands: | ||
- "./${AWS_LC_CI_TARGET}" | ||
|
||
artifacts: | ||
files: | ||
- '**/*' | ||
base-directory: x509-limbo-reports | ||
name: x509-limbo/${CODEBUILD_WEBHOOK_TRIGGER:-$CODEBUILD_BUILD_ID} |
28 changes: 28 additions & 0 deletions
28
tests/ci/docker_images/linux-x86/amazonlinux-2023_x509/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
FROM amazonlinux-2023:clang-15x | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN set -ex && \ | ||
dnf -y upgrade --releasever=latest && dnf install -y \ | ||
docker \ | ||
openssl-devel \ | ||
patch \ | ||
jq && \ | ||
dnf clean packages && \ | ||
dnf clean metadata && \ | ||
dnf clean all && \ | ||
rm -rf /tmp/* && \ | ||
rm -rf /var/cache/dnf | ||
|
||
RUN curl -fsSL https://pyenv.run | bash | ||
|
||
ENV PATH="/root/.pyenv/bin:${PATH}" | ||
RUN eval "$(pyenv init -)" && \ | ||
pyenv install 3.13.1 | ||
|
||
ENV PATH="/root/.pyenv/versions/3.13.1/bin:${PATH}" | ||
ENV CC=clang | ||
ENV CXX=clang++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters