From b9b152d269de2b0ae0005031922b77239ca21d67 Mon Sep 17 00:00:00 2001 From: Shubh Bapna <38372682+shubhbapna@users.noreply.github.com> Date: Thu, 9 Feb 2023 15:30:26 -0500 Subject: [PATCH] upgrade build-chain-config-reader 3.0.13 (#382) * upgrade build-chain-config-reader * bump version * fixed e2e tests --- package-lock.json | 18 ++-- package.json | 4 +- test/e2e/branch/branch.test.ts | 57 ++++++++---- .../full-downstream/full-downstream.test.ts | 91 ++++++++++++------- 4 files changed, 108 insertions(+), 62 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e8b1d2c..1b642f4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@kie/build-chain-action", - "version": "3.0.12", + "version": "3.0.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@kie/build-chain-action", - "version": "3.0.12", + "version": "3.0.13", "license": "ISC", "dependencies": { "@actions/artifact": "^1.1.0", "@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", @@ -1271,9 +1271,9 @@ "dev": true }, "node_modules/@kie/build-chain-configuration-reader": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@kie/build-chain-configuration-reader/-/build-chain-configuration-reader-3.0.9.tgz", - "integrity": "sha512-gJYFlIraEDEcuQHAY7vb5vLJUj4smRhuBo9sTEZGyccp4xjckCXyKULqjU51pWc1goIM0k224c6jjTIqZFthUQ==", + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@kie/build-chain-configuration-reader/-/build-chain-configuration-reader-3.0.10.tgz", + "integrity": "sha512-CuAaM2KcDLsBWS2p5PlUSKwS6BtMA4JgfpOUorm9PRr4s/qNQpcc/CEe0pAzdAO2et0zTfHaG81JZYl4S+KZxQ==", "dependencies": { "ajv": "^8.11.0", "axios": "^0.27.2", @@ -8545,9 +8545,9 @@ } }, "@kie/build-chain-configuration-reader": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@kie/build-chain-configuration-reader/-/build-chain-configuration-reader-3.0.9.tgz", - "integrity": "sha512-gJYFlIraEDEcuQHAY7vb5vLJUj4smRhuBo9sTEZGyccp4xjckCXyKULqjU51pWc1goIM0k224c6jjTIqZFthUQ==", + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@kie/build-chain-configuration-reader/-/build-chain-configuration-reader-3.0.10.tgz", + "integrity": "sha512-CuAaM2KcDLsBWS2p5PlUSKwS6BtMA4JgfpOUorm9PRr4s/qNQpcc/CEe0pAzdAO2et0zTfHaG81JZYl4S+KZxQ==", "requires": { "ajv": "^8.11.0", "axios": "^0.27.2", diff --git a/package.json b/package.json index c23cda70..9203192a 100644 --- a/package.json +++ b/package.json @@ -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": "", @@ -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", diff --git a/test/e2e/branch/branch.test.ts b/test/e2e/branch/branch.test.ts index ec71b7c0..9c25002b 100644 --- a/test/e2e/branch/branch.test.ts +++ b/test/e2e/branch/branch.test.ts @@ -50,6 +50,15 @@ beforeEach(async () => { }, ], }, + "owner1/project3": { + pushedBranches: ["branchB"], + history: [ + { + action: GitActionTypes.PUSH, + branch: "branchB", + }, + ], + }, "owner1/project4": { pushedBranches: ["branchB"], history: [ @@ -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", @@ -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]; @@ -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]")); @@ -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") @@ -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") ); diff --git a/test/e2e/full-downstream/full-downstream.test.ts b/test/e2e/full-downstream/full-downstream.test.ts index 78ede215..512dae36 100644 --- a/test/e2e/full-downstream/full-downstream.test.ts +++ b/test/e2e/full-downstream/full-downstream.test.ts @@ -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", }, ], }, @@ -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") ); @@ -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") ); @@ -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); @@ -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]; @@ -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]")); @@ -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") @@ -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") );