Skip to content

Commit

Permalink
upgrade build-chain-config-reader 3.0.13 (#382)
Browse files Browse the repository at this point in the history
* upgrade build-chain-config-reader

* bump version

* fixed e2e tests
  • Loading branch information
shubhbapna authored Feb 9, 2023
1 parent 3ba27fe commit b9b152d
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 62 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kie/build-chain-action",
"version": "3.0.12",
"version": "3.0.13",
"description": "Library to execute commands based on github projects dependencies.",
"main": "dist/index.js",
"author": "",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@actions/core": "^1.8.2",
"@actions/exec": "^1.1.1",
"@actions/glob": "^0.3.0",
"@kie/build-chain-configuration-reader": "^3.0.9",
"@kie/build-chain-configuration-reader": "^3.0.10",
"@octokit/rest": "^18.12.0",
"@octokit/types": "^6.39.0",
"commander": "^9.3.0",
Expand Down
57 changes: 40 additions & 17 deletions test/e2e/branch/branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ beforeEach(async () => {
},
],
},
"owner1/project3": {
pushedBranches: ["branchB"],
history: [
{
action: GitActionTypes.PUSH,
branch: "branchB",
},
],
},
"owner1/project4": {
pushedBranches: ["branchB"],
history: [
Expand Down Expand Up @@ -102,15 +111,15 @@ test("full downstream where 1 project has a PR and one doesn't", async () => {
moctokit.rest.repos
.get({
owner: "owner1",
repo: /project(1|2|4)/,
repo: /project(1|2|4|3)/,
})
.setResponse({ status: 200, data: {}, repeat: 3 }),
.setResponse({ status: 200, data: {}, repeat: 4 }),
moctokit.rest.pulls
.list({
owner: "owner1",
repo: /project(2|4)/,
repo: /project(2|4|3)/,
})
.setResponse({ status: 200, data: [], repeat: 4 }),
.setResponse({ status: 200, data: [], repeat: 6 }),
moctokit.rest.pulls
.list({
owner: "owner1",
Expand All @@ -126,7 +135,7 @@ test("full downstream where 1 project has a PR and one doesn't", async () => {
output: "",
});
expect(result[1]).toMatchObject({ name: "Main ./build-chain", status: 0 });
expect(result[1].groups?.length).toBe(15);
expect(result[1].groups?.length).toBe(18);

// pre section
const group1 = result[1].groups![0];
Expand All @@ -142,12 +151,16 @@ test("full downstream where 1 project has a PR and one doesn't", async () => {
const group2 = result[1].groups![1];
expect(group2.name).toBe("Execution Plan");
expect(group2.output).toEqual(
expect.stringContaining("3 projects will be executed")
expect.stringContaining("4 projects will be executed")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project1]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: upstream")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: upstream")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group2.output).toEqual(expect.stringContaining("Level type: current"));
expect(group2.output).toEqual(expect.stringContaining("[owner1/project4]"));
Expand All @@ -165,6 +178,10 @@ test("full downstream where 1 project has a PR and one doesn't", async () => {
expect(group4.output).toEqual(
expect.stringContaining("Merged owner1/project1:branchB into branch 8.B")
);
expect(group4.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group4.output).toEqual(
expect.stringContaining("Project taken from owner1/project3:branchB")
);
expect(group4.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group4.output).toEqual(
expect.stringContaining("Project taken from owner1/project2:branchB")
Expand Down Expand Up @@ -197,27 +214,33 @@ test("full downstream where 1 project has a PR and one doesn't", async () => {
expect.stringContaining("default after current")
);

// owner1/project2 execution
// owner1/project3 execution
const group9 = result[1].groups![8];
expect(group9.name).toBe("Executing owner1/project2");
expect(group9.name).toBe("Executing owner1/project3");
expect(group9.output).toEqual(
expect.stringContaining("current owner1/project2")
expect.stringContaining("default after current")
);
expect(group9.output).toEqual(expect.stringContaining("default after current"));

// owner1/project4 execution
// owner1/project2 execution
const group12 = result[1].groups![11];
expect(group12.name).toBe("Executing owner1/project4");
expect(group12.name).toBe("Executing owner1/project2");
expect(group12.output).toEqual(
expect.stringContaining("current owner1/project2")
);
expect(group12.output).toEqual(expect.stringContaining("default after current"));

// owner1/project4 execution
const group15 = result[1].groups![14];
expect(group15.name).toBe("Executing owner1/project4");
expect(group15.output).toEqual(
expect.stringContaining("default current")
);
expect(group12.output).toEqual(
expect(group15.output).toEqual(
expect.stringContaining("default after current")
);

const group15 = result[1].groups![14];
expect(group15.name).toBe("Uploading artifacts");
expect(group15.output).toEqual(
const group18 = result[1].groups![17];
expect(group18.name).toBe("Uploading artifacts");
expect(group18.output).toEqual(
expect.stringContaining("No artifacts to archive")
);

Expand Down
91 changes: 57 additions & 34 deletions test/e2e/full-downstream/full-downstream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ beforeEach(async () => {
],
},
"owner1/project3": {
pushedBranches: ["branchC", "8.x"],
pushedBranches: ["8.x", "branchB", "branchA"],
history: [
{
action: GitActionTypes.PUSH,
branch: "branchC",
branch: "8.x",
},
{
action: GitActionTypes.PUSH,
branch: "8.x",
branch: "branchB",
},
{
action: GitActionTypes.PUSH,
branch: "branchA",
},
],
},
Expand Down Expand Up @@ -254,11 +258,11 @@ test("PR from owner1/target:branchA to owner2/target:branchB while using mapping
expect(group2.output).toEqual(
expect.stringContaining("Level type: current")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group2.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: downstream")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group2.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: downstream")
);
Expand Down Expand Up @@ -316,27 +320,27 @@ test("PR from owner1/target:branchA to owner2/target:branchB while using mapping
expect.stringContaining("default after current")
);

// owner1/project2 section
// owner1/project3 section
const group9 = result[1].groups![8];
expect(group9.name).toBe("Executing owner1/project2");
expect(group9.name).toBe("Executing owner1/project3");
expect(group9.output).toEqual(
expect.stringContaining("current owner1/project2")
expect.stringContaining("default after current")
);
expect(group9.output).toEqual(expect.stringContaining("after downstream owner1/project2"));

// owner1/project4 section
// owner1/project2 section
const group12 = result[1].groups![11];
expect(group12.name).toBe("Executing owner1/project4");
expect(group12.output).toEqual(
expect.stringContaining("default current")
);
expect(group12.name).toBe("Executing owner1/project2");
expect(group12.output).toEqual(
expect.stringContaining("default after current")
expect.stringContaining("current owner1/project2")
);
expect(group12.output).toEqual(expect.stringContaining("after downstream owner1/project2"));

// owner1/project3 section
// owner1/project4 section
const group15 = result[1].groups![14];
expect(group15.name).toBe("Executing owner1/project3");
expect(group15.name).toBe("Executing owner1/project4");
expect(group15.output).toEqual(
expect.stringContaining("default current")
);
expect(group15.output).toEqual(
expect.stringContaining("default after current")
);
Expand Down Expand Up @@ -399,15 +403,15 @@ test("PR from target:branchA to target:branchB while using mapping of a non-star
moctokit.rest.repos
.get({
owner: "owner1",
repo: /project(1|2|4)/,
repo: /project(1|2|3|4)/,
})
.setResponse({ status: 200, data: {}, repeat: 3 }),
.setResponse({ status: 200, data: {}, repeat: 4 }),
moctokit.rest.pulls
.list({
owner: "owner1",
repo: /project(1|2|4)/,
repo: /project(1|2|3|4)/,
})
.setResponse({ status: 200, data: [{ title: "pr" }], repeat: 3 }),
.setResponse({ status: 200, data: [{ title: "pr" }], repeat: 4 }),
],
});
expect(result.length).toBe(4);
Expand All @@ -417,7 +421,7 @@ test("PR from target:branchA to target:branchB while using mapping of a non-star
output: "",
});
expect(result[1]).toMatchObject({ name: "Main ./build-chain", status: 0 });
expect(result[1].groups?.length).toBe(15);
expect(result[1].groups?.length).toBe(18);

// pre section
const group1 = result[1].groups![0];
Expand All @@ -433,12 +437,16 @@ test("PR from target:branchA to target:branchB while using mapping of a non-star
const group2 = result[1].groups![1];
expect(group2.name).toBe("Execution Plan");
expect(group2.output).toEqual(
expect.stringContaining("3 projects will be executed")
expect.stringContaining("4 projects will be executed")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project1]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: upstream")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group2.output).toEqual(
expect.stringContaining("Level type: upstream")
);
expect(group2.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group2.output).toEqual(expect.stringContaining("Level type: current"));
expect(group2.output).toEqual(expect.stringContaining("[owner1/project4]"));
Expand All @@ -456,6 +464,15 @@ test("PR from target:branchA to target:branchB while using mapping of a non-star
expect(group4.output).toEqual(
expect.stringContaining("Merged owner1/project1:branchA into branch 8.B")
);
expect(group4.output).toEqual(expect.stringContaining("[owner1/project3]"));
expect(group4.output).toEqual(
expect.stringContaining("Project taken from owner1/project3:branchB")
);
expect(group4.output).toEqual(
expect.stringContaining(
"Merged owner1/project3:branchA into branch branchB"
)
);
expect(group4.output).toEqual(expect.stringContaining("[owner1/project2]"));
expect(group4.output).toEqual(
expect.stringContaining("Project taken from owner1/project2:branchB")
Expand Down Expand Up @@ -488,27 +505,33 @@ test("PR from target:branchA to target:branchB while using mapping of a non-star
expect.stringContaining("default after current")
);

// owner1/project2 section
// owner1/project3 section
const group9 = result[1].groups![8];
expect(group9.name).toBe("Executing owner1/project2");
expect(group9.output).toEqual(
expect.stringContaining("current owner1/project2")
);
expect(group9.name).toBe("Executing owner1/project3");
expect(group9.output).toEqual(expect.stringContaining("default after current"));

// owner1/project4 section

// owner1/project2 section
const group12 = result[1].groups![11];
expect(group12.name).toBe("Executing owner1/project4");
expect(group12.name).toBe("Executing owner1/project2");
expect(group12.output).toEqual(
expect.stringContaining("current owner1/project2")
);
expect(group12.output).toEqual(expect.stringContaining("default after current"));

// owner1/project4 section
const group15 = result[1].groups![14];
expect(group15.name).toBe("Executing owner1/project4");
expect(group15.output).toEqual(
expect.stringContaining("default current")
);
expect(group12.output).toEqual(
expect(group15.output).toEqual(
expect.stringContaining("default after current")
);

const group15 = result[1].groups![14];
expect(group15.name).toBe("Uploading artifacts");
expect(group15.output).toEqual(
const group18 = result[1].groups![17];
expect(group18.name).toBe("Uploading artifacts");
expect(group18.output).toEqual(
expect.stringContaining("No artifacts to archive")
);

Expand Down

0 comments on commit b9b152d

Please sign in to comment.