forked from loafle/openapi-generator-original
Add a script to detect changes in test files (#8020)
* add script to detect changes in test files * remove build failure test
This commit is contained in:
parent
bcf4f8ade6
commit
64c57e3f52
@ -140,6 +140,8 @@ install:
|
|||||||
script:
|
script:
|
||||||
# fail fast
|
# fail fast
|
||||||
- set -e
|
- set -e
|
||||||
|
# fail if the test files have changes
|
||||||
|
- bin/utils/detect_test_file_changes.rb bin/utils/test_file_list.yaml
|
||||||
# fail if templates/generators contain carriage return '\r'
|
# fail if templates/generators contain carriage return '\r'
|
||||||
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
- /bin/bash ./bin/utils/detect_carriage_return.sh
|
||||||
# fail if generators contain merge conflicts
|
# fail if generators contain merge conflicts
|
||||||
|
57
bin/utils/detect_test_file_changes.rb
Executable file
57
bin/utils/detect_test_file_changes.rb
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# ruby script to detect changes in test-related files
|
||||||
|
require 'yaml'
|
||||||
|
require 'digest'
|
||||||
|
|
||||||
|
hash = Digest::SHA256.hexdigest("xyz")
|
||||||
|
|
||||||
|
filename= ARGV[0]
|
||||||
|
|
||||||
|
if !filename
|
||||||
|
puts "Usage: #{$0} filename"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if !File.file? filename
|
||||||
|
warn "Error. #{filename} doesn't exist."
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
mismatch = 0
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
test_files = YAML.load_file(filename)
|
||||||
|
test_files.each do |test_file|
|
||||||
|
count = count + 1
|
||||||
|
# file still exists?
|
||||||
|
if !File.file? test_file['filename']
|
||||||
|
warn "Error. Provided test file `#{test_file['filename']}` doesn't exist."
|
||||||
|
mismatch = mismatch + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# check sha256 hash
|
||||||
|
sha256 = Digest::SHA256.hexdigest(File.read(test_file['filename']))
|
||||||
|
if test_file['sha256'] != sha256
|
||||||
|
warn "Looks like #{test_file['filename']} has been modified as its SHA256 `#{sha256}` is not the same as the one in the record: #{test_file['sha256']}"
|
||||||
|
mismatch = mismatch + 1
|
||||||
|
else
|
||||||
|
# no change to the test file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if mismatch > 0
|
||||||
|
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
warn "There are #{mismatch} mismatch. Please review the test files to ensure it has not been deleted/regenerated."
|
||||||
|
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
puts "OK. All matched!"
|
||||||
|
end
|
||||||
|
|
||||||
|
if count == 0
|
||||||
|
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
warn "Looks like the test file list in #{filename} is empty! Please check!"
|
||||||
|
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
6
bin/utils/test_file_list.yaml
Normal file
6
bin/utils/test_file_list.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# csharp-netcore test files and image for upload
|
||||||
|
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
|
||||||
|
sha256: b74ef9eefa4b41fd3233e083fe2355babf25a77f9073d28e1aa81ae2e0a5f1d0
|
||||||
|
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
|
||||||
|
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
|
Loading…
x
Reference in New Issue
Block a user