-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check-readme-newlines executable * Working simple script * Setup GH action (#2) * add shellcheck and cleanup test * CODEOWNERS LICENSE README --------- Co-authored-by: Chris Reynolds <chris@jazzsequence.com>
- Loading branch information
Showing
11 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Validate Test README | ||
on: | ||
push: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: lint & test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./ | ||
with: | ||
filepath: ${{ github.workspace }}/fixtures/good.md | ||
- name: Shellcheck Lint | ||
run: make lint | ||
- name: Test "Bad" cases are rejected | ||
run: make test | ||
|
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @pantheon-systems/cms-platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2023 Pantheon Systems | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
lint: | ||
shellcheck ./check-readme-newlines.sh | ||
|
||
test: | ||
./test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Validate Readme Spacing | ||
[![Testing](https://github.com/pantheon-systems/validate-readme-spacing/actions/workflows/test.yml/badge.svg)](https://github.com/pantheon-systems/validate-readme-spacing/actions/workflows/test.yml) [![MIT License](https://img.shields.io/github/license/pantheon-systems/validate-readme-spacing)](https://github.com/pantheon-systems/validate-readme-spacing/blob/main/LICENSE) | ||
|
||
A GitHub Action that validates the heading section of your plugin's README.MD has newlines handled correctly. | ||
|
||
When writing markdown, two spaces are required at the end of a line to preserve single line breaks in the rendered view. Some people's (@jazzsequence) IDEs helpfully remove these and the diff can be missed in GitHub's PR view. | ||
|
||
## Input | ||
### `filepath` | ||
The path to the project's README file. Defaults to `README.md`. | ||
|
||
## Example Usage | ||
|
||
``` yaml | ||
uses: pantheon-systems/validate-readme-spacing@v1 | ||
with: | ||
filepath: 'README.md' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: WordPress Plugin README.md Validator | ||
description: Checks a README.md file that uses the standard WordPress readme.txt plugin header format for valid markdown. | ||
author: pantheon-systems | ||
branding: | ||
icon: file-text | ||
color: yellow | ||
inputs: | ||
filepath: | ||
description: Relative path to README.md file. Defaults to the root directory of the project. | ||
required: false | ||
default: ${{ github.workspace }}/README.md | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Validate Readme | ||
shell: bash | ||
run: | | ||
echo "Validating ${{ inputs.filepath }}..." | ||
bash check-readme-newlines.sh ${{ inputs.filepath }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
set -eou pipefail | ||
|
||
file="${1-:}" | ||
|
||
if [[ ! -f "${file}" ]]; then | ||
echo "File ${file} not found" | ||
exit 1 | ||
fi | ||
|
||
# https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information | ||
README_HEADER_SECTIONS=("Contributors" "Donate link" "Tags" "Requires at least" \ | ||
"Tested up to" "Stable tag" "Requires PHP" "License" "License URI") | ||
|
||
HEADER_ALRADY_READ=0 | ||
INVALID_LINE_FOUND=0 | ||
|
||
# Read the README line by line | ||
while IFS= read -r line; do | ||
# The very first header is skipped, any future headers (#) inform us we are past | ||
# the header section and should continue. | ||
if [[ "${line}" == "#"* ]]; then | ||
if [[ "${HEADER_ALRADY_READ}" -eq 1 ]]; then | ||
break | ||
fi | ||
HEADER_ALRADY_READ=1 | ||
continue | ||
fi | ||
|
||
# Check if the line is empty | ||
if [[ "${line}" == "" ]]; then | ||
continue | ||
fi | ||
|
||
# Skip if the line does not contain a colon | ||
if [[ "${line}" != *":"* ]]; then | ||
continue | ||
fi | ||
|
||
# Check if the line matches any of the strings (case-insensitive) | ||
IS_README_HEADER_LINE=0 | ||
for section in "${README_HEADER_SECTIONS[@]}"; do | ||
if [[ "${line}" =~ $section ]]; then | ||
IS_README_HEADER_LINE=1 | ||
break | ||
fi | ||
done | ||
if [[ "${IS_README_HEADER_LINE}" -ne 1 ]];then | ||
continue | ||
fi | ||
|
||
# Check if the line ends with two spaces | ||
if [[ "${line}" =~ .*[[:space:]]{2}$ ]]; then | ||
continue | ||
fi | ||
|
||
echo "This line is missing trailing spaces: ${line}" | ||
INVALID_LINE_FOUND=1 | ||
done < "$file" | ||
|
||
if [[ ${INVALID_LINE_FOUND} -eq 1 ]];then | ||
echo "⛔️ Invalid" | ||
exit 1 | ||
fi | ||
|
||
echo "🎊 Valid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Rossums Universal Robots | ||
Contributors: [pwtyler](https://profiles.wordpress.org/pwtyler) | ||
Donate link: https://example.com/ | ||
Tags: comments, spam | ||
Requires at least: 4.5 | ||
Tested up to: 6.2.1 | ||
Requires PHP: 5.6 | ||
Stable tag: 0.0.1 | ||
License: GPLv2 or later | ||
Is Super Awesome: Me | ||
License URI: https://www.gnu.org/licenses/gpl-2.0.html | ||
See the robots hard at work. | ||
|
||
## Usage | ||
Install the plugin and use it. | ||
|
||
## Changelog | ||
|
||
### 0.1.0 (6 June 2023) | ||
* Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Rossums Universal Robots | ||
Contributors: [pwtyler](https://profiles.wordpress.org/pwtyler) | ||
Donate link: https://example.com/ | ||
Tags: comments, spam | ||
Requires at least: 4.5 | ||
Tested up to: 6.2.1 | ||
Requires PHP: 5.6 | ||
Stable tag: 0.0.1 | ||
License: GPLv2 or later | ||
License URI: https://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
See the robots hard at work: they are good at it. | ||
|
||
## Usage | ||
Install the plugin and use it. | ||
Foo: Bar | ||
|
||
## Changelog | ||
|
||
### 0.1.0 (6 June 2023) | ||
* Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Rossums Universal Robots | ||
Contributors: [pwtyler](https://profiles.wordpress.org/pwtyler) | ||
Donate link: https://example.com/ | ||
Tags: comments, spam | ||
Requires at least: 4.5 | ||
Tested up to: 6.2.1 | ||
Requires PHP: 5.6 | ||
Stable tag: 0.0.1 | ||
License: GPLv2 or later | ||
License URI: https://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
See the robots hard at work: they are good at it. | ||
|
||
## Usage | ||
Install the plugin and use it. | ||
* Step One: Install it. | ||
* Step Two: Profit | ||
## Changelog | ||
|
||
### 0.1.0 (6 June 2023) | ||
* Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -eou pipefail | ||
|
||
echo "Validate all fields are bad" | ||
echo "Running checks on fixtures/bad-all.md..." | ||
if ! bash check-readme-newlines.sh fixtures/bad-all.md; then | ||
echo "✅ Validated bad README successfully!" | ||
else | ||
echo "🚫 Invalidated bad README unsuccessfully. Did the bad-all.md file change? 😉" | ||
exit 1 | ||
fi | ||
|
||
echo "Validate single line is bad" | ||
echo "Running checks on fixtures/bad-single.md..." | ||
if ! bash check-readme-newlines.sh fixtures/bad-single.md; then | ||
echo "✅ Validated bad README successfully!" | ||
else | ||
echo "🚫 Invalidated bad README unsuccessfully. Did the bad-single.md file change? 😉" | ||
exit 1 | ||
fi |