From 8c42f458db3676d0f65c2c2e4a1720dab7a7eed9 Mon Sep 17 00:00:00 2001 From: michhyun Date: Mon, 23 Nov 2020 16:09:23 -0800 Subject: [PATCH] Update changelog requirements --- .changelog-watchlist | 6 ++++ integration/js/script/run-test | 58 ++++++++++++++++++---------------- script/prebuild | 42 +++++++++++++++++++++--- 3 files changed, 75 insertions(+), 31 deletions(-) create mode 100644 .changelog-watchlist diff --git a/.changelog-watchlist b/.changelog-watchlist new file mode 100644 index 0000000000..1afb92d247 --- /dev/null +++ b/.changelog-watchlist @@ -0,0 +1,6 @@ +# Require changelog if files in these directories change +src/ +guides/ +libs/voicefocus + +# Exceptions (Add an exception by adding a path and prepend with a '!' ) \ No newline at end of file diff --git a/integration/js/script/run-test b/integration/js/script/run-test index ba7ef249e5..7a3336b861 100755 --- a/integration/js/script/run-test +++ b/integration/js/script/run-test @@ -50,36 +50,40 @@ echo 'Commits:' $commits requires_integration_test=false for commit in $commits do - commit_files=`git diff-tree --no-commit-id --name-only -r ${commit}` - echo 'Commited files are: ' $commit_files - matches=false - for committed_file in $commit_files - do - while read -r stem - do - if [[ $stem =~ ^#.* ]] - then - continue - elif [[ $stem = "" ]] - then - continue - elif [[ $stem =~ ^!.* ]] - then - stem_string="${stem:1}" - if [[ $committed_file = $stem_string* ]] - then - matches=false - fi - elif [[ $committed_file = $stem* ]] - then - requires_integration_test=true - fi - done < "../../.integration-watchlist" - done + commit_files=`git diff-tree --no-commit-id --name-only -r ${commit}` + echo 'Commited files are: ' $commit_files + matches=false + for committed_file in $commit_files + do + while read -r stem + do + if [[ $stem =~ ^#.* ]] + then + continue + elif [[ $stem = "" ]] + then + continue + elif [[ $stem =~ ^!.* ]] + then + stem_string="${stem:1}" + if [[ $committed_file = $stem_string* ]] + then + matches=false + fi + elif [[ $committed_file = $stem* ]] + then + matches=true + fi + done < "../../.integration-watchlist" + if [[ $matches ]] + then + requires_integration_test=true + fi + done done echo 'Requires integ tests:' $requires_integration_test -if [[ !$requires_integration_test ]] +if ![[ $requires_integration_test ]] then exit 0 fi diff --git a/script/prebuild b/script/prebuild index 9a6af18cee..25b8d18f4b 100755 --- a/script/prebuild +++ b/script/prebuild @@ -5,6 +5,34 @@ def verbose command puts("--> #{command}") || system(command) || fail("Failed: #{command}") end +def requires_changelog commits + for commit in commits + commit_files=`git diff-tree --no-commit-id --name-only -r #{commit}`.split("\n") + matches = false + for committed_file in commit_files + File.foreach(".changelog-watchlist") do |stem| + stem = stem.strip + if stem == '' + next + elsif stem.start_with?('!') + stem_string = stem[1..-1] + if committed_file.start_with?(stem_string) + matches = false + end + elsif committed_file.start_with?(stem) + puts 'There are changes within ' + stem + matches = true + end + end + if matches + return true + end + end + end + puts 'Does not contain any changes in the changelog watchlist' + return false +end + Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) base = File.read('.base-branch').strip commits = `git rev-list #{base}..`.strip.split("\n") @@ -14,10 +42,16 @@ if commits.size == 0 exit 0 end -changelog = `git diff #{base}.. CHANGELOG.md`.strip -if changelog.length == 0 - STDERR.puts "No CHANGELOG.md entries since #{base}." - exit 1 +if requires_changelog(commits) + changelog = `git diff #{base}.. CHANGELOG.md`.strip + if changelog.length == 0 + STDERR.puts "FAIL: Requires CHANGELOG, but no CHANGELOG.md entries found since #{base}." + exit 1 + else + puts "OK: Changelog changes found" + end +else + puts "OK: No Changelog required" end # Pull in package fixes automatically.