From 3324f51b97ad0affd95720dec4c20b291e89b37f Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Mon, 15 Jul 2019 12:20:39 -0700 Subject: [PATCH] Remove `markdownlint` tests due to security issues (#10163) # Conflicts: # test/common/markdown/markdown.tests.ps1 # test/common/markdown/package.json --- test/common/markdown/gulpfile.js | 60 -------------- test/common/markdown/markdown.tests.ps1 | 101 ------------------------ test/common/markdown/package.json | 25 ------ 3 files changed, 186 deletions(-) delete mode 100644 test/common/markdown/gulpfile.js delete mode 100644 test/common/markdown/markdown.tests.ps1 delete mode 100644 test/common/markdown/package.json diff --git a/test/common/markdown/gulpfile.js b/test/common/markdown/gulpfile.js deleted file mode 100644 index d6e675be2348..000000000000 --- a/test/common/markdown/gulpfile.js +++ /dev/null @@ -1,60 +0,0 @@ -function RunTest() { - "use strict"; - var gulp = require("gulp"); - var concat = require("gulp-concat"); - var through2 = require("through2"); - var markdownlint = require("markdownlint"); - - gulp.task("test-mdsyntax", function task() { - var paths = []; - var rootpath; - - // assign --repoRoot into rootpath - var j = process.argv.indexOf("--rootpath"); - if (j > -1) { - rootpath = process.argv[j + 1]; - } - - if(rootpath == null) - { - throw "--rootpath must be specified before all other parameters" - } - - // parse --filter into paths. --rootpath must be specified first. - var j = process.argv.indexOf("--filter"); - if (j > -1) { - var filters = process.argv[j + 1].split(","); - filters.forEach(function (filter) { - paths.push(rootpath + "/" + filter); - }, this); - } - - if(paths.length == 0) - { - throw "--filter must be specified" - } - - var rootJsonFile = rootpath + "/.markdownlint.json" - var fs = require('fs'); - fs.appendFileSync('markdownissues.txt', '--EMPTY--\r\n'); - return gulp.src(paths, { "read": false }) - .pipe(through2.obj(function obj(file, enc, next) { - markdownlint( - { - "files": [file.path], - "config": require(rootJsonFile) - }, - function callback(err, result) { - var resultString = (result || "").toString(); - if (resultString) { - file.contents = Buffer.from(resultString); - } - next(err, file); - }); - })) - .pipe(concat("markdownissues.txt", { newLine: "\r\n" })) - .pipe(gulp.dest(".")); - }); -} - -RunTest(); diff --git a/test/common/markdown/markdown.tests.ps1 b/test/common/markdown/markdown.tests.ps1 deleted file mode 100644 index 0bb182f94611..000000000000 --- a/test/common/markdown/markdown.tests.ps1 +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -Import-Module HelpersCommon -$moduleRootFilePath = Split-Path -Path $PSScriptRoot -Parent - -# Identify the repository root path of the resource module -$repoRootPath = (Resolve-Path -LiteralPath (Join-path $moduleRootFilePath "../..")).ProviderPath -$repoRootPathFound = $false - -Describe 'Common Tests - Validate Markdown Files' -Tag 'CI' { - BeforeAll { - Push-Location $psscriptroot - $skip = $false - $NpmInstalled = "not installed" - if (Get-Command -Name 'npm' -ErrorAction SilentlyContinue) - { - $NpmInstalled = "Installed" - Write-Verbose -Message "NPM is checking Gulp is installed. This may take a few moments." -Verbose - start-nativeExecution { npm install --silent } - start-nativeExecution { npm install 'gulp@4.0.0' --silent } - if(!(Get-Command -Name 'gulp' -ErrorAction SilentlyContinue)) - { - start-nativeExecution { - sudo npm install -g 'gulp@4.0.0' --silent - # Sometimes this folder is left behind with root permissions and is needed by later NPM installs which don't need sudo - sudo rm -rf ~/.npm/_cacache - } - } - if(!(Get-Command -Name 'node' -ErrorAction SilentlyContinue)) - { - throw "node not found" - } - } - if(!(Get-Command -Name 'node' -ErrorAction SilentlyContinue)) - { - <# - On Windows, pre-requisites are missing - For now we will skip, and write a warning. Work to resolve this is tracked in: - https://github.com/PowerShell/PowerShell/issues/3429 - #> - Write-Warning "Node and npm are required to run this test" - $skip = $true - } - - $mdIssuesPath = Join-Path -Path $PSScriptRoot -ChildPath "markdownissues.txt" - Remove-Item -Path $mdIssuesPath -Force -ErrorAction SilentlyContinue - } - - AfterAll { - Pop-Location - } - - It "Should not have errors in any markdown files" -skip:$skip { - $NpmInstalled | should BeExactly "Installed" - $mdErrors = 0 - Push-Location -Path $PSScriptRoot - try - { - $docsToTest = @( - './.github/*.md' - './README.md' - './demos/python/*.md' - './docker/*.md' - './docs/building/*.md' - './docs/community/*.md' - './docs/host-powershell/*.md' - './docs/cmdlet-example/*.md' - './docs/maintainers/*.md' - './test/powershell/README.md' - './tools/*.md' - './.github/ISSUE_TEMPLATE/*.md' - ) - $filter = ($docsToTest -join ',') - - # Gulp 4 beta is returning non-zero exit code even when there is not an error - Start-NativeExecution { - &"gulp" test-mdsyntax --silent ` - --rootpath $repoRootPath ` - --filter $filter - } -VerboseOutputOnError -IgnoreExitcode - - } - finally - { - Pop-Location - } - - $mdIssuesPath | Should -Exist - - [string[]] $markdownErrors = Get-Content -Path $mdIssuesPath - Remove-Item -Path $mdIssuesPath -Force -ErrorAction SilentlyContinue - - if ($markdownErrors -ne "--EMPTY--") - { - $markdownErrors += ' (See https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md for an explanation of the error codes)' - } - - $markdownErrors -join "`n" | Should -BeExactly "--EMPTY--" - } -} diff --git a/test/common/markdown/package.json b/test/common/markdown/package.json deleted file mode 100644 index ba553a917dda..000000000000 --- a/test/common/markdown/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "powershell.common.markdown.tests", - "version": "1.0.0", - "description": "The PowerShell Common MarkDown Tests.", - "main": "gulpfile.js", - "dependencies": { - "gulp": "^4.0.2", - "markdownlint": "^0.11.0", - "through2": "^2.0.1" - }, - "devDependencies": { - "gulp-concat": "^2.6.1", - "gulp-debug": "^3.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/PowerShell/PowerShell.git" - }, - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/PowerShell/PowerShell/issues" - }, - "homepage": "https://github.com/PowerShell/PowerShell#readme" -}