Skip to content

Commit

Permalink
Fix issues with templates & simplify Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Sep 12, 2021
1 parent d343473 commit 584f603
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 99 deletions.
33 changes: 4 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,15 @@ jobs:
- name: Run tests
run: swift test -v --enable-code-coverage

# originally from: https://github.com/compnerd/swift-build/blob/master/.github/workflows/swift-argument-parser.yml
test-windows:
runs-on: windows-latest

timeout-minutes: 15

strategy:
matrix:
include:
- tag: 5.4.3-RELEASE
branch: swift-5.4.3-release

steps:
- uses: actions/checkout@v2

- name: Install Swift ${{ matrix.tag }}
run: |
function Update-EnvironmentVariables {
foreach ($level in "Machine", "User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if ($_.Name -Match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -Split ';' | Select -Unique) -Join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
}
Install-Binary -Url "https://swift.org/builds/${{ matrix.branch }}/windows10/swift-${{ matrix.tag }}/swift-${{ matrix.tag }}-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
Update-EnvironmentVariables
# Reset Path and environment
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
Get-ChildItem Env: | % { echo "$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append }
- name: Run tests
run: swift test -v
- name: Install Swift & Run tests
uses: MaxDesiatov/swift-windows-action@v1
with:
shell-action: swift test -v
33 changes: 4 additions & 29 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,15 @@ jobs:
- name: Run tests
run: swift test -v --enable-code-coverage

# originally from: https://github.com/compnerd/swift-build/blob/master/.github/workflows/swift-argument-parser.yml
test-windows:
runs-on: windows-latest

timeout-minutes: 15

strategy:
matrix:
include:
- tag: 5.5-DEVELOPMENT-SNAPSHOT-2021-08-30-a
branch: swift-5.5-branch

steps:
- uses: actions/checkout@v2

- name: Install Swift ${{ matrix.tag }}
run: |
function Update-EnvironmentVariables {
foreach ($level in "Machine", "User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if ($_.Name -Match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -Split ';' | Select -Unique) -Join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
}
Install-Binary -Url "https://swift.org/builds/${{ matrix.branch }}/windows10/swift-${{ matrix.tag }}/swift-${{ matrix.tag }}-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
Update-EnvironmentVariables
# Reset Path and environment
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
Get-ChildItem Env: | % { echo "$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append }
- name: Run tests
run: swift test -v
- name: Install Swift & Run tests
uses: MaxDesiatov/swift-windows-action@v1
with:
shell-action: swift test -v
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Here are some **advanced Regex features** you might want to use or learn more ab
For example, consider a regex violating if there's an empty line after an opening curly brace like so: `{\n\s*\n\s*\S`. This would match the lines of `func do() {\n\n return 5}`, but what you actually want is it to start matching on the empty newline like so: `(?<={\n)\s*\n\s*\S`.

See also [#3](https://github.com/Flinesoft/AnyLint/issues/3)

## YAML Cheat Sheet

Please be aware that in YAML indentation (whitespaces) and newlines are actually important.
Expand All @@ -492,6 +492,8 @@ string2: 'This is with single quotes.'
string3: "This is with double quotes."
```
Note that only in double-quoted strings you can escape characters, e.g. `'Line1\nLine2'` will keep the `\n` as two characters in the result, whereas `"Line1\nLine2"` will escape `\n` to a newline. We recommend to use single quotes for `regex` arguments (the escaping will happen in the Regex parser) and double-quotes for any examples where you need escaping to be evaluated.

**Multi-line strings** can be written by specifying `|` and then a newline:
```yaml
multiline1: |
Expand All @@ -504,13 +506,13 @@ An additional `+` or `-` specified what to do with trailing newlines:
```yaml
multiline2: |+
This will make sure both trailing newlines are kept (ends with ".\n\n").
multiline3: |-
This will ignore any trailing newlines and
This will ignore any trailing newlines and
will end with the last non-newline character (the following dot in this case -->).
```

**Arrays** can be written in two ways:
Expand Down
83 changes: 59 additions & 24 deletions Sources/Configuration/Templates/Blank.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
FileContents: []
# - id: Readme
# hint: 'Each project should have a README.md file, explaining how to use or contribute to the project.'
# regex: '^README\.md$'
# violateIfNoMatchesFound: true
# matchingExamples: ['README.md']
# nonMatchingExamples: ['README.markdown', 'Readme.md', 'ReadMe.md']
# TODO: replace below sample checks with your custom checks and remove empty array specifier `[]` from above
# - id: ReadmeTopLevelTitle
# hint: 'The README.md file should only contain a single top level title.'
# regex: '(^|\n)#[^#](.*\n)*\n#[^#]'
# includeFilters: ['^README\.md$']
# matchingExamples:
# - |
# # Title
# ## Subtitle
# Lorem ipsum
#
# # Other Title
# ## Other Subtitle
# nonMatchingExamples:
# - |
# # Title
# ## Subtitle
# Lorem ipsum #1 and # 2.
#
# ## Other Subtitle
# ### Other Subsubtitle
#
# - id: ReadmeTypoLicense
# hint: 'ReadmeTypoLicense: Misspelled word `license`.'
# regex: '([\s#]L|l)isence([\s\.,:;])'
# matchingExamples: [' lisence:', "## Lisence\n"]
# nonMatchingExamples: [' license:', "## License\n"]
# includeFilters: ['^README\.md$']
# autoCorrectReplacement: '$1icense$2'
# autoCorrectExamples:
# - { before: ' lisence:', after: ' license:' }
# - { before: "## Lisence\n", after: "## License\n" }

FilePaths: []
# - id: 'ReadmePath'
# hint: 'The README file should be named exactly `README.md`.'
# regex: '^(.*/)?([Rr][Ee][Aa][Dd][Mm][Ee]\.markdown|readme\.md|Readme\.md|ReadMe\.md)$'
# matchingExamples: ['README.markdown', 'readme.md', 'ReadMe.md']
# nonMatchingExamples: ['README.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'api/help.md']
# autoCorrectReplacement: '$1README.md'
# autoCorrectExamples:
# - { before: 'api/readme.md', after: 'api/README.md' }
# - { before: 'ReadMe.md', after: 'README.md' }
# - { before: 'README.markdown', after: 'README.md' }
# TODO: replace below sample checks with your custom checks and remove empty array specifier `[]` from above
# - id: Readme
# hint: 'Each project should have a README.md file, explaining how to use or contribute to the project.'
# regex: '^README\.md$'
# violateIfNoMatchesFound: true
# matchingExamples: ['README.md']
# nonMatchingExamples: ['README.markdown', 'Readme.md', 'ReadMe.md']
#
# - id: ReadmePath
# hint: 'The README file should be named exactly `README.md`.'
# regex: '^(.*/)?([Rr][Ee][Aa][Dd][Mm][Ee]\.markdown|readme\.md|Readme\.md|ReadMe\.md)$'
# matchingExamples: ['README.markdown', 'readme.md', 'ReadMe.md']
# nonMatchingExamples: ['README.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'api/help.md']
# autoCorrectReplacement: '$1README.md'
# autoCorrectExamples:
# - { before: 'api/readme.md', after: 'api/README.md' }
# - { before: 'ReadMe.md', after: 'README.md' }
# - { before: 'README.markdown', after: 'README.md' }

CustomScripts: []
# - id: LintConfig
# hint: 'Lint the AnyLint config file to conform to YAML best practices.'
# command: |-
# if which yamllint > /dev/null; then
# yamllint anylint.yml
# else
# echo '{ "warning": { "YamlLint: Not installed, see instructions at https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint": [{}] } }'
# fi
# TODO: replace below sample check with your custom checks and remove empty array specifier `[]` from above
# - id: LintConfig
# hint: 'Lint the AnyLint config file to conform to YAML best practices.'
# command: |-
# if which yamllint > /dev/null; then
# yamllint anylint.yml
# else
# echo '{ "warning": { "YamlLint: Not installed, see instructions at https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint": [{}] } }'
# fi
22 changes: 11 additions & 11 deletions Sources/Configuration/Templates/OpenSource.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
FileContents:
- id: Readme
hint: 'Each project should have a README.md file, explaining how to use or contribute to the project.'
regex: '^README\.md$'
violateIfNoMatchesFound: true
matchingExamples: ['README.md']
nonMatchingExamples: ['README.markdown', 'Readme.md', 'ReadMe.md']

- id: ReadmeTopLevelTitle
hint: 'The README.md file should only contain a single top level title.'
regex: '(^|\n)#[^#](.*\n)*\n#[^#]'
includeFilter: ['^README\.md$']
includeFilters: ['^README\.md$']
matchingExamples:
- |
# Title
Expand All @@ -30,15 +23,22 @@ FileContents:
- id: ReadmeTypoLicense
hint: 'ReadmeTypoLicense: Misspelled word `license`.'
regex: '([\s#]L|l)isence([\s\.,:;])'
matchingExamples: [' lisence:', '## Lisence\n']
nonMatchingExamples: [' license:', '## License\n']
matchingExamples: [' lisence:', "## Lisence\n"]
nonMatchingExamples: [' license:', "## License\n"]
includeFilters: ['^README\.md$']
autoCorrectReplacement: '$1icense$2'
autoCorrectExamples:
- { before: ' lisence:', after: ' license:' }
- { before: '## Lisence\n', after: '## License\n' }
- { before: "## Lisence\n", after: "## License\n" }

FilePaths:
- id: Readme
hint: 'Each project should have a README.md file, explaining how to use or contribute to the project.'
regex: '^README\.md$'
violateIfNoMatchesFound: true
matchingExamples: ['README.md']
nonMatchingExamples: ['README.markdown', 'Readme.md', 'ReadMe.md']

- id: ReadmePath
hint: 'The README file should be named exactly `README.md`.'
regex: '^(.*/)?([Rr][Ee][Aa][Dd][Mm][Ee]\.markdown|readme\.md|Readme\.md|ReadMe\.md)$'
Expand Down

0 comments on commit 584f603

Please sign in to comment.