diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d4625b..b23ccfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Test Defaults - uses: kehoecj/validate-configs-action@v1 + uses: kehoecj/validate-configs-action@support_v1_6_0 with: exclude-dirs: failing search-paths: test/good.ini test/good.json test/good.toml test/good.xml test/good.yaml diff --git a/Dockerfile b/Dockerfile index 2278d93..2369af7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM alpine:3.18 +FROM alpine:3.20 COPY entrypoint.sh /entrypoint.sh RUN apk --no-cache add curl tar && \ - curl https://github.com/Boeing/config-file-validator/releases/download/v1.5.0/validator-v1.5.0-linux-386.tar.gz \ - -o /tmp/validator-v1.5.0-linux-386.tar.gz -s -L && \ - tar -xvf /tmp/validator-v1.5.0-linux-386.tar.gz -C /tmp && \ + curl https://github.com/Boeing/config-file-validator/releases/download/v1.6.0/validator-v1.6.0-linux-386.tar.gz \ + -o /tmp/validator-v1.6.0-linux-386.tar.gz -s -L && \ + tar -xvf /tmp/validator-v1.6.0-linux-386.tar.gz -C /tmp && \ mv /tmp/validator /usr/local/bin && \ rm -rf /tmp/* && \ chmod 0755 /usr/local/bin/validator && \ chmod 0755 /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index d64330a..003e5df 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ * Apple PList XML * CSV +* ENV * HCL +* HOCON * INI * JSON * Properties @@ -13,6 +15,7 @@ * YAML + Each file will get validated for the correct syntax and the results collected into a report showing the path of the file and if it is invalid or valid. If the file is invalid an error will be displayed along with the line number and column where the error ocurred. By default the `$GITHUB_WORKDIR` is scanned. ![Standard Run](./img/standard_run.png) @@ -21,11 +24,12 @@ Each file will get validated for the correct syntax and the results collected in | Input | Required | Default Value | Description | | ------------------ | -------- | ------------- | ----------- | -| search-paths | false | `"."` | The path that will be recursively searched for configuration files | +| search-paths | false | `"."` | The path that will be recursively searched for configuration files | | exclude-dirs | false | `""` | A comma-separated list of subdirectories to exclude from validation | | exclude-file-types | false | `""` | A comma-separated list of file extensions to exclude. Possible values are `xml`, `ini`, `yaml`, `yml`, `toml`, and `json` | | depth | false | `""` | An integer value limiting the depth of recursion for the search paths. For example, setting depth to 0 would disable recursion | -| reporter | false | `"standard"` | Format of the report printed to stdout. Options are `standard` and `json` | +| reporter | false | `"standard"` | Format of the report printed to stdout. Options are `standard` and `json` | +| group-by | false | `""` | Group output by filetype, directory, pass-fail | ## Outputs @@ -41,7 +45,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 ``` ### Custom search path @@ -51,7 +55,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 with: search-path: ./project/configs ``` @@ -63,7 +67,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 with: search-path: ./project/configs ./project/devops ``` @@ -75,7 +79,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 with: exclude-dirs: "tests,vendor" ``` @@ -87,7 +91,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 with: exclude-file-types: "json,xml" ``` @@ -99,7 +103,7 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 with: depth: 0 ``` @@ -111,7 +115,20 @@ jobs: validate-config-files: runs-on: ubuntu-latest steps: - - uses: kehoe/validate-configs-action@v1 + - uses: kehoe/validate-configs-action@v3 + with: + reporter: "json" +``` + +### Group By Pass/Fail + +```yml +jobs: + validate-config-files: + runs-on: ubuntu-latest + steps: + - uses: kehoe/validate-configs-action@v3 with: reporter: "json" ``` + diff --git a/action.yaml b/action.yaml index fe99d77..c60a420 100644 --- a/action.yaml +++ b/action.yaml @@ -24,6 +24,10 @@ inputs: description: 'Format of the printed report. Options are standard and json (default "standard")' required: false default: "standard" + group-by: + description: A comman separated list of how to group the output. Options are file type, directory, or pass-fail. + required: false + default: "" runs: using: 'docker' @@ -34,6 +38,7 @@ runs: - ${{ inputs.exclude-file-types }} - ${{ inputs.depth }} - ${{ inputs.reporter }} + - ${{ inputs.group-by }} branding: color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index 6a045fd..e81678b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,35 @@ set -e SEARCH_PATHS=$1 -validator --exclude-dirs=$2 --exclude-file-types=$3 --depth=$4 --reporter=$5 ${SEARCH_PATHS} \ No newline at end of file +EXCLUDE_DIRS=$2 +EXCLUDE_FILE_TYPES=$3 +DEPTH=$4 +REPORTER=$5 +GROUP_BY=$6 + +CMD=validator + +if [ -n "$EXCLUDE_DIRS" ]; then + CMD="$CMD --exclude-dirs=$EXCLUDE_DIRS" +fi + +if [ -n "$EXCLUDE_FILE_TYPES" ]; then + CMD="$CMD --exclude-file-types=$EXCLUDE_FILE_TYPES" +fi + +if [ -n "$DEPTH" ]; then + CMD="$CMD --depth=$DEPTH" +fi + +if [ -n "$REPORTER" ]; then + CMD="$CMD --reporter=$REPORTER" +fi + +if [ -n "$GROUP_BY" ]; then + CMD="$CMD --group-by=$GROUP_BY" +fi + +# add search paths +CMD="$CMD $SEARCH_PATHS" + +( ${CMD} )