You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/06/06 18:17:55 UTC
[GitHub] [tvm] gigiblender opened a new pull request, #11594: Add Github webhook to comment with link to docs
gigiblender opened a new pull request, #11594:
URL: https://github.com/apache/tvm/pull/11594
This PR adds a webhook to post a link to documentation when a commit passes the CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r893694711
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
sh(
- script: "aws s3 cp --no-progress _docs s3://${s3_prefix}/docs --recursive",
+ script: """
+ set -eux
+ aws s3 rm --no-progress s3://${docs_path} --recursive
Review Comment:
the `@tvm-bot <command>` workflow used to do this: https://github.com/apache/tvm/blob/main/tests/scripts/github_tvmbot.py#L71, it queries the PR for the latest N comments then iterates over them looking at the contents. Here I think it would make sense to:
1. query for the first few comments with graphql and something like
```graphql
query ($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
comments(first: 100) {
nodes {
author {
login
}
body
databaseId
}
}
}
}
}
```
2. search for a sigil that the bot leaves in its comments, maybe an HTML comment like `<!---tvm-bot comment marker -->`
3. update it in place via the `databaseId` if found, post a new comment if not
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r895644418
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return (
+ base_url_docs + "/tvm/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
+ )
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+ init_log()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ target_url = os.environ["TARGET_URL"]
+ pr_and_build = get_pr_and_build_numbers(target_url)
+
+ docs_url = build_docs_url(
+ args.base_url_docs, pr_and_build["pr_number"], pr_and_build["build_number"]
+ )
+
Review Comment:
Having a partial rollout of this sounds good to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Mousius commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891246613
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
Review Comment:
Can this use `s3_prefix` which also incorporates `BUILD_NUMBER`?
See:
https://github.com/apache/tvm/blob/70884e957aa5c8de9c02c25a14d30563d7300cb9/Jenkinsfile#L97-L98
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
+
+ def run(build_number, expected_url, expected_body):
Review Comment:
I think this is `pr_number` rather than `build_number` ?
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
Can we use a domain name we have control over rather than `cloudfront.net` ?
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
+
+ def run(build_number, expected_url, expected_body):
+ git = TempGit(tmpdir_factory.mktemp("tmp_git_dir"))
+ git.run("init")
+ git.run("checkout", "-b", "main")
+ git.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
+ proc = subprocess.run(
+ [str(docs_comment_script), "--dry-run"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env={"PR": json.dumps({"number": int(build_number)})},
+ encoding="utf-8",
+ cwd=git.cwd,
+ )
+ if proc.returncode != 0:
+ raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
+
+ assert (
+ f"Dry run, would have posted {expected_url} with data {expected_body}." in proc.stdout
+ )
+
+ run(
Review Comment:
Please use `pytest.mark.parameterize` rather than nested function calls (see: https://docs.pytest.org/en/6.2.x/parametrize.html)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Mousius merged pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
Mousius merged PR #11594:
URL: https://github.com/apache/tvm/pull/11594
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
areusch commented on PR #11594:
URL: https://github.com/apache/tvm/pull/11594#issuecomment-1155815383
@Mousius can you look at this one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
areusch commented on PR #11594:
URL: https://github.com/apache/tvm/pull/11594#issuecomment-1151758207
@gigiblender please ping the others when this is ready for another look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Mousius commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r892164711
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
sh(
- script: "aws s3 cp --no-progress _docs s3://${s3_prefix}/docs --recursive",
+ script: """
+ set -eux
+ aws s3 rm --no-progress s3://${docs_path} --recursive
Review Comment:
Do you have an example of where we've achieved this before?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r895868897
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+import sys
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return f"{base_url_docs}/tvm/PR-{str(pr_number)}/{str(build_number)}/docs/index.html"
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+ init_log()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ target_url = os.environ["TARGET_URL"]
+ pr_and_build = get_pr_and_build_numbers(target_url)
+
+ commit_sha = os.environ["COMMIT_SHA"]
+
+ docs_url = build_docs_url(
+ args.base_url_docs, pr_and_build["pr_number"], pr_and_build["build_number"]
+ )
+
+ url = f'/issues/{pr_and_build["pr_number"]}/comments'
Review Comment:
```suggestion
url = f'issues/{pr_and_build["pr_number"]}/comments'
```
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+import sys
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return f"{base_url_docs}/tvm/PR-{str(pr_number)}/{str(build_number)}/docs/index.html"
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+ init_log()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ target_url = os.environ["TARGET_URL"]
+ pr_and_build = get_pr_and_build_numbers(target_url)
+
+ commit_sha = os.environ["COMMIT_SHA"]
+
+ docs_url = build_docs_url(
+ args.base_url_docs, pr_and_build["pr_number"], pr_and_build["build_number"]
+ )
+
+ url = f'/issues/{pr_and_build["pr_number"]}/comments'
+ body = f"Built docs for commit [{commit_sha}]({commit_sha}) can be found [here]({docs_url})."
+ if not args.dry_run:
+ github = GitHubRepo(token=os.environ["GITHUB_TOKEN"], user=user, repo=repo)
+
+ # For now, only comment for PRs open by driazati, gigiblender and areusch.
+ get_pr_url = f'/repos/apache/tvm/pulls/{pr_and_build["pr_number"]}'
+ pull_request_body = github.get(get_pr_url)
Review Comment:
```suggestion
get_pr_url = f'pulls/{pr_and_build["pr_number"]}'
pull_request_body = github.get(get_pr_url)
```
doesn't the `GitHubRepo` class handle the `/repos/apache/tvm` part? https://github.com/apache/tvm/blob/2df4524e04cf48f759175a746632efe6ff0a7ea6/tests/scripts/git_utils.py#L99
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+import sys
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return f"{base_url_docs}/tvm/PR-{str(pr_number)}/{str(build_number)}/docs/index.html"
Review Comment:
```suggestion
return f"{base_url_docs}/PR-{str(pr_number)}/{str(build_number)}/docs/index.html"
```
the new URL also removes the `tvm` prefix
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return (
+ base_url_docs + "/tvm/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
+ )
Review Comment:
```suggestion
return (
base_url_docs + "/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
)
```
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+import sys
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return f"{base_url_docs}/tvm/PR-{str(pr_number)}/{str(build_number)}/docs/index.html"
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
Review Comment:
I moved this to a friendlier URL e.g. https://pr-docs.tlcpack.ai/PR-11470/18/docs/index.html
```suggestion
parser.add_argument("--base-url-docs", default="https://pr-docs.tlcpack.ai")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891323162
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
Not sure about the reason behind.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Mousius commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891470358
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
Ahh, fair enough, I can't see your internal tracker - potentially worth exposing in an issue?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r893317471
##########
.github/workflows/docs_bot.yml:
##########
@@ -0,0 +1,17 @@
+
+name: docs-bot
+on:
+ status
+jobs:
+ run-docs-bot:
+ if: ${{ github.repository == 'apache/tvm' && github.event.state == 'success' }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Comment link to docs
Review Comment:
Checking against [`tvm-ci/pr-head`](https://github.com/apache/tvm/blob/40c3c1f760c79760d7d5fd80988d86d09cdeb09c/.github/workflows/docs_bot.yml#L7) should do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891470545
##########
.github/workflows/docs_bot.yml:
##########
@@ -0,0 +1,17 @@
+
+name: docs-bot
+on:
+ status
+jobs:
+ run-docs-bot:
+ if: ${{ github.repository == 'apache/tvm' && github.event.state == 'success' }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Comment link to docs
Review Comment:
we should skip this on `status`es that go to commits without a PR (e.g. `main`)
```suggestion
- name: Comment link to docs
if: github.event.pull_request
```
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
sh(
- script: "aws s3 cp --no-progress _docs s3://${s3_prefix}/docs --recursive",
+ script: """
+ set -eux
+ aws s3 rm --no-progress s3://${docs_path} --recursive
Review Comment:
I think we should keep the uploads in separate iterations so old ones are still accessible. This complicates this bot a bit since it can't just post the comment once, it needs to check on every time it gets a status and update the current link (ideally we wouldn't leave more comments but search for the old one and update it in place), but the URL could then be something like `https://d3f1x5ne0bf47p.cloudfront.net/tvm/PR-1/2/docs/index.html`
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import json
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+
+
+def build_docs_url(base_url_docs, pr_number):
+ return base_url_docs + "/tvm/PR-" + str(pr_number) + "/docs/index.html"
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ pr = json.loads(os.environ["PR"])
+ number = pr["number"]
+
+ docs_url = build_docs_url(args.base_url_docs, number)
+
+ url = f"/issues/{number}/comments"
+ body = f"Built docs can be found [here]({docs_url})."
+ if not args.dry_run:
+ github = GitHubRepo(token=os.environ["GITHUB_TOKEN"], user=user, repo=repo)
+ try:
+ github.post(url, {"body": body})
+ except error.HTTPError as e:
+ print(f"Failed to add docs comment {docs_url}: {e}")
Review Comment:
Can you use `logging` to get a full traceback here (and replace the other `print`s as well?) the other Python scripts in `tests/scripts` have some example usages (just call `cmd_utils.init_log()` and then use `logging.info`)
```suggestion
logging.exception(f"Failed to add docs comment {docs_url}: {e}")
```
##########
.github/workflows/docs_bot.yml:
##########
@@ -0,0 +1,17 @@
+
+name: docs-bot
+on:
+ status
+jobs:
+ run-docs-bot:
+ if: ${{ github.repository == 'apache/tvm' && github.event.state == 'success' }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Comment link to docs
+ env:
+ PR: ${{ toJson(github.event.pull_request) }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -eux
+ python tests/scripts/github_docs_comment.py || echo step failed
Review Comment:
this job doesn't show up on PRs afaik so we don't need to hide failures
```suggestion
python tests/scripts/github_docs_comment.py
```
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
Review Comment:
see https://github.com/apache/tvm/pull/11594#discussion_r891474732
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r894720868
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return (
+ base_url_docs + "/tvm/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
+ )
Review Comment:
nit: f-string
```suggestion
return f"{base_url_docs}/tvm/PR-{pr_number}/{build_number}/docs/index.html"
```
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return (
+ base_url_docs + "/tvm/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
+ )
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+ init_log()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ target_url = os.environ["TARGET_URL"]
+ pr_and_build = get_pr_and_build_numbers(target_url)
+
+ docs_url = build_docs_url(
+ args.base_url_docs, pr_and_build["pr_number"], pr_and_build["build_number"]
+ )
+
+ url = f'/issues/{pr_and_build["pr_number"]}/comments'
+ body = f"Built docs can be found [here]({docs_url})."
Review Comment:
is it easy to grab the SHA from GitHub as well? it's supposedly on the [status webhook](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#webhook-payload-object-47), including it here might be nice in case a build is currently in flight and its not clear which version of the docs it is.
```suggestion
body = f"Built docs for {commit_sha} can be found [here]({docs_url})."
```
If it's not just a one-liner env variable in the actions yaml we can skip this
##########
tests/scripts/github_docs_comment.py:
##########
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import logging
+import argparse
+from urllib import error
+
+from git_utils import git, GitHubRepo, parse_remote
+from cmd_utils import init_log
+
+
+def build_docs_url(base_url_docs, pr_number, build_number):
+ return (
+ base_url_docs + "/tvm/PR-" + str(pr_number) + "/" + str(build_number) + "/docs/index.html"
+ )
+
+
+def get_pr_and_build_numbers(target_url):
+ target_url = target_url[target_url.find("PR-") : len(target_url)]
+ split = target_url.split("/")
+ pr_number = split[0].strip("PR-")
+ build_number = split[1]
+ return {"pr_number": pr_number, "build_number": build_number}
+
+
+if __name__ == "__main__":
+ help = "Add comment with link to docs"
+ parser = argparse.ArgumentParser(description=help)
+ parser.add_argument("--remote", default="origin", help="ssh remote to parse")
+ parser.add_argument("--base-url-docs", default="https://d3f1x5ne0bf47p.cloudfront.net")
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ default=False,
+ help="run but don't send any request to GitHub",
+ )
+ args = parser.parse_args()
+ init_log()
+
+ remote = git(["config", "--get", f"remote.{args.remote}.url"])
+ user, repo = parse_remote(remote)
+
+ target_url = os.environ["TARGET_URL"]
+ pr_and_build = get_pr_and_build_numbers(target_url)
+
+ docs_url = build_docs_url(
+ args.base_url_docs, pr_and_build["pr_number"], pr_and_build["build_number"]
+ )
+
Review Comment:
sorry to tack on another thing after the fact but this may lead to a lot of bot comments on peoples PRs, we should roll it out slowly instead of affecting everyone all at once. What do you think about querying GitHub for the PR here so we can check the author and only comment for a certain list of users at first (maybe you, me, and @areusch) and after a day or two of seeing it work in prod then remove the gate?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on PR #11594:
URL: https://github.com/apache/tvm/pull/11594#issuecomment-1148186199
@areusch @driazati
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891320901
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
Review Comment:
Then I will need the jenkins build number in github actions to be part of the URL, which I am not sure how to obtain.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on PR #11594:
URL: https://github.com/apache/tvm/pull/11594#issuecomment-1152233122
@Mousius @driazati, I think this is ready for another look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891465662
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
We can as a follow up, we're doing this incrementally so the cloudfront domain is just easier to get started with and is immediately useful to devs (comes with HTTPS for example)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Mousius commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891469931
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
Review Comment:
Hmm, maybe @driazati can advise on how tricky that is? 😸
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891322663
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
I think we agreed to use the default cloudfront domain for now: https://octoml.atlassian.net/browse/OSS-50
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] gigiblender commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
gigiblender commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891320901
##########
jenkins/Test.groovy.j2:
##########
@@ -266,8 +266,13 @@ stage('Test') {
)
}
{{ m.upload_artifacts(tag='docs', filenames=["docs.tgz"]) }}
+ def docs_path = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/docs/"
Review Comment:
Then I will need the jenkins build number in github actions, which I am not sure how to obtain.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #11594:
URL: https://github.com/apache/tvm/pull/11594#discussion_r891481763
##########
tests/python/ci/test_ci.py:
##########
@@ -35,6 +35,37 @@ def run(self, *args):
raise RuntimeError(f"git command failed: '{args}'")
+def test_docs_comment(tmpdir_factory):
+ docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"
+ base_url = "https://d3f1x5ne0bf47p.cloudfront.net"
Review Comment:
filed #11605
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on pull request #11594: Add Github webhook to comment with link to docs
Posted by GitBox <gi...@apache.org>.
areusch commented on PR #11594:
URL: https://github.com/apache/tvm/pull/11594#issuecomment-1152665465
@Mousius can you take another look?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org