diff --git a/README.md b/README.md index c8d614a..fcc67ed 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} ``` -You can provide optional arguments to specify paths, exclude paths, +You can provide optional arguments to specify paths, exclude paths, extensions of tested files, a config file, Verible version and extra arguments for ``verible-verilog-lint``. ```yaml @@ -49,6 +49,11 @@ a config file, Verible version and extra arguments for ``verible-verilog-lint``. ./rtl/some_file extra_args: "--check_syntax=true" verible_version: "v0.0-3100-gd75b1c47" + extensions: | + .sv + .v + .vh + .svh github_token: ${{ secrets.GITHUB_TOKEN }} ``` diff --git a/action.py b/action.py index 9dde1e1..4515c4e 100755 --- a/action.py +++ b/action.py @@ -48,14 +48,14 @@ def unwrap_from_gha_string(args): return elements -def find_sources_in_paths(paths): - '''Scan {paths} for Verilog and SystemVerilog files +def find_sources_in_paths(paths, exts): + '''Scan {paths} for files with extensions from set ''' files = set() for filename in paths: # check if filename is a directory or a source file if os.path.isdir(filename): - new_files = recursive_find({".v", ".sv"}, filename) + new_files = recursive_find(exts, filename) files.update(new_files) elif os.path.isfile(filename): files.add(filename) @@ -72,12 +72,14 @@ def find_sources_in_paths(paths): help='extra options for the linter') @click.option('--exclude-paths', '-x', required=False, help='exclude these paths from the files to lint') +@click.option('--extensions', '-t', type=str, required=False, + help='lint files with these extensions (starting with a dot, split by comma)') @click.option('--log-file', '-l', type=str, required=False, help='log file name') @click.option('--patch', '-p', type=str, required=False, help='patch file name') @click.argument('path', nargs=-1, required=True) -def main(conf_file, extra_opts, exclude_paths, log_file, patch, path): +def main(conf_file, extra_opts, exclude_paths, extensions, log_file, patch, path): ''' Lint .v and .sv files specified in PATHs ''' @@ -96,9 +98,14 @@ def main(conf_file, extra_opts, exclude_paths, log_file, patch, path): else: patch = [] + if extensions: + extensions = set(ext if ext.startswith('.') else '.' + ext for ext in extensions.split()) + else: + extensions = {'.v', '.sv'} + paths = unwrap_from_gha_string(path) # set of target files to lint - files = find_sources_in_paths(paths) + files = find_sources_in_paths(paths, extensions) if exclude_paths: for p in exclude_paths.split(): diff --git a/action.yml b/action.yml index 1617401..4499b92 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,10 @@ inputs: exclude_paths: description: 'Exclude these paths after finding all target files' required: false + extensions: + description: 'Run linting on files ending with following extensions' + required: false + default: '' log_file: description: 'Name for a log file' required: false @@ -66,6 +70,7 @@ runs: INPUT_CONFIG_FILE: ${{ inputs.config_file }} INPUT_EXCLUDE_PATHS: ${{ inputs.exclude_paths }} INPUT_EXTRA_ARGS: ${{ inputs.extra_args }} + INPUT_EXTENSIONS: ${{ inputs.extensions }} INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} INPUT_LOG_FILE: ${{ inputs.log_file }} diff --git a/entrypoint.sh b/entrypoint.sh index 7fca4ea..e04fd3f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,6 +41,7 @@ if [ "$INPUT_SUGGEST_FIXES" = "true" ]; then --conf-file "$INPUT_CONFIG_FILE" \ --extra-opts "$INPUT_EXTRA_ARGS" \ --exclude-paths "$INPUT_EXCLUDE_PATHS" \ + --extensions "$INPUT_EXTENSIONS" \ --log-file "$INPUT_LOG_FILE" \ --patch "$patch" \ "$INPUT_PATHS" @@ -55,6 +56,7 @@ else --conf-file "$INPUT_CONFIG_FILE" \ --extra-opts "$INPUT_EXTRA_ARGS" \ --exclude-paths "$INPUT_EXCLUDE_PATHS" \ + --extensions "$INPUT_EXTENSIONS" \ --log-file "$INPUT_LOG_FILE" \ "$INPUT_PATHS"