From 60b31a6452f1ebdd1b3c8077bc70fb9fe2f80a57 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:20:26 +0530 Subject: [PATCH 1/7] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..7d405f9ee --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,36 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' +strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' From e6b5b831a16e0f03af1bdf54ec9e72b57d5807b9 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:33:57 +0530 Subject: [PATCH 2/7] Create starterapi.json --- starterapi.json | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 starterapi.json diff --git a/starterapi.json b/starterapi.json new file mode 100644 index 000000000..57e5ca3dc --- /dev/null +++ b/starterapi.json @@ -0,0 +1,94 @@ +{ + "info": { + "_postman_id": "968b3a18-cc72-48a2-9b6b-e8619b4aaca8", + "name": "Starter APIs", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Create Employee", + "event": [ + { + "listen": "test", + "script": { + "id": "38b1717c-45ae-477f-8dae-8e889ba381d5", + "exec": [ + "pm.test(\"Successful response\", function () {", + " pm.expect(pm.response.text()).to.include(\"success\");", + "});", + "var json = pm.response.json();", + "pm.environment.set(\"id\", json.data.id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"{{name}}\",\n \"salary\": \"{{salary}}\",\n \"age\": \"{{age}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://dummy.restapiexample.com/api/v1/create", + "protocol": "http", + "host": [ + "dummy", + "restapiexample", + "com" + ], + "path": [ + "api", + "v1", + "create" + ] + } + }, + "response": [] + }, + { + "name": "Get All Employees", + "event": [ + { + "listen": "test", + "script": { + "id": "af3cb111-e3ac-4174-b8ca-7f4127a0285d", + "exec": [ + "pm.test(\"Successful response\", function () {", + " pm.expect(pm.response.text()).to.include(\"success\");", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://dummy.restapiexample.com/api/v1/employees", + "protocol": "http", + "host": [ + "dummy", + "restapiexample", + "com" + ], + "path": [ + "api", + "v1", + "employees" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +} From e57c490f000b56fe298a9ed01ed3a6d40fdb2f54 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:34:39 +0530 Subject: [PATCH 3/7] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7d405f9ee..0f40c8bce 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,12 +10,6 @@ pool: vmImage: 'ubuntu-latest' strategy: matrix: - Python27: - python.version: '2.7' - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' Python37: python.version: '3.7' @@ -34,3 +28,14 @@ steps: pip install pytest pytest-azurepipelines pytest displayName: 'pytest' + +- task: CmdLine@2 + displayName: 'install newman' + inputs: + script: 'sudo npm install -g newman' + workingDirectory: $(System.DefaultWorkingDirectory) +- task: CmdLine@2 + displayName: 'Run tests' + inputs: + script: 'newman startapi.json' + workingDirectory: 'starterapi.json' From 8f1c3a6693fa2a9a16590d4f06bb2815b04b4a06 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:38:32 +0530 Subject: [PATCH 4/7] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0f40c8bce..94066823a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -37,5 +37,5 @@ steps: - task: CmdLine@2 displayName: 'Run tests' inputs: - script: 'newman startapi.json' + script: 'newman run starterapi.json' workingDirectory: 'starterapi.json' From d01f40df99e2839da03383c5466bd48a4ddac297 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:42:34 +0530 Subject: [PATCH 5/7] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 94066823a..7a1e55695 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,4 +38,4 @@ steps: displayName: 'Run tests' inputs: script: 'newman run starterapi.json' - workingDirectory: 'starterapi.json' + workingDirectory: 'starter-code/starterapi.json' From a6b0f352b41048b420a2d6aeff03b6c1211bb196 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:49:37 +0530 Subject: [PATCH 6/7] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7a1e55695..8a9280843 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -37,5 +37,5 @@ steps: - task: CmdLine@2 displayName: 'Run tests' inputs: - script: 'newman run starterapi.json' + script: 'ls -1' workingDirectory: 'starter-code/starterapi.json' From f016a5887a0ae5c5384078935790406ab2919361 Mon Sep 17 00:00:00 2001 From: Nitin Dhiman <34596466+NitinD97@users.noreply.github.com> Date: Mon, 29 Jun 2020 05:52:13 +0530 Subject: [PATCH 7/7] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8a9280843..9d74bee4a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -37,5 +37,5 @@ steps: - task: CmdLine@2 displayName: 'Run tests' inputs: - script: 'ls -1' - workingDirectory: 'starter-code/starterapi.json' + script: 'newman run starterapi.json' + workingDirectory: $(Build.SourcesDirectory)