From 7a17bcef340e63dbf6ba66fcc189cf2a76d6ddea Mon Sep 17 00:00:00 2001 From: andycampbell Date: Wed, 15 Jul 2020 17:56:06 -0400 Subject: [PATCH 1/2] Add ci configs for CircleCI and Azure pipelines. Also, use more specific test apis for better failure diagnostics. --- .circleci/config.yml | 15 ++++++++++++++ azure-pipelines.yml | 19 ++++++++++++++++++ .../Root.type.Files/.circleci.type.File.xml | 2 ++ .../1.type.DIR_SIGNIFIER.xml | 2 ++ .../config.yml.type.File.xml | 2 ++ .../azure-pipelines.yml.type.File.xml | 2 ++ tests/fileTest.m | 11 ++++------ tests/rulesTest.m | 20 +++++++++---------- tests/valueRetrieveTest.m | 4 ++-- 9 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 azure-pipelines.yml create mode 100644 resources/project/Root.type.Files/.circleci.type.File.xml create mode 100644 resources/project/Root.type.Files/.circleci.type.File/1.type.DIR_SIGNIFIER.xml create mode 100644 resources/project/Root.type.Files/.circleci.type.File/config.yml.type.File.xml create mode 100644 resources/project/Root.type.Files/azure-pipelines.yml.type.File.xml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..408b0d2 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,15 @@ +version: 2.1 +orbs: + matlab: mathworks/matlab@0.1 + +jobs: + build: + machine: + image: ubuntu-1604:201903-01 + steps: + - checkout + - matlab/install + - matlab/run-tests: + test-results-junit: test-results/matlab/results.xml + - store_test_results: + path: test-results \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..04ebdbe --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,19 @@ +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' + +steps: + - task: RunMATLABTests@0 + inputs: + testResultsJUnit: test-results/results.xml + codeCoverageCobertura: code-coverage/coverage.xml + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: test-results/results.xml + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: code-coverage/coverage.xml \ No newline at end of file diff --git a/resources/project/Root.type.Files/.circleci.type.File.xml b/resources/project/Root.type.Files/.circleci.type.File.xml new file mode 100644 index 0000000..1c0844e --- /dev/null +++ b/resources/project/Root.type.Files/.circleci.type.File.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/Root.type.Files/.circleci.type.File/1.type.DIR_SIGNIFIER.xml b/resources/project/Root.type.Files/.circleci.type.File/1.type.DIR_SIGNIFIER.xml new file mode 100644 index 0000000..1c0844e --- /dev/null +++ b/resources/project/Root.type.Files/.circleci.type.File/1.type.DIR_SIGNIFIER.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/Root.type.Files/.circleci.type.File/config.yml.type.File.xml b/resources/project/Root.type.Files/.circleci.type.File/config.yml.type.File.xml new file mode 100644 index 0000000..1c0844e --- /dev/null +++ b/resources/project/Root.type.Files/.circleci.type.File/config.yml.type.File.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/Root.type.Files/azure-pipelines.yml.type.File.xml b/resources/project/Root.type.Files/azure-pipelines.yml.type.File.xml new file mode 100644 index 0000000..1c0844e --- /dev/null +++ b/resources/project/Root.type.Files/azure-pipelines.yml.type.File.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tests/fileTest.m b/tests/fileTest.m index 3dfc6b6..bcff494 100644 --- a/tests/fileTest.m +++ b/tests/fileTest.m @@ -5,21 +5,18 @@ end function testFileNotFound(testCase) -try - d = dotenv('config/dotenv'); % dosen't exist -catch ME - assert(string(ME.identifier) == 'DOTENV:CannotOpenFile'); -end +testCase.verifyError(@() dotenv('config/dotenv'), 'DOTENV:CannotOpenFile', ... + 'Should error properly for file that doesn''t exist'); end function testDefaultLocation(testCase) %% Opens default ./.env file d = dotenv(); -assert(d.env.DB_HOST == "localhost"); +testCase.verifyEqual(d.env.DB_HOST, "localhost"); end function testNamedLocation(testCase) %% Opens nested .env file d = dotenv('../config/.env'); -assert(d.env.DB_HOST == "localhost"); +testCase.verifyEqual(d.env.DB_HOST, "localhost"); end \ No newline at end of file diff --git a/tests/rulesTest.m b/tests/rulesTest.m index 4f6b9d0..6000c18 100644 --- a/tests/rulesTest.m +++ b/tests/rulesTest.m @@ -10,57 +10,57 @@ function testTopComment(testCase) % Tests that lines starting with # are skipped % specifically tests first line comment d = dotenv('../config/topcomment.env'); -assert(numel(fieldnames(d.env)) == 3); +testCase.verifyNumElements(fieldnames(d.env), 3); end function testMiddleComment(testCase) % Tests that lines starting with # are skipped % specifically tests interior comment d = dotenv('../config/middlecomment.env'); -assert(numel(fieldnames(d.env)) == 3); +testCase.verifyNumElements(fieldnames(d.env), 3); end function testBottomComment(testCase) % Tests that lines starting with # are skipped % specifically tests last line comment d = dotenv('../config/bottomcomment.env'); -assert(numel(fieldnames(d.env)) == 3); +testCase.verifyNumElements(fieldnames(d.env), 3); end function testBlankLines(testCase) d = dotenv('../config/blanklines.env'); -assert(numel(fieldnames(d.env)) == 4); +testCase.verifyNumElements(fieldnames(d.env), 4); end function testEqualsInPassword(testCase) d = dotenv('../config/equalPassword.env'); -assert("s1mpl3=123" == d.env.DB_PASS); +testCase.verifyEqual("s1mpl3=123", d.env.DB_PASS); end function testWhitespaceValue(testCase) d = dotenv('../config/whitespace.env'); -assert("localhost server" == d.env.DB_HOST); +testCase.verifyEqual("localhost server", d.env.DB_HOST); end function testEmptyValue(testCase) d = dotenv('../config/empty.env'); -assert("" == d.env.DB_HOST); +testCase.verifyEqual(d.env.DB_HOST,""); end function testUnquotedWhitespace(testCase) % D.configure should trim leading and trailing whitespace for whitespace values d = dotenv('../config/whitespace.env'); -assert("george" == d.env.DB_USER); +testCase.verifyEqual(d.env.DB_USER, "george"); end function testQuotedValues(testCase) d = dotenv('../config/whitespace.env'); -assert('" mypass "' == d.env.DB_PASS); +testCase.verifyEqual(d.env.DB_PASS, """ mypass """); end function testSingleValue(testCase) d = dotenv('../config/single.env'); -assert("localhost" == d.env.DB_HOST); +testCase.verifyEqual(d.env.DB_HOST, "localhost"); end diff --git a/tests/valueRetrieveTest.m b/tests/valueRetrieveTest.m index 4dc7f58..409bcb2 100644 --- a/tests/valueRetrieveTest.m +++ b/tests/valueRetrieveTest.m @@ -7,11 +7,11 @@ function testValidData(testCase) d = dotenv(); -assert(d.env.DB_HOST == "localhost"); +testCase.verifyEqual(d.env.DB_HOST,"localhost"); end function testInvalidName(testCase) d = dotenv(); -assert(d.env.DB_HOSED == ""); % doesn't exist +testCase.verifyEqual(d.env.DB_HOSED, "", 'DB_HOSED variable doesn''t exist'); end From 9307fdef7d0802c9c79f9017ed7e74a0a10c5b9b Mon Sep 17 00:00:00 2001 From: andycampbell Date: Wed, 15 Jul 2020 18:01:02 -0400 Subject: [PATCH 2/2] Add cloud install step --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 04ebdbe..ed8b783 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,6 +5,7 @@ pool: vmImage: 'ubuntu-latest' steps: + - task: InstallMATLAB@0 - task: RunMATLABTests@0 inputs: testResultsJUnit: test-results/results.xml