Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use glob pattern matching for the files input #46

Merged
merged 8 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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