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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]