feat(codepipeline): add AWS CodePipeline emulation (#1469)

* feat(codepipeline): add AWS CodePipeline emulation

* fix(codepipeline): align webhook and rollback response shapes
This commit is contained in:
kotov228 authored and GitHub committed 2026-06-21 09:01:44 -05:00
1 parent c2cd31216b
commit 3f314dcb4e
19 files changed
+2624 -8

No files matched your search

+4 -3
View File
@@ -178,7 +178,7 @@ LocalStack's community edition [sunset in March 2026](https://blog.localstack.cl
| CodeBuild | Real Docker execution | No |
| Native binary | ~40 MB | No |
**58 AWS services. Broad coverage. Free forever.**
**59 AWS services. Broad coverage. Free forever.**
## Architecture Overview
@@ -190,7 +190,7 @@ flowchart LR
Router["HTTP Router\nJAX-RS / Vert.x"]
subgraph Stateless ["Stateless Services"]
A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM · Config\nAPI Gateway · AppSync · ELB v2 · Auto Scaling\nCodeDeploy · Backup · Bedrock Runtime · Route53 · Transfer"]
A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM · Config\nAPI Gateway · AppSync · ELB v2 · Auto Scaling\nCodeDeploy · CodePipeline · Backup · Bedrock Runtime · Route53 · Transfer"]
end
subgraph Stateful ["Stateful Services"]
@@ -222,7 +222,7 @@ Floci supports local emulation for application services, data services, eventing
| Core app services | S3, SQS, SNS, DynamoDB, Lambda, IAM, STS, KMS, Secrets Manager |
| Events and workflows | EventBridge, EventBridge Pipes, EventBridge Scheduler, Step Functions, CloudWatch Logs, CloudWatch Metrics |
| API and identity | API Gateway REST, API Gateway v2, AppSync, Cognito, ACM, Route53, Cloud Map |
| Containers and compute | ECS, EC2, EKS, CodeBuild, CodeDeploy, Auto Scaling, ELB v2 |
| Containers and compute | ECS, EC2, EKS, CodeBuild, CodeDeploy, CodePipeline, Auto Scaling, ELB v2 |
| Data and analytics | Athena, Glue, EMR, Firehose, OpenSearch, Textract, Transcribe |
| Security and governance | WAF v2, CloudTrail |
| Databases | RDS, RDS Data API, Neptune, DocumentDB, MemoryDB |
@@ -287,6 +287,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
| ELB v2 | In-process | ALB, NLB, target groups, listeners, routing rules, Lambda targets, tags |
| CodeBuild | In-process with real Docker | Real buildspec execution, CloudWatch logs, S3 artifacts |
| CodeDeploy | In-process with Lambda traffic shifting | Deployment groups, configs, lifecycle hooks, auto-rollback |
| CodePipeline | In-process orchestration | Pipelines, executions, S3 artifacts, approvals, local providers, custom workers |
| Auto Scaling | In-process with reconciler | Launch configs, ASGs, desired capacity reconciliation, lifecycle hooks |
| AWS Backup | In-process | Vaults, backup plans, selections, simulated job lifecycle, recovery points |
| AWS Config | In-process | Config rules, configuration recorders, delivery channels, conformance packs, tagging |
@@ -271,6 +271,11 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>codedeploy</artifactId>
</dependency>
<!-- CodePipeline client -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>codepipeline</artifactId>
</dependency>
<!-- AWS Backup client -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
@@ -50,6 +50,7 @@ import software.amazon.awssdk.services.ecr.EcrClient;
import software.amazon.awssdk.services.pipes.PipesClient;
import software.amazon.awssdk.services.codebuild.CodeBuildClient;
import software.amazon.awssdk.services.codedeploy.CodeDeployClient;
import software.amazon.awssdk.services.codepipeline.CodePipelineClient;
import software.amazon.awssdk.services.ecs.EcsClient;
import software.amazon.awssdk.services.eks.EksClient;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
@@ -673,6 +674,14 @@ public final class TestFixtures {
.build();
}
public static CodePipelineClient codePipelineClient() {
return CodePipelineClient.builder()
.endpointOverride(ENDPOINT)
.region(REGION)
.credentialsProvider(CREDENTIALS)
.build();
}
public static BackupClient backupClient() {
return BackupClient.builder()
.endpointOverride(ENDPOINT)
@@ -0,0 +1,147 @@
package com.floci.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import software.amazon.awssdk.services.codepipeline.CodePipelineClient;
import software.amazon.awssdk.services.codepipeline.model.ActionCategory;
import software.amazon.awssdk.services.codepipeline.model.ActionDeclaration;
import software.amazon.awssdk.services.codepipeline.model.ActionOwner;
import software.amazon.awssdk.services.codepipeline.model.ActionTypeId;
import software.amazon.awssdk.services.codepipeline.model.ArtifactStore;
import software.amazon.awssdk.services.codepipeline.model.ArtifactStoreType;
import software.amazon.awssdk.services.codepipeline.model.CreatePipelineResponse;
import software.amazon.awssdk.services.codepipeline.model.DeleteWebhookResponse;
import software.amazon.awssdk.services.codepipeline.model.GetPipelineResponse;
import software.amazon.awssdk.services.codepipeline.model.ListPipelinesResponse;
import software.amazon.awssdk.services.codepipeline.model.ListWebhooksResponse;
import software.amazon.awssdk.services.codepipeline.model.OutputArtifact;
import software.amazon.awssdk.services.codepipeline.model.PipelineDeclaration;
import software.amazon.awssdk.services.codepipeline.model.PutWebhookResponse;
import software.amazon.awssdk.services.codepipeline.model.StageDeclaration;
import software.amazon.awssdk.services.codepipeline.model.UpdatePipelineResponse;
import software.amazon.awssdk.services.codepipeline.model.WebhookAuthenticationType;
import software.amazon.awssdk.services.codepipeline.model.WebhookDefinition;
import software.amazon.awssdk.services.codepipeline.model.WebhookFilterRule;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CodePipelineTest {
private static final String PIPELINE = "sdk-codepipeline";
private static CodePipelineClient codepipeline;
@BeforeAll
static void setup() {
codepipeline = TestFixtures.codePipelineClient();
}
@AfterAll
static void teardown() {
codepipeline.close();
}
@Test
@Order(1)
void createAndGetPipeline() {
CreatePipelineResponse created = codepipeline.createPipeline(r -> r.pipeline(declaration("Deploy")));
assertThat(created.pipeline().name()).isEqualTo(PIPELINE);
assertThat(created.pipeline().version()).isEqualTo(1);
GetPipelineResponse fetched = codepipeline.getPipeline(r -> r.name(PIPELINE));
assertThat(fetched.pipeline().stages()).hasSize(2);
assertThat(fetched.metadata().pipelineArn()).endsWith(":" + PIPELINE);
}
@Test
@Order(2)
void updateAndListPipeline() {
UpdatePipelineResponse updated = codepipeline.updatePipeline(r -> r.pipeline(declaration("Release")));
assertThat(updated.pipeline().version()).isEqualTo(2);
assertThat(updated.pipeline().stages().get(1).name()).isEqualTo("Release");
ListPipelinesResponse listed = codepipeline.listPipelines();
assertThat(listed.pipelines()).extracting(p -> p.name()).contains(PIPELINE);
}
@Test
@Order(3)
void webhookResponsesUseSdkModelShape() {
WebhookDefinition definition = WebhookDefinition.builder()
.name("sdk-webhook")
.targetPipeline(PIPELINE)
.targetAction("Source")
.authentication(WebhookAuthenticationType.UNAUTHENTICATED)
.filters(WebhookFilterRule.builder()
.jsonPath("$.ref")
.matchEquals("refs/heads/main")
.build())
.build();
PutWebhookResponse created = codepipeline.putWebhook(r -> r.webhook(definition));
assertThat(created.webhook().definition()).isEqualTo(definition);
assertThat(created.webhook().arn()).endsWith(":webhook/sdk-webhook");
ListWebhooksResponse listed = codepipeline.listWebhooks();
assertThat(listed.webhooks()).singleElement()
.extracting(webhook -> webhook.definition().name())
.isEqualTo("sdk-webhook");
DeleteWebhookResponse deleted = codepipeline.deleteWebhook(r -> r.name("sdk-webhook"));
assertThat(deleted.sdkFields()).isEmpty();
}
@Test
@Order(4)
void deletePipeline() {
codepipeline.deletePipeline(r -> r.name(PIPELINE));
assertThat(codepipeline.listPipelines().pipelines())
.extracting(p -> p.name())
.doesNotContain(PIPELINE);
}
private static PipelineDeclaration declaration(String secondStage) {
return PipelineDeclaration.builder()
.name(PIPELINE)
.roleArn("arn:aws:iam::000000000000:role/codepipeline-role")
.artifactStore(ArtifactStore.builder()
.type(ArtifactStoreType.S3)
.location("codepipeline-artifacts")
.build())
.stages(
StageDeclaration.builder()
.name("Source")
.actions(ActionDeclaration.builder()
.name("Source")
.actionTypeId(ActionTypeId.builder()
.category(ActionCategory.SOURCE)
.owner(ActionOwner.AWS)
.provider("S3")
.version("1")
.build())
.configuration(Map.of(
"S3Bucket", "codepipeline-source",
"S3ObjectKey", "source.zip"))
.outputArtifacts(OutputArtifact.builder().name("SourceOutput").build())
.build())
.build(),
StageDeclaration.builder()
.name(secondStage)
.actions(ActionDeclaration.builder()
.name("Approval")
.actionTypeId(ActionTypeId.builder()
.category(ActionCategory.APPROVAL)
.owner(ActionOwner.AWS)
.provider("Manual")
.version("1")
.build())
.build())
.build())
.build();
}
}
+3 -2
View File
@@ -12,7 +12,7 @@ Floci is a fast, free, and open-source local AWS service emulator built for deve
## Supported Services
Floci emulates 58 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details.
Floci emulates 59 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details.
| Service | Protocol |
|---|---|
@@ -60,6 +60,7 @@ Floci emulates 58 AWS services. See the [Services Overview](services/index.md) f
| Auto Scaling | Query |
| CodeBuild | JSON 1.1 |
| CodeDeploy | JSON 1.1 |
| CodePipeline | JSON 1.1 |
| AWS Backup | REST JSON |
| CloudFront | REST XML |
| Route53 | REST XML |
@@ -107,7 +108,7 @@ docker compose up -d
aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket
```
All 58 AWS services are immediately available at `http://localhost:4566`.
All 59 AWS services are immediately available at `http://localhost:4566`.
[Get started →](getting-started/quick-start.md){ .md-button .md-button--primary }
[View services →](services/index.md){ .md-button }
+61
View File
@@ -0,0 +1,61 @@
# CodePipeline
Floci implements the AWS CodePipeline JSON 1.1 API and a local pipeline execution engine.
**Protocol:** `POST /` with `Content-Type: application/x-amz-json-1.1` and
`X-Amz-Target: CodePipeline_20150709.<Action>`.
## Supported Operations (44 total)
The complete CodePipeline 2015-07-09 API surface is routed:
- Pipeline lifecycle, state, execution history, start, stop, retry, and rollback
- Stage transitions, manual approvals, action and rule execution history
- Custom action types and AWS/third-party worker job polling
- Webhook registration and tag lifecycle
Pipeline definitions, executions, custom action types, jobs, webhooks, tags, and transition
state use Floci's configured storage backend.
## Execution
Stages execute in declaration order. Actions with the same `runOrder` execute in parallel.
`SUPERSEDED`, `QUEUED`, and `PARALLEL` execution modes are recognized, with `QUEUED` and
`PARALLEL` restricted to V2 pipelines.
The following providers execute against local Floci services:
| Category | Provider | Behavior |
|---|---|---|
| Source | S3 | Reads the configured object and publishes the output artifact |
| Build/Test | CodeBuild | Starts and monitors the configured local CodeBuild project |
| Deploy | S3 | Writes the input artifact to the configured bucket and key |
| Deploy | CodeDeploy | Starts and monitors a local CodeDeploy deployment |
| Invoke | Lambda | Invokes the configured local Lambda function |
| Invoke | CodePipeline | Starts a nested local pipeline execution |
| Approval | Manual | Waits for `PutApprovalResult` |
| Custom/third-party | Any registered action | Uses poll, acknowledge, success, and failure job APIs |
AWS-managed providers without a corresponding Floci execution adapter fail the action with an
AWS-shaped action error. Floci does not call real AWS accounts or third-party SaaS providers.
## Configuration
| Variable | Default | Description |
|---|---|---|
| `FLOCI_SERVICES_CODEPIPELINE_ENABLED` | `true` | Enables the CodePipeline API |
| `FLOCI_STORAGE_SERVICES_CODEPIPELINE_MODE` | global mode | Overrides CodePipeline storage mode |
| `FLOCI_STORAGE_SERVICES_CODEPIPELINE_FLUSH_INTERVAL_MS` | `5000` | Hybrid storage flush interval |
## Example
```bash
aws --endpoint-url http://localhost:4566 codepipeline create-pipeline \
--pipeline file://pipeline.json
aws --endpoint-url http://localhost:4566 codepipeline start-pipeline-execution \
--name local-release
aws --endpoint-url http://localhost:4566 codepipeline list-pipeline-executions \
--pipeline-name local-release
```
+2 -1
View File
@@ -1,6 +1,6 @@
# Services Overview
Floci emulates 58 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
Floci emulates 59 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
This page is the canonical reference for supported service and operation counts. Some services expose separate control-plane and data-plane rows below. Other docs (and the README) should link here rather than duplicating the table.
@@ -62,6 +62,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [CodeBuild](codebuild.md) | `POST /` + `X-Amz-Target: CodeBuild_20161006.*` | JSON 1.1 | 20 |
| [AWS Batch](batch.md) | `/v1/...` | REST JSON | 10 |
| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 30 |
| [CodePipeline](codepipeline.md) | `POST /` + `X-Amz-Target: CodePipeline_20150709.*` | JSON 1.1 | 44 |
| [AWS Backup](backup.md) | `/backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 20 |
| [CloudFront](cloudfront.md) | `/2020-05-31/distribution/*`, `/2020-05-31/cache-policy/*`, `/2020-05-31/function/*` | REST XML | 50 |
| [Route53](route53.md) | `/2013-04-01/hostedzone/*`, `/2013-04-01/healthcheck/*`, `/2013-04-01/change/*` | REST XML | 17 |
+1
View File
@@ -118,6 +118,7 @@ nav:
- CodeBuild: services/codebuild.md
- AWS Batch: services/batch.md
- CodeDeploy: services/codedeploy.md
- CodePipeline: services/codepipeline.md
- AWS Backup: services/backup.md
- CloudFront: services/cloudfront.md
- Route53: services/route53.md
@@ -175,6 +175,7 @@ public interface EmulatorConfig {
CloudFrontStorageConfig cloudfront();
AppSyncStorageConfig appsync();
BatchStorageConfig batch();
CodePipelineStorageConfig codepipeline();
S3VectorsStorageConfig s3vectors();
}
@@ -314,6 +315,13 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
interface CodePipelineStorageConfig {
Optional<String> mode();
@WithDefault("5000")
long flushIntervalMs();
}
interface S3VectorsStorageConfig {
Optional<String> mode();
@@ -384,6 +392,7 @@ public interface EmulatorConfig {
ElbV2ServiceConfig elbv2();
CodeBuildServiceConfig codebuild();
CodeDeployServiceConfig codedeploy();
CodePipelineServiceConfig codepipeline();
AutoScalingServiceConfig autoscaling();
BackupServiceConfig backup();
NeptuneServiceConfig neptune();
@@ -478,6 +487,11 @@ public interface EmulatorConfig {
boolean enabled();
}
interface CodePipelineServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface SsmServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.services.acm.AcmJsonHandler;
import io.github.hectorvent.floci.services.athena.AthenaJsonHandler;
import io.github.hectorvent.floci.services.codebuild.CodeBuildJsonHandler;
import io.github.hectorvent.floci.services.codedeploy.CodeDeployJsonHandler;
import io.github.hectorvent.floci.services.codepipeline.CodePipelineJsonHandler;
import io.github.hectorvent.floci.services.ecr.EcrJsonHandler;
import io.github.hectorvent.floci.services.transfer.TransferHandler;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
@@ -78,6 +79,7 @@ public class AwsJson11Controller {
private final ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler;
private final CodeBuildJsonHandler codeBuildJsonHandler;
private final CodeDeployJsonHandler codeDeployJsonHandler;
private final CodePipelineJsonHandler codePipelineJsonHandler;
private final Ec2MessagesJsonHandler ec2MessagesJsonHandler;
private final TransferHandler transferHandler;
private final TextractJsonHandler textractJsonHandler;
@@ -109,6 +111,7 @@ public class AwsJson11Controller {
ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler,
CodeBuildJsonHandler codeBuildJsonHandler,
CodeDeployJsonHandler codeDeployJsonHandler,
CodePipelineJsonHandler codePipelineJsonHandler,
Ec2MessagesJsonHandler ec2MessagesJsonHandler,
TransferHandler transferHandler,
TextractJsonHandler textractJsonHandler,
@@ -143,6 +146,7 @@ public class AwsJson11Controller {
this.resourceGroupsTaggingJsonHandler = resourceGroupsTaggingJsonHandler;
this.codeBuildJsonHandler = codeBuildJsonHandler;
this.codeDeployJsonHandler = codeDeployJsonHandler;
this.codePipelineJsonHandler = codePipelineJsonHandler;
this.ec2MessagesJsonHandler = ec2MessagesJsonHandler;
this.transferHandler = transferHandler;
this.textractJsonHandler = textractJsonHandler;
@@ -202,6 +206,8 @@ public class AwsJson11Controller {
case "tagging" -> resourceGroupsTaggingJsonHandler.handle(action, request, region);
case "codebuild" -> codeBuildJsonHandler.handle(action, request, region, regionResolver.getAccountId());
case "codedeploy" -> codeDeployJsonHandler.handle(action, request, region);
case "codepipeline" -> codePipelineJsonHandler.handle(
action, request, region, regionResolver.getAccountId());
case "ec2messages" -> ec2MessagesJsonHandler.handle(action, request, region);
case "transfer" -> transferHandler.handle(action, request, region);
case "textract" -> textractJsonHandler.handle(action, request, region);
@@ -263,6 +263,12 @@ public class ResolvedServiceCatalog {
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodeDeploy_20141006."), Set.of("codedeploy"), Set.of(), Set.of()),
descriptor("codepipeline", "codepipeline", config.services().codepipeline().enabled(), true,
"codepipeline",
storageMode(config.storage().services().codepipeline().mode(), config.storage().mode()),
config.storage().services().codepipeline().flushIntervalMs(), null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodePipeline_20150709."), Set.of("codepipeline"), Set.of(), Set.of()),
descriptor("config", "configservice", config.services().configservice().enabled(), true,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
@@ -0,0 +1,21 @@
package io.github.hectorvent.floci.services.codepipeline;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
@ApplicationScoped
public class CodePipelineJsonHandler {
private final CodePipelineService service;
@Inject
public CodePipelineJsonHandler(CodePipelineService service) {
this.service = service;
}
public Response handle(String action, JsonNode request, String region, String account) {
JsonNode response = service.handle(action, request, region, account);
return Response.ok(response).build();
}
}
@@ -0,0 +1,349 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelineExecution {
public CodePipelineExecution() {
}
private String accountId;
private String region;
private String pipelineExecutionId;
private String pipelineName;
private Integer pipelineVersion;
private String status;
private String statusSummary;
private String executionMode;
private String executionType;
private Double startTime;
private Double lastUpdateTime;
private List<Map<String, Object>> artifactRevisions = new ArrayList<>();
private List<Map<String, Object>> sourceRevisions = new ArrayList<>();
private List<Map<String, String>> variables = new ArrayList<>();
private Map<String, String> trigger = new LinkedHashMap<>();
private List<ActionExecution> actionExecutions = new ArrayList<>();
private String currentStage;
private boolean stopRequested;
private boolean abandon;
private String rollbackTargetPipelineExecutionId;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getPipelineExecutionId() {
return pipelineExecutionId;
}
public void setPipelineExecutionId(String pipelineExecutionId) {
this.pipelineExecutionId = pipelineExecutionId;
}
public String getPipelineName() {
return pipelineName;
}
public void setPipelineName(String pipelineName) {
this.pipelineName = pipelineName;
}
public Integer getPipelineVersion() {
return pipelineVersion;
}
public void setPipelineVersion(Integer pipelineVersion) {
this.pipelineVersion = pipelineVersion;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusSummary() {
return statusSummary;
}
public void setStatusSummary(String statusSummary) {
this.statusSummary = statusSummary;
}
public String getExecutionMode() {
return executionMode;
}
public void setExecutionMode(String executionMode) {
this.executionMode = executionMode;
}
public String getExecutionType() {
return executionType;
}
public void setExecutionType(String executionType) {
this.executionType = executionType;
}
public Double getStartTime() {
return startTime;
}
public void setStartTime(Double startTime) {
this.startTime = startTime;
}
public Double getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Double lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public List<Map<String, Object>> getArtifactRevisions() {
return artifactRevisions;
}
public void setArtifactRevisions(List<Map<String, Object>> artifactRevisions) {
this.artifactRevisions = artifactRevisions;
}
public List<Map<String, Object>> getSourceRevisions() {
return sourceRevisions;
}
public void setSourceRevisions(List<Map<String, Object>> sourceRevisions) {
this.sourceRevisions = sourceRevisions;
}
public List<Map<String, String>> getVariables() {
return variables;
}
public void setVariables(List<Map<String, String>> variables) {
this.variables = variables;
}
public Map<String, String> getTrigger() {
return trigger;
}
public void setTrigger(Map<String, String> trigger) {
this.trigger = trigger;
}
public List<ActionExecution> getActionExecutions() {
return actionExecutions;
}
public void setActionExecutions(List<ActionExecution> actionExecutions) {
this.actionExecutions = actionExecutions;
}
public String getCurrentStage() {
return currentStage;
}
public void setCurrentStage(String currentStage) {
this.currentStage = currentStage;
}
public boolean isStopRequested() {
return stopRequested;
}
public void setStopRequested(boolean stopRequested) {
this.stopRequested = stopRequested;
}
public boolean isAbandon() {
return abandon;
}
public void setAbandon(boolean abandon) {
this.abandon = abandon;
}
public String getRollbackTargetPipelineExecutionId() {
return rollbackTargetPipelineExecutionId;
}
public void setRollbackTargetPipelineExecutionId(String rollbackTargetPipelineExecutionId) {
this.rollbackTargetPipelineExecutionId = rollbackTargetPipelineExecutionId;
}
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class ActionExecution {
public ActionExecution() {
}
private String actionExecutionId;
private String stageName;
private String actionName;
private String category;
private String owner;
private String provider;
private Integer runOrder;
private String status;
private Double startTime;
private Double lastUpdateTime;
private String summary;
private String externalExecutionId;
private String externalExecutionUrl;
private String token;
private Map<String, String> outputVariables = new LinkedHashMap<>();
private Map<String, Object> errorDetails;
public String getActionExecutionId() {
return actionExecutionId;
}
public void setActionExecutionId(String actionExecutionId) {
this.actionExecutionId = actionExecutionId;
}
public String getStageName() {
return stageName;
}
public void setStageName(String stageName) {
this.stageName = stageName;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
public Integer getRunOrder() {
return runOrder;
}
public void setRunOrder(Integer runOrder) {
this.runOrder = runOrder;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getStartTime() {
return startTime;
}
public void setStartTime(Double startTime) {
this.startTime = startTime;
}
public Double getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Double lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getExternalExecutionId() {
return externalExecutionId;
}
public void setExternalExecutionId(String externalExecutionId) {
this.externalExecutionId = externalExecutionId;
}
public String getExternalExecutionUrl() {
return externalExecutionUrl;
}
public void setExternalExecutionUrl(String externalExecutionUrl) {
this.externalExecutionUrl = externalExecutionUrl;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Map<String, String> getOutputVariables() {
return outputVariables;
}
public void setOutputVariables(Map<String, String> outputVariables) {
this.outputVariables = outputVariables;
}
public Map<String, Object> getErrorDetails() {
return errorDetails;
}
public void setErrorDetails(Map<String, Object> errorDetails) {
this.errorDetails = errorDetails;
}
}
}
@@ -0,0 +1,150 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.LinkedHashMap;
import java.util.Map;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelinePipeline {
public CodePipelinePipeline() {
}
private String accountId;
private String region;
private String name;
private String arn;
private Integer version;
private Double created;
private Double updated;
private JsonNode declaration;
private Map<String, String> tags = new LinkedHashMap<>();
private Map<String, TransitionState> transitions = new LinkedHashMap<>();
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getArn() {
return arn;
}
public void setArn(String arn) {
this.arn = arn;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public Double getCreated() {
return created;
}
public void setCreated(Double created) {
this.created = created;
}
public Double getUpdated() {
return updated;
}
public void setUpdated(Double updated) {
this.updated = updated;
}
public JsonNode getDeclaration() {
return declaration;
}
public void setDeclaration(JsonNode declaration) {
this.declaration = declaration;
}
public Map<String, String> getTags() {
return tags;
}
public void setTags(Map<String, String> tags) {
this.tags = tags;
}
public Map<String, TransitionState> getTransitions() {
return transitions;
}
public void setTransitions(Map<String, TransitionState> transitions) {
this.transitions = transitions;
}
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class TransitionState {
public TransitionState() {
}
private boolean enabled = true;
private String reason;
private Double lastChangedAt;
private String lastChangedBy;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public Double getLastChangedAt() {
return lastChangedAt;
}
public void setLastChangedAt(Double lastChangedAt) {
this.lastChangedAt = lastChangedAt;
}
public String getLastChangedBy() {
return lastChangedBy;
}
public void setLastChangedBy(String lastChangedBy) {
this.lastChangedBy = lastChangedBy;
}
}
}
@@ -0,0 +1,85 @@
package io.github.hectorvent.floci.services.codepipeline.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CodePipelineStoredItem {
public CodePipelineStoredItem() {
}
private String accountId;
private String region;
private String id;
private String type;
private String status;
private Double created;
private Double updated;
private JsonNode data;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getCreated() {
return created;
}
public void setCreated(Double created) {
this.created = created;
}
public Double getUpdated() {
return updated;
}
public void setUpdated(Double updated) {
this.updated = updated;
}
public JsonNode getData() {
return data;
}
public void setData(JsonNode data) {
this.data = data;
}
}
+4 -1
View File
@@ -94,6 +94,8 @@ floci:
flush-interval-ms: 5000
batch:
flush-interval-ms: 5000
codepipeline:
flush-interval-ms: 5000
s3vectors:
flush-interval-ms: 5000
rds:
@@ -330,6 +332,8 @@ floci:
# docker-network: floci-network
codedeploy:
enabled: true
codepipeline:
enabled: true
autoscaling:
enabled: true
backup:
@@ -363,4 +367,3 @@ floci:
enabled: true
s3vectors:
enabled: true
@@ -0,0 +1,383 @@
package io.github.hectorvent.floci.services.codepipeline;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.Instant;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@QuarkusTest
class CodePipelineIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String TARGET = "CodePipeline_20150709.";
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void pipelineLifecycleExecutesS3SourceAndDeployActions() throws Exception {
createBucket("codepipeline-source");
createBucket("codepipeline-destination");
putObject("codepipeline-source", "source.zip", "pipeline artifact");
String pipelineName = "s3-copy-pipeline";
post("CreatePipeline", pipeline(pipelineName, """
{
"name": "Source",
"actions": [{
"name": "SourceObject",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"S3Bucket": "codepipeline-source",
"S3ObjectKey": "source.zip"
},
"outputArtifacts": [{"name": "SourceOutput"}],
"runOrder": 1
}]
},
{
"name": "Deploy",
"actions": [{
"name": "DeployObject",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"BucketName": "codepipeline-destination",
"ObjectKey": "deployed.zip"
},
"inputArtifacts": [{"name": "SourceOutput"}],
"runOrder": 1
}]
}
"""))
.then()
.statusCode(200)
.body("pipeline.name", equalTo(pipelineName))
.body("pipeline.version", equalTo(1))
.body("pipeline.executionMode", equalTo("SUPERSEDED"));
String executionId = post("StartPipelineExecution", """
{"name": "%s", "clientRequestToken": "s3-copy-token"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("pipelineExecutionId", notNullValue())
.extract().path("pipelineExecutionId");
waitForExecution(pipelineName, executionId, "Succeeded");
given()
.get("/codepipeline-destination/deployed.zip")
.then()
.statusCode(200)
.body(equalTo("pipeline artifact"));
post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("pipelineExecution.pipelineName", equalTo(pipelineName))
.body("pipelineExecution.status", equalTo("Succeeded"))
.body("pipelineExecution.artifactRevisions", hasSize(1))
.body("pipelineExecution.artifactRevisions[0].name", equalTo("SourceObject"));
post("GetPipelineState", """
{"name": "%s"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("stageStates", hasSize(2))
.body("stageStates[0].actionStates[0].latestExecution.status", equalTo("Succeeded"));
post("ListActionExecutions", """
{
"pipelineName": "%s",
"filter": {"pipelineExecutionId": "%s"}
}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("actionExecutionDetails", hasSize(2));
String rollbackExecutionId = post("RollbackStage", """
{
"pipelineName": "%s",
"stageName": "Deploy",
"targetPipelineExecutionId": "%s"
}
""".formatted(pipelineName, executionId))
.then()
.statusCode(200)
.body("pipelineExecutionId", notNullValue())
.extract().path("pipelineExecutionId");
waitForExecution(pipelineName, rollbackExecutionId, "Succeeded");
post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, rollbackExecutionId))
.then()
.statusCode(200)
.body("pipelineExecution.executionType", equalTo("ROLLBACK"))
.body("pipelineExecution.rollbackMetadata.rollbackTargetPipelineExecutionId", equalTo(executionId))
.body("pipelineExecution.rollbackTargetPipelineExecutionId", nullValue());
post("TagResource", """
{
"resourceArn": "arn:aws:codepipeline:us-east-1:000000000000:%s",
"tags": [{"key": "environment", "value": "test"}]
}
""".formatted(pipelineName)).then().statusCode(200);
post("ListTagsForResource", """
{"resourceArn": "arn:aws:codepipeline:us-east-1:000000000000:%s"}
""".formatted(pipelineName))
.then()
.statusCode(200)
.body("tags[0].key", equalTo("environment"));
post("ListPipelines", "{}")
.then()
.statusCode(200)
.body("pipelines.name", hasItem(pipelineName));
post("DeletePipeline", """
{"name": "%s"}
""".formatted(pipelineName)).then().statusCode(200);
}
@Test
void customActionUsesAwsWorkerJobProtocol() throws Exception {
createBucket("codepipeline-custom-source");
putObject("codepipeline-custom-source", "source.zip", "custom artifact");
post("CreateCustomActionType", """
{
"category": "Build",
"provider": "FlociWorker",
"version": "1",
"inputArtifactDetails": {"minimumCount": 0, "maximumCount": 1},
"outputArtifactDetails": {"minimumCount": 0, "maximumCount": 1}
}
""")
.then()
.statusCode(200)
.body("actionType.id.owner", equalTo("Custom"));
String pipelineName = "custom-worker-pipeline";
post("CreatePipeline", pipeline(pipelineName, """
{
"name": "Source",
"actions": [{
"name": "SourceObject",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"configuration": {
"S3Bucket": "codepipeline-custom-source",
"S3ObjectKey": "source.zip"
},
"outputArtifacts": [{"name": "SourceOutput"}]
}]
},
{
"name": "Build",
"actions": [{
"name": "WorkerBuild",
"actionTypeId": {
"category": "Build",
"owner": "Custom",
"provider": "FlociWorker",
"version": "1"
},
"inputArtifacts": [{"name": "SourceOutput"}]
}]
}
""")).then().statusCode(200);
String executionId = post("StartPipelineExecution", """
{"name": "%s"}
""".formatted(pipelineName)).then().extract().path("pipelineExecutionId");
Response poll = waitForJob();
String jobId = poll.path("jobs[0].id");
String nonce = poll.path("jobs[0].nonce");
post("AcknowledgeJob", """
{"jobId": "%s", "nonce": "%s"}
""".formatted(jobId, nonce))
.then()
.statusCode(200)
.body("status", equalTo("InProgress"));
post("PutJobSuccessResult", """
{
"jobId": "%s",
"executionDetails": {
"summary": "worker completed",
"externalExecutionId": "worker-1",
"percentComplete": 100
},
"outputVariables": {"result": "ok"}
}
""".formatted(jobId)).then().statusCode(200);
waitForExecution(pipelineName, executionId, "Succeeded");
post("DeleteCustomActionType", """
{"category": "Build", "provider": "FlociWorker", "version": "1"}
""").then().statusCode(200);
}
@Test
void webhookStageTransitionAndValidationErrorsUseAwsShapes() {
post("PutWebhook", """
{
"webhook": {
"name": "source-hook",
"targetPipeline": "pipeline",
"targetAction": "source",
"filters": [{"jsonPath": "$.ref", "matchEquals": "refs/heads/main"}],
"authentication": "UNAUTHENTICATED"
}
}
""")
.then()
.statusCode(200)
.body("webhook.definition.name", equalTo("source-hook"))
.body("webhook.definition.targetPipeline", equalTo("pipeline"))
.body("webhook.definition.targetAction", equalTo("source"))
.body("webhook.registrationStatus", nullValue());
post("RegisterWebhookWithThirdParty", """
{"webhookName": "source-hook"}
""").then().statusCode(200);
post("ListWebhooks", "{}")
.then()
.statusCode(200)
.body("webhooks.definition.name", hasItem("source-hook"))
.body("webhooks[0].definition.filters[0].jsonPath", equalTo("$.ref"))
.body("webhooks[0].registrationStatus", nullValue());
post("DeleteWebhook", """
{"name": "source-hook"}
""")
.then()
.statusCode(200)
.body(equalTo("{}"));
post("CreatePipeline", """
{"pipeline": {"name": "invalid", "roleArn": "role", "stages": []}}
""")
.then()
.statusCode(400)
.body("__type", containsString("InvalidStructureException"));
}
private Response waitForJob() throws Exception {
Instant deadline = Instant.now().plus(Duration.ofSeconds(5));
Response response;
do {
response = post("PollForJobs", """
{
"actionTypeId": {
"category": "Build",
"owner": "Custom",
"provider": "FlociWorker",
"version": "1"
}
}
""");
if (response.jsonPath().getList("jobs").size() == 1) {
return response;
}
Thread.sleep(50);
} while (Instant.now().isBefore(deadline));
throw new AssertionError("Custom action job was not created");
}
private void waitForExecution(String pipelineName, String executionId, String expected) throws Exception {
Instant deadline = Instant.now().plus(Duration.ofSeconds(5));
String status;
do {
status = post("GetPipelineExecution", """
{"pipelineName": "%s", "pipelineExecutionId": "%s"}
""".formatted(pipelineName, executionId))
.jsonPath().getString("pipelineExecution.status");
if (expected.equals(status)) {
return;
}
if ("Failed".equals(status)) {
throw new AssertionError("Pipeline failed");
}
Thread.sleep(50);
} while (Instant.now().isBefore(deadline));
throw new AssertionError("Pipeline did not reach " + expected + ", last status: " + status);
}
private static Response post(String action, String body) {
return given()
.header("X-Amz-Target", TARGET + action)
.contentType(CONTENT_TYPE)
.body(body)
.when()
.post("/");
}
private static String pipeline(String name, String stages) {
return """
{
"pipeline": {
"name": "%s",
"roleArn": "arn:aws:iam::000000000000:role/codepipeline-role",
"artifactStore": {
"type": "S3",
"location": "codepipeline-artifacts"
},
"stages": [%s]
}
}
""".formatted(name, stages);
}
private static void createBucket(String bucket) {
given().when().put("/" + bucket).then().statusCode(200);
}
private static void putObject(String bucket, String key, String body) {
given()
.contentType("application/octet-stream")
.body(body.getBytes(java.nio.charset.StandardCharsets.UTF_8))
.when()
.put("/" + bucket + "/" + key)
.then()
.statusCode(200);
}
}
+4 -1
View File
@@ -38,6 +38,8 @@ floci:
flush-interval-ms: 60000
batch:
flush-interval-ms: 60000
codepipeline:
flush-interval-ms: 60000
s3vectors:
flush-interval-ms: 60000
cloudfront:
@@ -201,6 +203,8 @@ floci:
runner-mode: immediate
codedeploy:
enabled: true
codepipeline:
enabled: true
autoscaling:
enabled: true
transfer:
@@ -230,4 +234,3 @@ floci:
enabled: true
s3vectors:
enabled: true