All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.janusgraph.codepipelines.AwsCodePipelinesCi Maven / Gradle / Ivy

// Copyright 2017 JanusGraph Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.
package org.janusgraph.codepipelines;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableList;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.janusgraph.codepipelines.model.PipelineDefinitions;

import software.amazon.awssdk.auth.AwsCredentialsProvider;
import software.amazon.awssdk.auth.ProfileCredentialsProvider;
import software.amazon.awssdk.client.builder.ClientHttpConfiguration;
import software.amazon.awssdk.http.apache.ApacheSdkHttpClientFactory;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.codebuild.CodeBuildClient;
import software.amazon.awssdk.services.codepipeline.CodePipelineClient;
import software.amazon.awssdk.services.iam.model.IAMException;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.BucketLocationConstraint;
import software.amazon.awssdk.services.s3.model.Tag;

import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.List;

/**
 * This class orchestrates some CodePipelines stacks to run JanusGraph release tests in parallel.
 * @author Alexander Patrikalakis
 */
@Slf4j
@RequiredArgsConstructor
public class AwsCodePipelinesCi {

    private static final Option REGION_OPTION = createRequiredOneArgOption("region", "AWS region to create build stack");
    private static final Option BUCKET_OPTION = createRequiredOneArgOption("bucket", "AWS S3 bucket to store artifacts");
    private static final Option CODEPIPELINE_ROLE_ARN_OPTION =
        createRequiredOneArgOption("codepipeline-role-arn", "ARN of IAM role for CodePipeline to use");
    private static final Option GITHUB_OWNER_OPTION =
        createRequiredOneArgOption("github-owner", "GitHub owner (organization) of the repository to build");
    private static final Option GITHUB_REPO_OPTION = createRequiredOneArgOption("github-repo", "GitHub repository to build");
    private static final Option GITHUB_BRANCH_OPTION = createRequiredOneArgOption("github-branch", "GitHub repository branch to build");
    private static final Option GITHUB_TOKEN_OPTION =
        createRequiredOneArgOption("github-token", "GitHub personal access token for AWS CodeBuild to use to build");
    private static final Option PROFILE_OPTION =
        createRequiredOneArgOption("profile", "AWS credential profile to use to create the stack");
    private static final Option PIPELINES_JSON_OPTION =
        createRequiredOneArgOption("pipelines","Path to JSON file containing abbreviated pipeline definitions");
    private static final Option CODE_BUILD_SERVICE_ROLE_ARN_OPTION =
        createRequiredOneArgOption("codebuild-role-arn",
            "ARN of the service role for CodeBuild (https://docs.aws.amazon.com/codebuild/latest/userguide/setting-up.html#setting-up-service-role)");
    private static final Option CODE_BUILD_COMPUTE_IMAGE = createOptionalOneArgOption("codebuild-compute-image",
        "Compute image to use for CodeBuild");

    private static final List




© 2015 - 2025 Weber Informatics LLC | Privacy Policy