Git Product home page Git Product logo

lint-filenames's Introduction

Lint Filenames action

build-test action status code-ql action status Codacy Security Scan license MIT

Lint Filenames is an simple github action to help you ensure certain patterns are followed in a given folder in your repository.

Sample Report

Inputs

path

Required The path to a directory to check the filenames.

pattern

Required The escaped regex pattern to match for each of the files in the given directory.

  • NOTE: the pattern needs to have all backslashes (\) escaped, i.e. for each \ you need to replace with \\.
  • Example: /^\d+\.jpg$/ should be /^\\d+\\.jpg$/.

For more examples, see ./__tests__/validate-filenames.test.ts.

Outputs

total-files-analyzed

The number of files analyzed.

Example usage

to ensure all files match the pattern /^.+\..+$/ in the my-files directory, use the following:

uses: batista/lint-filenames@v1
name: Validating my-folder filenames
with:
  path: './my-folder'
  pattern: '^.+\\..+$'

Development

Install the dependencies

npm install

Build the typescript and package it for distribution

npm run build && npm run package

Run the tests ✔️

npm test

 PASS  __tests__/validate-filenames.test.ts
  Name of the group
    ✓ 01 - Passes for any character files (10 ms)
    ✓ 02 - Passes for `name.ext` files (1 ms)
    ✓ 03 - Passes for `.dotfiles` (1 ms)
    ✓ 04 - Passes for no `.dotfiles`
    ✓ 05 - Passes for files with `a` in the name (1 ms)
    ✓ 06 - Passes for json files `*.json` (1 ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        0.559 s, estimated 2 s
Ran all test suites.

Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run ncc and push the results:

$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

Your action is now published! 🚀

See the versioning documentation

Validate

You can now validate the action by referencing ./ in a workflow in your repo (see test.yml)

uses: ./
with:
  path: './__tests__/test-files/06-json-files'
  pattern: "\\.json$"

See the actions tab for runs of this action! 🚀

Usage

After testing you can create a v1 tag to reference the stable and latest V1 action

lint-filenames's People

Contributors

batista avatar dependabot[bot] avatar martinm82 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lint-filenames's Issues

Split README.md and CONTRIBUTING.md

For readability sake, the readme should be targeted only to the consumer of this extension.

We should extract a contributing file with guidelines for those that want to contribute and/or fork.

Include sub folders

Nice Action, more or less what I was looking for.

Interested to hear why you had intentionally opted to not include any files in sub-folders or, alternatively, give the user an option to mach files by glob pattern or something similar ?

Unspecified error when running this action

I'm trying to use this action to validate the filenames in a folder against a regex. The run fails after 2 seconds with no clear error message.

Output of the action:

 ##[debug]Evaluating condition for step: 'Validate migration filenames'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Validate migration filenames
##[debug]Loading inputs
##[debug]Loading env
Run batista/lint-filenames@v1
  with:
    path: ./db-migrations/flyway/migrations
    pattern: ^[V|U|R]\d*?__[A-Za-z0-9_]*\\.sql$
====================
|  Lint Filenames  |
====================
ℹ️  Path:    		'./db-migrations/flyway/migrations'
ℹ️  Pattern: 		/^[V|U|R]\d*?__[A-Za-z0-9_]*\\.sql$/
Error: Error: Execution failed, see log above. ❌
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Validate migration filenames

Can you see what I'm doing wrong @batista ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.