Skip to content

Commit b03b968

Browse files
xtqqczzeTravisEz13
andauthored
Restore markdownlint tests (PowerShell#12549)
Co-authored-by: Travis Plunk <[email protected]>
1 parent 5a42f45 commit b03b968

File tree

14 files changed

+2574
-46
lines changed

14 files changed

+2574
-46
lines changed

.github/ISSUE_TEMPLATE/Bug_Report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ This repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.
2020
2121
-->
2222

23-
# Steps to reproduce
23+
## Steps to reproduce
2424

2525
```powershell
2626
2727
```
2828

29-
# Expected behavior
29+
## Expected behavior
3030

3131
```none
3232
3333
```
3434

35-
# Actual behavior
35+
## Actual behavior
3636

3737
```none
3838
3939
```
4040

41-
# Environment data
41+
## Environment data
4242

4343
<!-- provide the output of $PSVersionTable -->
4444

.github/ISSUE_TEMPLATE/Distribution_Request.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ assignees: ''
77

88
---
99

10-
# Details of the Distribution
10+
## Details of the Distribution
1111

12-
- Name of the Distribution:
12+
- Name of the Distribution:
1313
- Version of the Distribution:
1414
- Package Types
15-
- [ ] Deb
16-
- [ ] RPM
17-
- [ ] Tar.gz
18-
- Snap - Please file issue in https://github.com/powershell/powershell-snap. This issues type is unrelated to snap packages with a distribution neutral.
19-
- Processor Architecture (One per request):
15+
- [ ] Deb
16+
- [ ] RPM
17+
- [ ] Tar.gz
18+
- Snap - Please file issue in https://github.com/powershell/powershell-snap. This issues type is unrelated to snap packages with a distribution neutral.
19+
- Processor Architecture (One per request):
2020
- [ ] **Required** - An issues has been filed to create a Docker image in https://github.com/powershell/powershell-docker
2121
- The following is a requirement for supporting a distribution **without exception.**
22-
- [ ] The version and architecture of the Distribution is [supported by .NET Core](https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-supported-os.md#linux).
22+
- [ ] The version and architecture of the Distribution is [supported by .NET Core](https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-supported-os.md#linux).
2323
- The following are requirements for supporting a distribution.
24-
Please write a justification for any exception where these criteria are not met and
24+
Please write a justification for any exception where these criteria are not met and
2525
the PowerShell committee will review the request.
26-
- [ ] The version of the Distribution is supported for at least one year.
27-
- [ ] The version of the Distribution is not an [interim release](https://ubuntu.com/about/release-cycle) or equivalent.
26+
- [ ] The version of the Distribution is supported for at least one year.
27+
- [ ] The version of the Distribution is not an [interim release](https://ubuntu.com/about/release-cycle) or equivalent.
2828

2929
## Progress - For PowerShell Team **ONLY**
3030

.github/ISSUE_TEMPLATE/Feature_Request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ assignees: ''
77

88
---
99

10-
# Summary of the new feature/enhancement
10+
## Summary of the new feature/enhancement
1111

1212
<!--
1313
A clear and concise description of what the problem is that the new feature would solve.
1414
Try formulating it in user story style (if applicable):
1515
'As a user I want X so that Y.' with X being the being the action and Y being the value of the action.
1616
-->
1717

18-
# Proposed technical implementation details (optional)
18+
## Proposed technical implementation details (optional)
1919

2020
<!--
2121
A clear and concise description of what you want to happen.

.github/ISSUE_TEMPLATE/Release_Process.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This template is for maintainers to create an issues to track the release proces
1212
Please **only** use this template if you are a maintainer.
1313
-->
1414

15-
# Release Process for v6.x.x
15+
## Checklist
1616

1717
- [ ] Verify that `PowerShell-Native` has been updated/released as needed.
1818
- [ ] Check for `PowerShellGet` and `PackageManagement` release plans.

.github/ISSUE_TEMPLATE/Security_Issue_Report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ assignees: 'TravisEz13'
77

88
---
99

10-
# Security Issue
10+
## Security Issue
1111

1212
Excerpt from [Issue Management - Security Vulnerabilities](https://github.com/PowerShell/PowerShell/blob/master/.github/SECURITY.md)
1313

.vsts-ci/misc-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ jobs:
6868
}
6969
displayName: Run Common Tests
7070
condition: succeededOrFailed()
71+
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
72+
displayName: 'Component Detection'
73+
inputs:
74+
sourceScanPath: '$(Build.SourcesDirectory)'
75+
snapshotForceEnabled: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ We have a Gitter Room which you can join below.
144144
[![Join the chat](https://img.shields.io/static/v1.svg?label=chat&message=on%20gitter&color=informational&logo=gitter)](https://gitter.im/PowerShell/PowerShell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
145145

146146
There is also the community driven PowerShell Virtual User Group, which you can join on:
147+
147148
* [Slack](https://aka.ms/psslack)
148149
* [Discord](https://aka.ms/psdiscord)
149150

test/common/markdown/gulpfile.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
function runTest() {
5+
"use strict";
6+
var gulp = require("gulp");
7+
var concat = require("gulp-concat");
8+
var through2 = require("through2");
9+
var markdownlint = require("markdownlint");
10+
11+
gulp.task("test-mdsyntax", function task() {
12+
var paths = [];
13+
var rootpath;
14+
15+
// assign --repoRoot <rootpath> into rootpath
16+
var j = process.argv.indexOf("--rootpath");
17+
if (j > -1) {
18+
rootpath = process.argv[j + 1];
19+
}
20+
21+
if (rootpath === null) {
22+
throw "--rootpath <repoRoot> must be specified before all other parameters";
23+
}
24+
25+
// parse --filter into paths. --rootpath must be specified first.
26+
j = process.argv.indexOf("--filter");
27+
if (j > -1) {
28+
var filters = process.argv[j + 1].split(",");
29+
filters.forEach(function(filter) {
30+
paths.push(rootpath + "/" + filter);
31+
}, this);
32+
}
33+
34+
if (paths.length === 0) {
35+
throw "--filter <filter relative to repoRoot> must be specified";
36+
}
37+
38+
var rootJsonFile = rootpath + "/.markdownlint.json";
39+
var fs = require("fs");
40+
fs.appendFileSync("markdownissues.txt", "--EMPTY--\r\n");
41+
return gulp.src(paths, { "read": false })
42+
.pipe(through2.obj(function obj(file, enc, next) {
43+
markdownlint({
44+
"files": [file.path],
45+
"config": require(rootJsonFile)
46+
},
47+
function callback(err, result) {
48+
var resultString = (result || "").toString();
49+
if (resultString) {
50+
file.contents = Buffer.from(resultString);
51+
}
52+
next(err, file);
53+
});
54+
}))
55+
.pipe(concat("markdownissues.txt", { newLine: "\r\n" }))
56+
.pipe(gulp.dest("."));
57+
});
58+
}
59+
60+
runTest();

test/common/markdown/markdown-link.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Describe "Verify Markdown Links" {
105105
$prefix = $url.Substring(0,7)
106106

107107
# Logging for diagnosability. Azure DevOps sometimes redacts the full url.
108-
Write-Verbose "prefix: '$prefix'" -Verbose
108+
Write-Verbose "prefix: '$prefix'"
109109
if($url -match '^http(s)?:')
110110
{
111111
# If invoke-WebRequest can handle the URL, re-verify, with 6 retries
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
Import-Module HelpersCommon
5+
$moduleRootFilePath = Split-Path -Path $PSScriptRoot -Parent
6+
7+
# Identify the repository root path of the resource module
8+
$repoRootPath = (Resolve-Path -LiteralPath (Join-Path $moduleRootFilePath "../..")).ProviderPath
9+
$repoRootPathFound = $false
10+
11+
Describe 'Common Tests - Validate Markdown Files' -Tag 'CI' {
12+
BeforeAll {
13+
Push-Location $psscriptroot
14+
$skip = $false
15+
$NpmInstalled = "not installed"
16+
if (Get-Command -Name 'yarn' -ErrorAction SilentlyContinue)
17+
{
18+
$NpmInstalled = "Installed"
19+
Write-Verbose -Message "Checking if Gulp is installed. This may take a few moments." -Verbose
20+
start-nativeExecution { yarn }
21+
if(!(Get-Command -Name 'gulp' -ErrorAction SilentlyContinue))
22+
{
23+
start-nativeExecution {
24+
sudo yarn global add '[email protected]'
25+
}
26+
}
27+
if(!(Get-Command -Name 'node' -ErrorAction SilentlyContinue))
28+
{
29+
throw "node not found"
30+
}
31+
}
32+
if(!(Get-Command -Name 'node' -ErrorAction SilentlyContinue))
33+
{
34+
<#
35+
On Windows, pre-requisites are missing
36+
For now we will skip, and write a warning. Work to resolve this is tracked in:
37+
https://github.com/PowerShell/PowerShell/issues/3429
38+
#>
39+
Write-Warning "Node and yarn are required to run this test"
40+
$skip = $true
41+
}
42+
43+
$mdIssuesPath = Join-Path -Path $PSScriptRoot -ChildPath "markdownissues.txt"
44+
Remove-Item -Path $mdIssuesPath -Force -ErrorAction SilentlyContinue
45+
}
46+
47+
AfterAll {
48+
Pop-Location
49+
}
50+
51+
It "Should not have errors in any markdown files" -Skip:$skip {
52+
$NpmInstalled | Should -BeExactly "Installed"
53+
$mdErrors = 0
54+
Push-Location -Path $PSScriptRoot
55+
try
56+
{
57+
$docsToTest = @(
58+
'./.github/*.md'
59+
'./README.md'
60+
'./demos/python/*.md'
61+
'./docker/*.md'
62+
'./docs/building/*.md'
63+
'./docs/community/*.md'
64+
'./docs/host-powershell/*.md'
65+
'./docs/cmdlet-example/*.md'
66+
'./docs/maintainers/*.md'
67+
'./test/powershell/README.md'
68+
'./tools/*.md'
69+
'./.github/ISSUE_TEMPLATE/*.md'
70+
)
71+
$filter = ($docsToTest -join ',')
72+
73+
# Gulp 4 beta is returning non-zero exit code even when there is not an error
74+
Start-NativeExecution {
75+
&"gulp" test-mdsyntax --silent `
76+
--rootpath $repoRootPath `
77+
--filter $filter
78+
} -VerboseOutputOnError -IgnoreExitcode
79+
80+
}
81+
finally
82+
{
83+
Pop-Location
84+
}
85+
86+
$mdIssuesPath | Should -Exist
87+
88+
[string[]] $markdownErrors = Get-Content -Path $mdIssuesPath
89+
Remove-Item -Path $mdIssuesPath -Force -ErrorAction SilentlyContinue
90+
91+
if ($markdownErrors -ne "--EMPTY--")
92+
{
93+
$markdownErrors += ' (See https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md for an explanation of the error codes)'
94+
}
95+
96+
$markdownErrors | Write-Host
97+
98+
$markdownErrors -join "`n" | Should -BeExactly "--EMPTY--"
99+
}
100+
}

0 commit comments

Comments
 (0)