Skip to content

Commit

Permalink
Link to demo in PR + check checkboxes (#2543)
Browse files Browse the repository at this point in the history
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Part of #2167

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested https://demo.rerun.io/pr/2543 (if applicable)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2543

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/2ceab68/docs
Examples preview: https://rerun.io/preview/2ceab68/examples
<!-- pr-link-docs:end -->
  • Loading branch information
jprochazk authored and emilk committed Jun 29, 2023
1 parent 1fb76fb commit aeb8bba
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ To get an auto-generated PR description you can put "copilot:summary" or "copilo
### Checklist
* [ ] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [ ] I've included a screenshot or gif (if applicable)
* [ ] I have tested https://demo.rerun.io/pr/{{ pr-number }} (if applicable)

<!-- This line will get updated when the PR build summary job finishes. -->
PR Build Summary: {{ pr-build-summary }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ uploaded anywhere.
- `RELEASE_VERSION` - If producing a release, the version number.
- `UPLOAD_COMMIT_OVERRIDE` - If set, will replace the value of `<commit>`. This is necessary because we want pull
request builds associated with their originating commit, even if the web-build happens on an ephemeral merge-commit.
- `PR_NUMBER` - If set, will upload `demo.rerun.io/pr/<PR_NUMBER>`
- [reusable_pr_summary.yml](reusable_pr_summary.yml) - This job updates the PR summary with the results of the CI run.
- This summary can be found at:
`https://build.rerun.io/pr/<PR_NUMBER>/`
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/checkboxes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Checks that all checkboxes in a PR are checked

name: Pull Request Checkboxes

on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited

concurrency:
group: ${{ github.event.pull_request.number }}-pr-checkboxes
cancel-in-progress: true

jobs:
pr-checkboxes:
name: Check PR checkboxes

permissions:
contents: "read"
id-token: "write"
pull-requests: "write"

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install deps
run: pip install PyGithub # NOLINT

- name: Check PR checkboxes
run: |
./scripts/check_pr_checkboxes.py \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--github-repository ${{ github.repository }} \
--pr-number ${{ github.event.pull_request.number }}
29 changes: 16 additions & 13 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,30 @@ jobs:
uses: ./.github/workflows/reusable_checks.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
secrets: inherit

min-test-wheel:
name: 'Minimum Wheel'
name: "Minimum Wheel"
uses: ./.github/workflows/reusable_build_and_test_wheels.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
SAVE_CACHE: false
PLATFORM: linux
MATURIN_FEATURE_FLAGS: '--no-default-features --features extension-module'
WHEEL_ARTIFACT_NAME: 'linux-wheel-fast'
MATURIN_FEATURE_FLAGS: "--no-default-features --features extension-module"
WHEEL_ARTIFACT_NAME: "linux-wheel-fast"
RRD_ARTIFACT_NAME: linux-rrd-fast
secrets: inherit

build-web:
name: 'Build Web'
name: "Build Web"
uses: ./.github/workflows/reusable_build_web.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
secrets: inherit

upload-web:
name: 'Upload Web'
name: "Upload Web"
needs: [min-test-wheel, build-web]
uses: ./.github/workflows/reusable_upload_web.yml
with:
Expand All @@ -45,7 +46,7 @@ jobs:
secrets: inherit

build-web-demo:
name: 'Build Web Demo'
name: "Build Web Demo"
needs: [min-test-wheel, build-web]
uses: ./.github/workflows/reusable_build_web_demo.yml
with:
Expand All @@ -55,16 +56,17 @@ jobs:
secrets: inherit

upload-web-demo:
name: 'Upload Web Demo'
name: "Upload Web Demo"
needs: [build-web-demo]
uses: ./.github/workflows/reusable_upload_web_demo.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
UPLOAD_COMMIT_OVERRIDE: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
secrets: inherit

run-notebook:
name: 'Run Notebook'
name: "Run Notebook"
needs: [min-test-wheel]
uses: ./.github/workflows/reusable_run_notebook.yml
with:
Expand All @@ -74,18 +76,19 @@ jobs:
secrets: inherit

save-pr-summary:
name: 'Save PR Summary'
name: "Save PR Summary"
needs: [upload-web, run-notebook]
uses: ./.github/workflows/reusable_pr_summary.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
secrets: inherit
link-docs:
name: 'Link Docs'
uses: ./.github/workflows/reusable_pr_link_docs.yml

update-pr-body:
name: "Update PR Body"
uses: ./.github/workflows/reusable_update_pr_body.yml
with:
CONCURRENCY: pr-${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
secrets: inherit

26 changes: 14 additions & 12 deletions .github/workflows/reusable_checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Checks: Lints, Tests, Docs'
name: "Checks: Lints, Tests, Docs"

on:
workflow_call:
Expand All @@ -22,6 +22,10 @@ on:
required: false
type: boolean
default: false
PR_NUMBER:
required: false
type: string
default: ""

concurrency:
group: ${{ inputs.CONCURRENCY }}-checks
Expand All @@ -42,8 +46,7 @@ env:
RUSTC_WRAPPER: "sccache"

jobs:

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

py-lints:
name: Python lints (black, mypy, flake8)
Expand Down Expand Up @@ -76,7 +79,7 @@ jobs:
run: |
just py-requirements
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

py-test-docs:
name: Test Python Docs
Expand All @@ -100,7 +103,7 @@ jobs:
run: |
mkdocs build -f rerun_py/mkdocs.yml
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

rs-lints:
name: Rust lints (fmt, check, cranky, tests, doc)
Expand Down Expand Up @@ -139,7 +142,6 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]


# First do our check with --locked to make sure `Cargo.lock` is up to date
- name: Check all features
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -203,7 +205,7 @@ jobs:
command: test
args: --all-targets --all-features

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

rs-check-wasm:
name: Check Rust web build (wasm32 + wasm-bindgen)
Expand Down Expand Up @@ -240,13 +242,12 @@ jobs:
command: run
args: --locked -p re_build_web_viewer -- --debug

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

toml-lints:
name: Lint TOML files
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

- name: Set up cargo cache
Expand All @@ -268,7 +269,7 @@ jobs:
run: |
taplo fmt --check
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

misc-rerun-lints:
name: Rerun lints
Expand All @@ -293,7 +294,7 @@ jobs:
run: |
./scripts/check_requirements.py
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

spell-check:
name: Spell Check
Expand All @@ -305,7 +306,7 @@ jobs:
- name: Check spelling of entire workspace
uses: crate-ci/typos@master

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

rs-cargo-deny:
name: Cargo Deny ${{ matrix.platform }}
Expand All @@ -324,3 +325,4 @@ jobs:
shell: bash
id: expected_version
run: ./scripts/cargo_deny.sh

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable PR Link Docs
name: Update links in PR Body

on:
workflow_call:
Expand All @@ -15,8 +15,8 @@ concurrency:
cancel-in-progress: true

jobs:
pr-link-docs:
name: Link to docs preview in PR
update-pr-body:
name: Update PR body

permissions:
contents: "read"
Expand All @@ -37,13 +37,10 @@ jobs:
- name: Install deps
run: pip install PyGithub # NOLINT

- name: Link to docs
- name: Update PR description
run: |
python scripts/pr_link_docs.py \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--github-repository ${GITHUB_REPOSITORY} \
--pr-number ${{ inputs.PR_NUMBER }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ inputs.PR_NUMBER }}
./scripts/update_pr_body.py \
--github-token '${{ secrets.GITHUB_TOKEN }}' \
--github-repository '${{ github.repository }}' \
--pr-number '${{ inputs.PR_NUMBER }}'
21 changes: 16 additions & 5 deletions .github/workflows/reusable_upload_web_demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
ADHOC_NAME:
type: string
required: false
default: ''
default: ""
MARK_PRERELEASE_FOR_MAINLINE:
required: false
type: boolean
Expand All @@ -21,26 +21,28 @@ on:
RELEASE_VERSION:
required: false
type: string
default: 'prerelease'
default: "prerelease"
# We need this because PRs use a merged commit but we really want
# to track uploads based on the source commit.
UPLOAD_COMMIT_OVERRIDE:
required: false
type: string
default: ''
default: ""
UPLOAD_COMMIT:
required: false
type: boolean
default: true
PR_NUMBER:
type: string
default: ""

concurrency:
group: ${{ inputs.CONCURRENCY }}-upload-web-demo
cancel-in-progress: true

jobs:

upload-web:
name: Upload Web Wemo to Google Cloud
name: Upload Web Demo to Google Cloud
permissions:
contents: "read"
id-token: "write"
Expand Down Expand Up @@ -103,3 +105,12 @@ jobs:
path: "web_demo"
destination: "rerun-demo/adhoc/${{inputs.ADHOC_NAME}}"
parent: false

- name: "Upload web demo (pr)"
if: ${{ inputs.PR_NUMBER != '' }}
uses: google-github-actions/upload-cloud-storage@v1
with:
path: "web_demo"
destination: "rerun-demo/pr/${{ inputs.PR_NUMBER }}"
parent: false

37 changes: 37 additions & 0 deletions scripts/check_pr_checkboxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

from __future__ import annotations

import argparse

from github import Github # NOLINT


def main() -> None:
parser = argparse.ArgumentParser(description="Generate a PR summary page")
parser.add_argument("--github-token", required=True, help="GitHub token")
parser.add_argument("--github-repository", required=True, help="GitHub repository")
parser.add_argument("--pr-number", required=True, type=int, help="PR number")
args = parser.parse_args()

gh = Github(args.github_token) # NOLINT
repo = gh.get_repo(args.github_repository)
pr = repo.get_pull(args.pr_number)

latest_commit = pr.get_commits().reversed[0]
print(f"Latest commit: {latest_commit.sha}")

body_lower = pr.body.lower()
if "* [ ]" in body_lower or "- [ ]" in body_lower:
print("PR contains unchecked checkboxes")
exit(1)
elif "* [x]" in body_lower or "- [x]" in body_lower:
print("All clear")
exit(0)
else:
print("Don't delete the PR description")
exit(1)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

cryptography==38.0.4 # for scripts/upload_image.py
google-cloud-storage==2.9.0 # for scripts/upload_image.py
PyGithub==1.58.2 # for scripts/generate_pr_summary.py and scripts/pr_link_docs_preview.py
PyGithub==1.58.2 # for scripts/generate_pr_summary.py and scripts/update_pr_body.py
Pillow # for scripts/upload_image.py
tqdm
requests
Loading

0 comments on commit aeb8bba

Please sign in to comment.