Skip to content

Commit

Permalink
fix: update Java pipeline project to resolve sample issues
Browse files Browse the repository at this point in the history
  • Loading branch information
agdimech committed May 13, 2022
1 parent 061dcff commit c8592fc
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 20 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/test/pdk-pipeline-py-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('pdk-pipeline-py E2E Tests', () => {
// https://github.com/projen/projen/blob/e5899dd04a575209424a08fe90bde99e07ac6c7b/src/common.ts#L5
process.env.NODE_ENV='_test';

execSync('npx projen new --from aws-prototyping-sdk pdk-pipeline-py --no-git', {
execSync('npx projen new --from aws-prototyping-sdk pdk-pipeline-py --no-git --module-name=e2e_python', {
cwd: tempFolder,
env: process.env, // This is important to make sure we use the local registry!
stdio: 'inherit',
Expand Down
7 changes: 5 additions & 2 deletions packages/aws-prototyping-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export * as pdk_pipeline from "./pdk_pipeline";
export * as pdk_projen from "./pdk_projen";
export class Hello {
public sayHello() {
return "hello, world!";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class PDKPipelineJavaProject extends AwsCdkJavaApp {
junit: false,
...options,
mainClass:
options.mainClass ||
'software.aws.Pipeline -Dexec.classpathScope="test"',
cdkVersion: options.cdkVersion || "2.0.0",
options.mainClass !== "org.acme.MyApp"
? options.mainClass
: 'software.aws.Pipeline -Dexec.classpathScope="test"',
});

this.addDependency("software.aws.awsprototypingsdk/aws-prototyping-sdk@^0");
Expand All @@ -33,16 +33,48 @@ export class PDKPipelineJavaProject extends AwsCdkJavaApp {
this.addTestDependency("org.junit.jupiter/junit-jupiter-api@5.7.0");
this.addTestDependency("org.junit.jupiter/junit-jupiter-engine@5.7.0");

new SampleDir(this, "src", {
sourceDir: path.join(
__dirname,
"..",
"..",
"..",
"samples",
"sample-pdk-pipeline-java",
"src"
),
});
const mainPackage = this.mainClass
.split(" ")[0]
.split(".")
.slice(0, -1)
.join(".");
new SampleDir(
this,
path.join("src", "main", "java", ...mainPackage.split(".")),
{
sourceDir: path.join(
__dirname,
"..",
"..",
"..",
"samples",
"sample-pdk-pipeline-java",
"src",
"main",
"java",
"software",
"aws"
),
}
);
new SampleDir(
this,
path.join("src", "test", "java", ...mainPackage.split(".")),
{
sourceDir: path.join(
__dirname,
"..",
"..",
"..",
"samples",
"sample-pdk-pipeline-java",
"src",
"test",
"java",
"software",
"aws"
),
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class PDKPipelinePyProject extends AwsCdkPythonApp {
...options,
appEntrypoint:
options.appEntrypoint || `${options.moduleName}/pipeline.py`,
cdkVersion: options.cdkVersion || "2.0.0",
});

["aws-prototyping-sdk", "pyhumps"].forEach((dep) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class PDKPipelineTsProject extends AwsCdkTypeScriptApp {
sampleCode: false,
...options,
appEntrypoint: options.appEntrypoint || "pipeline.ts",
cdkVersion: options.cdkVersion || "2.0.0",
});

this.addDeps("aws-prototyping-sdk");
Expand Down
8 changes: 8 additions & 0 deletions packages/aws-prototyping-sdk/test/hello.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { Hello } from "../src";

test("hello", () => {
expect(new Hello().sayHello()).toBe("hello, world!");
});
15 changes: 15 additions & 0 deletions samples/sample-pdk-pipeline-py/tests/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest

from infra.example import hello

@pytest.mark.parametrize(
("name", "expected"),
[
("A. Musing", "Hello A. Musing!"),
("traveler", "Hello traveler!"),
("projen developer", "Hello projen developer!"),
],
)
def test_hello(name, expected):
"""Example test with parametrization."""
assert hello(name) == expected
2 changes: 1 addition & 1 deletion yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8592fc

Please sign in to comment.