From 60cb996eb04ae4c94b847a22a4d4f2d37fa9ba3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 10 Dec 2024 08:46:11 +0100 Subject: [PATCH 1/4] Update gitignore to exlude taskkey for testing --- .gitignore | 5 +- .../UnityGetProjectVersionV1/test/_suite.ts | 66 +++++++++++-------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 633d322..11dc7c7 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,7 @@ dist *.js *.vsix -.vs/ \ No newline at end of file +.vs/ + +# Azure DevOps extensions +.taskkey \ No newline at end of file diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts index 605dadf..ab60c0b 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts @@ -2,58 +2,70 @@ import assert from 'assert'; import * as mocktest from 'azure-pipelines-task-lib/mock-test'; import * as path from 'path'; -describe("Unity Get Project Version", async () => { - it("Error determining the project version from file", async () => { +describe("Unity Get Project Version", () => { + it("Error determining the project version from file", (done) => { let testPath = path.join(__dirname, 'errorDeterminingTheProjectVersionFromFile.js'); let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath); - await runner.runAsync(); + runner.runAsync() + .then(() => { + assert.strictEqual(runner.failed, true); + assert.strictEqual(runner.invokedToolCount, 0); + assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered')); - assert.strictEqual(runner.failed, true); - assert.strictEqual(runner.invokedToolCount, 0); - assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered')); + done(); + }); }) - it("Success (alpha) determining the project version from file", async () => { + it("Success (alpha) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successAlphaDeterminingTheProjectVersionFromFile.js'); let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath); - await runner.runAsync(); + runner.runAsync() + .then(() => { + assert.strictEqual(runner.succeeded, true); + assert.strictEqual(runner.invokedToolCount, 0); + assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49a1, revision=4dae1bb8668d, alpha=true, beta=false')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49a1')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); - assert.strictEqual(runner.succeeded, true); - assert.strictEqual(runner.invokedToolCount, 0); - assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49a1, revision=4dae1bb8668d, alpha=true, beta=false')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49a1')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); + done(); + }); }) - it("Success (beta) determining the project version from file", async () => { + it("Success (beta) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successBetaDeterminingTheProjectVersionFromFile.js'); let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath); - await runner.runAsync(); + runner.runAsync() + .then(() => { + assert.strictEqual(runner.succeeded, true); + assert.strictEqual(runner.invokedToolCount, 0); + assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49b1, revision=4dae1bb8668d, alpha=false, beta=true')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49b1')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); - assert.strictEqual(runner.succeeded, true); - assert.strictEqual(runner.invokedToolCount, 0); - assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49b1, revision=4dae1bb8668d, alpha=false, beta=true')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49b1')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); + done(); + }); }) - it("Success (stable) determining the project version from file", async () => { + it("Success (stable) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successStableDeterminingTheProjectVersionFromFile.js'); let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath); - await runner.runAsync(); + runner.runAsync() + .then(() => { + assert.strictEqual(runner.succeeded, true); + assert.strictEqual(runner.invokedToolCount, 0); + assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49f1, revision=4dae1bb8668d, alpha=false, beta=false')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49f1')); + assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); - assert.strictEqual(runner.succeeded, true); - assert.strictEqual(runner.invokedToolCount, 0); - assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49f1, revision=4dae1bb8668d, alpha=false, beta=false')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49f1')); - assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d')); + done(); + }); }) }) \ No newline at end of file From 7a6f35d7c60d7de5a97d305383a1a898accd16ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 10 Dec 2024 08:46:41 +0100 Subject: [PATCH 2/4] Do not build when running test --- .../UnityGetProjectVersionV1/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json index 2178ecf..1e58df5 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json @@ -5,7 +5,7 @@ "main": "unity-get-project-version.js", "scripts": { "build": "tsc", - "test": "npm run build && nyc mocha test/_suite.js", + "test": "nyc mocha test/_suite.js", "upload": "tfx build tasks upload --task-path ./", "dev-delete": "tfx build tasks delete --task-id 38ec98bf-601a-4390-9f2e-23d43dd6dbba", "dev-upload": "npm run build && npm run upload" From 05301e7f5ba805911066e12c8b69dc550171ebfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 10 Dec 2024 08:49:33 +0100 Subject: [PATCH 3/4] Update UnityGetProjectVersionV1 shared library dependency --- .../UnityGetProjectVersionV1/CHANGELOG.md | 6 ++++++ .../UnityGetProjectVersionV1/package.json | 4 ++-- .../UnityGetProjectVersionV1/task.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/CHANGELOG.md b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/CHANGELOG.md index 037aac0..d9ede73 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/CHANGELOG.md +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] + +### Changed + +- Updated shared library (https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks-lib) dependency + ## [1.1.0] ### Fixed diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json index 1e58df5..6ccee19 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json @@ -1,6 +1,6 @@ { "name": "@dinomite-studios/unity-get-project-version-task", - "version": "1.1.0", + "version": "1.1.1", "description": "Azure Pipelines task to get the project version of a Unity project.", "main": "unity-get-project-version.js", "scripts": { @@ -19,7 +19,7 @@ "dependencies": { "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.0.9", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.0.11", "azure-pipelines-task-lib": "^4.17.3" }, "devDependencies": { diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/task.json b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/task.json index abbeacf..f152230 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/task.json +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/task.json @@ -12,7 +12,7 @@ "version": { "Major": 1, "Minor": 1, - "Patch": 0 + "Patch": 1 }, "releaseNotes": "[Full Changelog](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/master/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/CHANGELOG.md)", "minimumAgentVersion": "2.144.0", From 80bb0492e08aff1a674fa9bfd0433fcacef213dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 10 Dec 2024 08:58:57 +0100 Subject: [PATCH 4/4] Try using LoadAsync when creating mock task runner --- .../UnityGetProjectVersionV1/test/_suite.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts index ab60c0b..cb63739 100644 --- a/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts +++ b/Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts @@ -2,21 +2,23 @@ import assert from 'assert'; import * as mocktest from 'azure-pipelines-task-lib/mock-test'; import * as path from 'path'; -describe("Unity Get Project Version", () => { +describe("Unity Get Project Version V1 tests", () => { it("Error determining the project version from file", (done) => { - let testPath = path.join(__dirname, 'errorDeterminingTheProjectVersionFromFile.js'); + const testPath = path.join(__dirname, 'errorDeterminingTheProjectVersionFromFile.js'); + const runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(); - let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath); - - runner.runAsync() + runner.LoadAsync(testPath) .then(() => { - assert.strictEqual(runner.failed, true); - assert.strictEqual(runner.invokedToolCount, 0); - assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered')); - - done(); + runner.runAsync() + .then(() => { + assert.strictEqual(runner.failed, true); + assert.strictEqual(runner.invokedToolCount, 0); + assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered')); + + done(); + }); }); - }) + }); it("Success (alpha) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successAlphaDeterminingTheProjectVersionFromFile.js'); @@ -33,7 +35,7 @@ describe("Unity Get Project Version", () => { done(); }); - }) + }); it("Success (beta) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successBetaDeterminingTheProjectVersionFromFile.js'); @@ -50,7 +52,7 @@ describe("Unity Get Project Version", () => { done(); }); - }) + }); it("Success (stable) determining the project version from file", (done) => { let testPath = path.join(__dirname, 'successStableDeterminingTheProjectVersionFromFile.js'); @@ -67,5 +69,5 @@ describe("Unity Get Project Version", () => { done(); }); - }) -}) \ No newline at end of file + }); +}); \ No newline at end of file