Skip to content

Commit b00fe7d

Browse files
authored
Merge pull request #155 from pippolino/refactor-pipeline
Add pipeline code and refactor structure
2 parents 9c031ae + f1f4db9 commit b00fe7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+12983
-2873
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/**
2+
**/task.d.ts
3+
**/*.json
4+
**/*.js

.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"project": ['./build/scripts/tsconfig.json', './Tasks/tsconfig.json', './Tasks/*/tsconfig.json'],
6+
},
7+
"env": {
8+
"node": true,
9+
},
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
14+
],
15+
"plugins": [
16+
"@typescript-eslint", "no-null"
17+
],
18+
"rules": {
19+
'@typescript-eslint/await-thenable': 'error',
20+
'@typescript-eslint/no-floating-promises': 'error',
21+
'@typescript-eslint/explicit-module-boundary-types': 'off',
22+
'@typescript-eslint/no-unsafe-call': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
"@typescript-eslint/no-unused-vars": "off",
25+
'@typescript-eslint/restrict-template-expressions': 'off',
26+
'@typescript-eslint/no-unsafe-member-access': 'off',
27+
'@typescript-eslint/no-unsafe-assignment': 'off',
28+
'@typescript-eslint/no-empty-function': 'off'
29+
}
30+
};

.gitignore

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,19 @@
1-
## Ignore Visual Studio temporary files, build results, and
2-
## files generated by popular Visual Studio add-ons.
1+
**/.vscode/
2+
**/.vs/
3+
**/.idea/
4+
**/.DS_Store
35

4-
# User-specific files
5-
*.suo
6-
*.user
7-
*.userosscache
8-
*.sln.docstates
9-
*DS_Store
6+
**/node_modules/
7+
**/package/
108

11-
# User-specific files (MonoDevelop/Xamarin Studio)
12-
*.userprefs
9+
**/*.log
10+
**/*.js
11+
**/*.map
12+
**/*.taskkey
13+
**/*.tsbuildinfo
14+
**/*.loc.json
15+
**/*.LEGAL.txt
16+
**/*.zip
17+
**/resources.resjson
1318

14-
# Build results
15-
[Dd]ebug/
16-
[Dd]ebugPublic/
17-
[Rr]elease/
18-
[Rr]eleases/
19-
x64/
20-
x86/
21-
bld/
22-
dist/
23-
24-
# Visual Studio 2015 cache/options directory
25-
.vs/
26-
.pumafile
27-
28-
node_modules
29-
.vscode
30-
*.vsix
31-
32-
.taskkey
33-
34-
# Dep check data directory files
35-
src/Tasks/dependency-check-build-task/dependency-check/*
36-
src/Tasks/dependency-check-build-task/dependency-check/data/*
37-
src/Tasks/dependency-check-build-task/dependency-check-build-task.js
38-
!src/Tasks/dependency-check-build-task/dependency-check/data
39-
!src/Tasks/dependency-check-build-task/dependency-check/data/README.md
19+
!.eslintrc.js

Tasks/DependencyCheck/Tests/L0.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import fs = require('fs-extra')
2+
import assert = require('assert');
3+
import path = require('path');
4+
import * as ttm from 'azure-pipelines-task-lib/mock-test';
5+
import * as Mocha from 'mocha';
6+
7+
describe('DependencyCheck Suite', function () {
8+
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);
9+
10+
before(() => {
11+
const dataPath = path.join(__dirname, "data");
12+
const dcPath = path.join(dataPath, "dependency-check");
13+
const logPath = path.join(dcPath, "log");
14+
fs.removeSync(dataPath);
15+
fs.mkdirSync(dataPath);
16+
fs.mkdirSync(dcPath);
17+
fs.mkdirSync(logPath);
18+
19+
process.env['PRODUCT_VERSION'] = '0.1.0';
20+
process.env['BUILD_BINARIESDIRECTORY'] = __dirname;
21+
process.env['VSTS_PUBLIC_VARIABLES'] = '["Product.Version","Build.BinariesDirectory"]';
22+
process.env['AGENT_JOBSTATUS'] = "Succeeded";
23+
process.env['AGENT_NAME'] = "MyAgent";
24+
process.env['BUILD_BUILDID'] = "5";
25+
process.env['BUILD_BUILDNUMBER'] = "20210108.1";
26+
process.env['BUILD_REASON'] = "Scheduled";
27+
process.env['BUILD_REPOSITORY_NAME'] = "MyRepo";
28+
process.env['BUILD_SOURCEBRANCHNAME'] = "master";
29+
process.env['BUILD_SOURCEVERSION'] = "122a24f";
30+
process.env['BUILD_SOURCESDIRECTORY'] = __dirname;
31+
process.env['BUILDCONFIGURATION'] = "Debug";
32+
process.env['BUILDPLATFORM'] = "Any CPU";
33+
process.env['SYSTEM_ACCESSTOKEN'] = "";
34+
process.env['SYSTEM_DEFINITIONNAME'] = "MyDefinitionName";
35+
process.env['SYSTEM_TEAMFOUNDATIONSERVERURI'] = "https://myurl.de/mycollection/";
36+
process.env['SYSTEM_TEAMPROJECT'] = "PSItraffic";
37+
process.env['COMMON_TESTRESULTSDIRECTORY'] = "data";
38+
});
39+
40+
after(() => {
41+
});
42+
43+
it('Basic execution', (done: Mocha.Done) => {
44+
let tp: string = path.join(__dirname, 'L0BasicExecution.js');
45+
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
46+
47+
tr.run();
48+
49+
assert(tr.invokedToolCount === 0, 'should not run anything');
50+
assert(tr.stderr.length === 0, 'should not have written to stderr');
51+
assert(tr.succeeded, 'task should have succeeded');
52+
53+
done();
54+
});
55+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import ma = require('azure-pipelines-task-lib/mock-answer');
2+
import tmrm = require('azure-pipelines-task-lib/mock-run');
3+
import path = require('path');
4+
5+
let taskPath = path.join(__dirname, '..', 'dependency-check-build-task.js');
6+
let tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
7+
8+
tr.setInput('enableVerbose', 'true');
9+
tr.setInput('projectName', 'Example Project Name');
10+
tr.setInput('scanPath', '**/*.jar');
11+
tr.setInput('format', 'HTML,SARIF');
12+
tr.setInput('enableExperimental', 'false');
13+
tr.setInput('enableRetired', 'false');
14+
tr.setInput('uploadReports', 'true');
15+
tr.setInput('uploadSARIFReport', 'true');
16+
tr.setInput('warnOnCVSSViolation', 'true');
17+
tr.setInput('reportsDirectory', "data");
18+
19+
// provide answers for task mock
20+
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{};
21+
//a.checkPath[path.join(__dirname, "data")] = true;
22+
//a.checkPath[path.join(__dirname, "data", "dependency-check")] = true;
23+
tr.setAnswers(a);
24+
25+
tr.run();

0 commit comments

Comments
 (0)