From fc9f8c28fbdc89501ebdca4792d5ff86490f9295 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:09:54 +1000 Subject: [PATCH 1/9] Appveyor CI: Fix GitHub provider detection Part of 26979. --- scripts/test/appveyor-irc-notify.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index 4ffea52684..297b02b158 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -22,6 +22,9 @@ # - Accept UTF-8 # - only guess github URLs # - stop using ANSI colors +# +# Modified by teor in 2018: +# - fix github provider detection ('gitHub' or 'gitHubEnterprise', apparently) # This program is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software Foundation; @@ -110,7 +113,7 @@ def appveyor_vars(): BUILD_FMT = u'{url}/project/{account_name}/{project_name}/build/{build_version}' - if vars["repo_provider"] == 'github': + if vars["repo_provider"].lower().startswith('github'): COMMIT_FMT = u'https://{repo_provider}.com/{repo_name}/commit/{repo_commit}' vars.update(commit_url=COMMIT_FMT.format(**vars)) From 861db8c4aef4b71648a6ec9acad35bff042d00f2 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:10:55 +1000 Subject: [PATCH 2/9] Appveyor CI: Make short commits 10 hexdigits long That's what git does for tor. Part of 26979. --- scripts/test/appveyor-irc-notify.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index 297b02b158..fc2ead1647 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -25,6 +25,7 @@ # # Modified by teor in 2018: # - fix github provider detection ('gitHub' or 'gitHubEnterprise', apparently) +# - make short commits 10 hexdigits long (that's what git does for tor) # This program is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software Foundation; @@ -119,7 +120,7 @@ def appveyor_vars(): vars.update( build_url=BUILD_FMT.format(**vars), - short_commit=vars["repo_commit"][:7], + short_commit=vars["repo_commit"][:10], ) return vars From 9b41eb2bc3294f9bf0cf85d75fe2680efcebcc0e Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:12:21 +1000 Subject: [PATCH 3/9] Appveyor CI: Generate correct branches and URLs for pull requests Part of 26979. --- scripts/test/appveyor-irc-notify.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index fc2ead1647..f830db4e44 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -26,6 +26,7 @@ # Modified by teor in 2018: # - fix github provider detection ('gitHub' or 'gitHubEnterprise', apparently) # - make short commits 10 hexdigits long (that's what git does for tor) +# - generate correct branches and URLs for pull requests # This program is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software Foundation; @@ -102,6 +103,9 @@ def appveyor_vars(): 'APPVEYOR_REPO_COMMIT_TIMESTAMP', 'APPVEYOR_REPO_PROVIDER', 'APPVEYOR_PROJECT_NAME', + 'APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME', + 'APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH', + 'APPVEYOR_PULL_REQUEST_HEAD_COMMIT', 'APPVEYOR_PULL_REQUEST_TITLE', 'APPVEYOR_BUILD_VERSION', 'APPVEYOR_REPO_COMMIT', @@ -112,15 +116,25 @@ def appveyor_vars(): ] ]) + vars.update( + short_commit=vars["repo_commit"][:10], + ) + BUILD_FMT = u'{url}/project/{account_name}/{project_name}/build/{build_version}' + BRANCH_FMT = u'{repo_name} {repo_branch} {short_commit}' if vars["repo_provider"].lower().startswith('github'): - COMMIT_FMT = u'https://{repo_provider}.com/{repo_name}/commit/{repo_commit}' + COMMIT_FMT = u'https://github.com/{repo_name}/commit/{repo_commit}' + if vars["pull_request_number"]: + BRANCH_FMT = u'{repo_name} {repo_branch} pull {pull_request_head_repo_name} {pull_request_head_repo_branch} {short_commit}' + COMMIT_FMT = u'https://github.com/{pull_request_head_repo_name}/commit/{pull_request_head_commit}' + PULL_FMT = u'https://github.com/{repo_name}/pull/{pull_request_number}' + vars.update(pull_url=PULL_FMT.format(**vars)) vars.update(commit_url=COMMIT_FMT.format(**vars)) vars.update( build_url=BUILD_FMT.format(**vars), - short_commit=vars["repo_commit"][:10], + branch_detail=BRANCH_FMT.format(**vars), ) return vars @@ -138,7 +152,7 @@ def notify(): if success or failure: messages = [] - messages.append(u"{repo_name} {repo_branch} {short_commit} - {repo_commit_author}: {repo_commit_message}") + messages.append(u"{branch_detail} - {repo_commit_author}: {repo_commit_message}") if success: m = u"Build #{build_version} passed. Details: {build_url}" @@ -147,7 +161,10 @@ def notify(): if "commit_url" in apvy_vars: m += " Commit: {commit_url}" - + + if "pull_url" in apvy_vars: + m += " Pull: {pull_url}" + messages.append(m) else: messages = sys.argv[3:] From 3d3e62d1474a386f6a46fe6a8c5d6c7c5bed4f85 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:37:11 +1000 Subject: [PATCH 4/9] Appveyor CI: Switch to one URL per line Part of 26979. --- scripts/test/appveyor-irc-notify.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index f830db4e44..eb4d26ba38 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -27,6 +27,7 @@ # - fix github provider detection ('gitHub' or 'gitHubEnterprise', apparently) # - make short commits 10 hexdigits long (that's what git does for tor) # - generate correct branches and URLs for pull requests +# - switch to one URL per line # This program is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software Foundation; @@ -155,17 +156,16 @@ def notify(): messages.append(u"{branch_detail} - {repo_commit_author}: {repo_commit_message}") if success: - m = u"Build #{build_version} passed. Details: {build_url}" + messages.append(u"Build #{build_version} passed. Details: {build_url}") if failure: - m = u"Build #{build_version} failed. Details: {build_url}" + messages.append(u"Build #{build_version} failed. Details: {build_url}") if "commit_url" in apvy_vars: - m += " Commit: {commit_url}" + messages.append(u"Commit: {commit_url}") if "pull_url" in apvy_vars: - m += " Pull: {pull_url}" + messages.append(u"Pull: {pull_url}") - messages.append(m) else: messages = sys.argv[3:] messages = ' '.join(messages) From 019c31bbf8a7aff9e99c8e373daa4d0f4102d1a4 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:47:33 +1000 Subject: [PATCH 5/9] Appveyor CI: Generate correct tag names Part of 26979. --- scripts/test/appveyor-irc-notify.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index eb4d26ba38..b06534c3fe 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -26,7 +26,7 @@ # Modified by teor in 2018: # - fix github provider detection ('gitHub' or 'gitHubEnterprise', apparently) # - make short commits 10 hexdigits long (that's what git does for tor) -# - generate correct branches and URLs for pull requests +# - generate correct branches and URLs for pull requests and tags # - switch to one URL per line # This program is free software; you can redistribute it and/or modify it under the @@ -113,7 +113,8 @@ def appveyor_vars(): 'APPVEYOR_REPO_COMMIT_MESSAGE', 'APPVEYOR_ACCOUNT_NAME', 'APPVEYOR_PULL_REQUEST_NUMBER', - 'APPVEYOR_REPO_NAME' + 'APPVEYOR_REPO_NAME', + 'APPVEYOR_REPO_TAG_NAME', ] ]) @@ -122,7 +123,11 @@ def appveyor_vars(): ) BUILD_FMT = u'{url}/project/{account_name}/{project_name}/build/{build_version}' - BRANCH_FMT = u'{repo_name} {repo_branch} {short_commit}' + + if vars["repo_tag_name"]: + BRANCH_FMT = u'{repo_name} {repo_tag_name} {short_commit}' + else: + BRANCH_FMT = u'{repo_name} {repo_branch} {short_commit}' if vars["repo_provider"].lower().startswith('github'): COMMIT_FMT = u'https://github.com/{repo_name}/commit/{repo_commit}' From 02a45b3ea478b8295a3e15a0a301ce902fba0227 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:49:11 +1000 Subject: [PATCH 6/9] Appveyor CI: fix some typos --- scripts/test/appveyor-irc-notify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index b06534c3fe..59514bebed 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -55,7 +55,7 @@ export APPVEYOR_URL=https://ci.appveyor.com export APPVEYOR_PROJECT_NAME=tor export APPVEYOR_REPO_COMMIT_AUTHOR=isislovecruft export APPVEYOR_REPO_COMMIT_TIMESTAMP=2018-04-23 -export APPVEYOR_REPO_PROVIDER=gihub +export APPVEYOR_REPO_PROVIDER=github export APPVEYOR_REPO_BRANCH=repo_branch export APPVEYOR_PULL_REQUEST_TITLE=pull_request_title export APPVEYOR_BUILD_VERSION=1 @@ -88,7 +88,7 @@ import time def appveyor_vars(): """ - Return a dict of key value carfted from appveyor environment variables. + Return a dict of key value crafted from appveyor environment variables. """ vars = dict([ From c6973aeccb2d65aaed104996d3cd5048421348ab Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:54:02 +1000 Subject: [PATCH 7/9] Appveyor CI: sort environmental variables To avoid future duplicates. --- scripts/test/appveyor-irc-notify.py | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index 59514bebed..639acc6ce6 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -51,19 +51,19 @@ delineate multiple messages. Example: -export APPVEYOR_URL=https://ci.appveyor.com -export APPVEYOR_PROJECT_NAME=tor -export APPVEYOR_REPO_COMMIT_AUTHOR=isislovecruft -export APPVEYOR_REPO_COMMIT_TIMESTAMP=2018-04-23 -export APPVEYOR_REPO_PROVIDER=github -export APPVEYOR_REPO_BRANCH=repo_branch -export APPVEYOR_PULL_REQUEST_TITLE=pull_request_title -export APPVEYOR_BUILD_VERSION=1 -export APPVEYOR_REPO_COMMIT=22c95b72e29248dc4de9b85e590ee18f6f587de8 -export APPVEYOR_REPO_COMMIT_MESSAGE="some IRC test" export APPVEYOR_ACCOUNT_NAME=isislovecruft +export APPVEYOR_BUILD_VERSION=1 +export APPVEYOR_PROJECT_NAME=tor export APPVEYOR_PULL_REQUEST_NUMBER=pull_request_number +export APPVEYOR_PULL_REQUEST_TITLE=pull_request_title +export APPVEYOR_REPO_BRANCH=repo_branch +export APPVEYOR_REPO_COMMIT=22c95b72e29248dc4de9b85e590ee18f6f587de8 +export APPVEYOR_REPO_COMMIT_AUTHOR=isislovecruft +export APPVEYOR_REPO_COMMIT_MESSAGE="some IRC test" +export APPVEYOR_REPO_COMMIT_TIMESTAMP=2018-04-23 export APPVEYOR_REPO_NAME=isislovecruft/tor +export APPVEYOR_REPO_PROVIDER=github +export APPVEYOR_URL=https://ci.appveyor.com python ./appveyor-irc-notify.py irc.oftc.net:6697 tor-ci '{repo_name} {repo_branch} {short_commit} - {repo_commit_author}: {repo_commit_message}','Build #{build_version} passed. Details: {build_url} | Commit: {commit_url} See also https://github.com/gridsync/gridsync/blob/master/appveyor.yml for examples @@ -96,25 +96,25 @@ def appveyor_vars(): v.replace('APPVEYOR_', '').lower(), os.getenv(v, '').decode('utf-8') ) for v in [ - 'APPVEYOR_URL', - 'APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED', + 'APPVEYOR_ACCOUNT_NAME', + 'APPVEYOR_BUILD_VERSION', + 'APPVEYOR_PROJECT_NAME', + 'APPVEYOR_PULL_REQUEST_HEAD_COMMIT', + 'APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH', + 'APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME', + 'APPVEYOR_PULL_REQUEST_NUMBER', + 'APPVEYOR_PULL_REQUEST_TITLE', 'APPVEYOR_REPO_BRANCH', + 'APPVEYOR_REPO_COMMIT', 'APPVEYOR_REPO_COMMIT_AUTHOR', 'APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL', - 'APPVEYOR_REPO_COMMIT_TIMESTAMP', - 'APPVEYOR_REPO_PROVIDER', - 'APPVEYOR_PROJECT_NAME', - 'APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME', - 'APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH', - 'APPVEYOR_PULL_REQUEST_HEAD_COMMIT', - 'APPVEYOR_PULL_REQUEST_TITLE', - 'APPVEYOR_BUILD_VERSION', - 'APPVEYOR_REPO_COMMIT', 'APPVEYOR_REPO_COMMIT_MESSAGE', - 'APPVEYOR_ACCOUNT_NAME', - 'APPVEYOR_PULL_REQUEST_NUMBER', + 'APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED', + 'APPVEYOR_REPO_COMMIT_TIMESTAMP', 'APPVEYOR_REPO_NAME', + 'APPVEYOR_REPO_PROVIDER', 'APPVEYOR_REPO_TAG_NAME', + 'APPVEYOR_URL', ] ]) From fcc848009311717dc23a739273501637ec7826fc Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 11:58:04 +1000 Subject: [PATCH 8/9] Appveyor CI: Changes file for 26979 Closes 26979. --- changes/bug26979 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/bug26979 diff --git a/changes/bug26979 b/changes/bug26979 new file mode 100644 index 0000000000..e615207b74 --- /dev/null +++ b/changes/bug26979 @@ -0,0 +1,4 @@ + o Minor bugfixes (appveyor ci): + - Improve Appveyor CI IRC logging. Generate correct branches and URLs for + pull requests and tags. Use unambiguous short commits. + Fixes bug 26979; bugfix on master. From c3fca338a2c63241497b64a9f997c28f17ef1b6a Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 31 Jul 2018 12:14:40 +1000 Subject: [PATCH 9/9] Appveyor CI: always use HEAD for the short commit Part of 26979. --- scripts/test/appveyor-irc-notify.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index 639acc6ce6..cfe0afe7ae 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -118,10 +118,6 @@ def appveyor_vars(): ] ]) - vars.update( - short_commit=vars["repo_commit"][:10], - ) - BUILD_FMT = u'{url}/project/{account_name}/{project_name}/build/{build_version}' if vars["repo_tag_name"]: @@ -129,15 +125,20 @@ def appveyor_vars(): else: BRANCH_FMT = u'{repo_name} {repo_branch} {short_commit}' + vars.update(head_commit=vars["repo_commit"]) + if vars["repo_provider"].lower().startswith('github'): COMMIT_FMT = u'https://github.com/{repo_name}/commit/{repo_commit}' if vars["pull_request_number"]: + vars.update(head_commit=vars["pull_request_head_commit"]) BRANCH_FMT = u'{repo_name} {repo_branch} pull {pull_request_head_repo_name} {pull_request_head_repo_branch} {short_commit}' COMMIT_FMT = u'https://github.com/{pull_request_head_repo_name}/commit/{pull_request_head_commit}' PULL_FMT = u'https://github.com/{repo_name}/pull/{pull_request_number}' vars.update(pull_url=PULL_FMT.format(**vars)) vars.update(commit_url=COMMIT_FMT.format(**vars)) + vars.update(short_commit=vars["head_commit"][:10]) + vars.update( build_url=BUILD_FMT.format(**vars), branch_detail=BRANCH_FMT.format(**vars),