lint-filenames icon indicating copy to clipboard operation
lint-filenames copied to clipboard

Unspecified error when running this action

Open DonDebonair opened this issue 1 year ago • 2 comments

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 ?

DonDebonair avatar Apr 07 '23 10:04 DonDebonair

Same here, did you find a solution @DonDebonair or is the repo abandoned?

image

Isengo1989 avatar Nov 22 '23 08:11 Isengo1989

I ended up creating a bash script to check filenames and run that as an action.

Script:

#!/usr/bin/env bash

badname=""

for f in "$@"
do
  file=$(basename $f)
  if [[ ! "$file" =~ ^([V|U|R]|afterMigrate)[0-9]*__[A-Za-z0-9_]*\.sql$ ]]; then
    echo "File $file does not match"
    badname=$file
  fi
done

if [[ ! -z "$badname" ]]; then
  exit 1
fi

Workflow:


jobs:
  lint-migrations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Validate migration filenames
        shell: bash
        run: db-migrations/flyway/scripts/check-migration-filenames.sh db-migrations/flyway/migrations/*

Change regex in bash script to whatever filename format you want to check against. Change directory and script location in workflow to your setup

DonDebonair avatar Nov 22 '23 08:11 DonDebonair