From 84b017f5cf6b46937acbbe13e131a4cca2f26784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Sun, 12 Sep 2021 17:41:59 +0200 Subject: [PATCH] Add CI limit on Windows + start improving CLI --- .github/workflows/main.yml | 2 + .github/workflows/pull-request.yml | 2 + README.md | 85 +++++++++++------------------- Sources/Commands/InitCommand.swift | 4 -- Sources/Commands/LintCommand.swift | 2 +- 5 files changed, 37 insertions(+), 58 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f451e4..a691807 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,8 @@ jobs: test-windows: runs-on: windows-latest + timeout-minutes: 15 + strategy: matrix: include: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index be4f47f..7de1829 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -48,6 +48,8 @@ jobs: test-windows: runs-on: windows-latest + timeout-minutes: 15 + strategy: matrix: include: diff --git a/README.md b/README.md index ebc1402..e234a31 100644 --- a/README.md +++ b/README.md @@ -76,63 +76,42 @@ mint install Flinesoft/AnyLint To initialize AnyLint in a project, run: ```bash -anylint --init blank +anylint init ``` This will create the Swift script file `anylint.yml` with something like the following contents: ```yaml -CheckFileContents: - - 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$'] - 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' } - -CheckFilePaths: - - 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' } +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'] + +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' } + +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 + ``` Having this configuration file, you can now run `anylint` to run your lint checks. By default, if any check fails, the entire command fails and reports the violation reason. To learn more about how to configure your own checks, see the [Configuration](#configuration) section below. @@ -141,7 +120,7 @@ If you want to create and run multiple configuration files or if you want a diff Initializes the configuration files at the given locations: ```bash -anylint --init blank --path Sources/anylint.yml --path Tests/anylint.yml +anylint --init template=OpenSource --path Sources/anylint.yml --path Tests/anylint.yml ``` Runs the lint checks for both configuration files: diff --git a/Sources/Commands/InitCommand.swift b/Sources/Commands/InitCommand.swift index a64a0a7..5c2ce09 100644 --- a/Sources/Commands/InitCommand.swift +++ b/Sources/Commands/InitCommand.swift @@ -46,11 +46,7 @@ struct InitCommand: ParsableCommand { attributes: nil ) - log.message("Making config file executable ...", level: .info) - try shellOut(to: "chmod", arguments: ["+x", path]) - log.message("Successfully created config file at \(path)", level: .success) - } } diff --git a/Sources/Commands/LintCommand.swift b/Sources/Commands/LintCommand.swift index 81bad83..0dd01a2 100644 --- a/Sources/Commands/LintCommand.swift +++ b/Sources/Commands/LintCommand.swift @@ -54,7 +54,7 @@ struct LintCommand: ParsableCommand { guard FileManager.default.fileExists(atPath: config) else { log.message( - "No configuration file found at \(config) – consider running `anylint --init` with a template.", + "No configuration file found at \(config) – consider running `anylint init` with a template.", level: .error ) log.exit(fail: true)