Skip to content

Commit

Permalink
Merge pull request #46 from GrantBirki/files-glob-match
Browse files Browse the repository at this point in the history
use glob pattern matching for the `files` input
  • Loading branch information
GrantBirki authored Dec 29, 2023
2 parents 55e74d3 + 9b8ea63 commit 7c34098
Show file tree
Hide file tree
Showing 20 changed files with 8,776 additions and 244 deletions.
1 change: 1 addition & 0 deletions .github/config/exclude-alt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__tests__/fixtures/
14 changes: 13 additions & 1 deletion .github/workflows/acceptance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,20 @@ jobs:
- name: valid file creation
run: echo "{}" > valid.yaml

- uses: ./
- name: acceptance test
uses: ./
id: json-yaml-validate
with:
comment: "true"
exclude_file: .github/config/exclude.txt

- name: acceptance test - files input option (glob)
uses: ./
id: json-yaml-validate-glob-test
with:
comment: "true"
yaml_as_json: "false"
exclude_file: .github/config/exclude-alt.txt
files: |
__tests__/**/test1.yml
__tests__/**/test*.json
5 changes: 5 additions & 0 deletions __tests__/acceptance/dev/test2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"food": "apple",
"tasty": true,
"eaten": 1492
}
9 changes: 9 additions & 0 deletions __tests__/acceptance/prod/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
code:
app:
name: coolapp
cpu: 2
secured: true
gpus:
- gpu1
- gpu2
5 changes: 5 additions & 0 deletions __tests__/acceptance/prod/test1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"food": "lime",
"tasty": false,
"eaten": 1
}
9 changes: 9 additions & 0 deletions __tests__/acceptance/prod/test1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
person:
name:
first_name: monalisa
age: 2000
employeed: true
hobbies:
- tennis
- football
3 changes: 3 additions & 0 deletions __tests__/acceptance/staging/code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "ruby-latest"
}
9 changes: 9 additions & 0 deletions __tests__/acceptance/staging/test1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
person:
name:
first_name: lisamona
age: 5000
employeed: false
hobbies:
- golf
- skiing
4 changes: 4 additions & 0 deletions __tests__/fixtures/json/with_yaml/first/test1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo": 1,
"bar": "abc"
}
1 change: 1 addition & 0 deletions __tests__/fixtures/json/with_yaml/first/test1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
key: value
4 changes: 4 additions & 0 deletions __tests__/fixtures/json/with_yaml/second/test2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo": 1,
"bar": "abc"
}
1 change: 1 addition & 0 deletions __tests__/fixtures/json/with_yaml/second/test2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
key: value
18 changes: 18 additions & 0 deletions __tests__/functions/json-validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ test('successfully validates a yaml file with a schema when yaml_as_json is true
})
})

test('successfully validates a json file and skips over the yaml one in the json processor', async () => {
process.env.INPUT_YAML_AS_JSON = 'false'
process.env.INPUT_BASE_DIR = '.'
process.env.INPUT_JSON_SCHEMA = ''
process.env.INPUT_FILES = `
__tests__/fixtures/json/with_yaml/**/test1.yml,
__tests__/fixtures/json/with_yaml/**/test*.json
`

expect(await jsonValidator(excludeMock)).toStrictEqual({
failed: 0,
passed: 2,
skipped: 0,
success: true,
violations: []
})
})

test('processes multiple files when yaml_as_json is true and also a mixture of other json files with yaml are present', async () => {
process.env.INPUT_YAML_AS_JSON = 'true'
process.env.INPUT_JSON_SCHEMA = ''
Expand Down
Loading

0 comments on commit 7c34098

Please sign in to comment.