Skip to content

Commit

Permalink
infra: add comment on PRs to ask for dev site review (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Jun 20, 2023
1 parent a6f89ef commit 451bf7e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ on:
description: hack
type: string
required: true
branch:
description: Branch suffix to push the evaluated projects to
type: string
required: true
default: ''
# To be used by pr_flow and passed down to the workflow
# that builds the docs.
outputs:
Expand Down Expand Up @@ -100,6 +105,7 @@ jobs:
with:
project: ${{ matrix.project }}
type: ${{ inputs.type }}
branch: ${{ inputs.branch }}
build_matrix:
needs: inferprojects
if: ( inputs.type == 'workflow_dispatch' || github.event_name == 'schedule' ) && needs.inferprojects.outputs.projects != '[]'
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build_one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: hack
required: true
type: string
branch:
description: Branch suffix to push the evaluated projects to
type: string
default: ''
workflow_dispatch:
inputs:
project:
Expand Down Expand Up @@ -84,7 +88,7 @@ jobs:
if: inputs.type == 'workflow_call'
run: |
DIR=${{ inputs.project }}
BRANCHNAME="tmp_evaluated_fghgf_${{ github.ref_name }}"
BRANCHNAME="tmp_evaluated_fghgf_${{ inputs.branch }}"
REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git"
git config user.email "travis@travis.org"
git config user.name "travis"
Expand Down Expand Up @@ -116,7 +120,7 @@ jobs:
git add ./doc/$DIR
git commit -m "adding $DIR"
git push --force "https://pyviz-developers:${{ secrets.GITHUB_TOKEN }}@github.com/holoviz-topics/examples.git" HEAD:$BRANCHNAME
git checkout ${{ github.ref_name }}
git checkout -
- name: clean up
run: doit clean --clean-dep build:${{ inputs.project }}
- name: git diff
Expand Down
33 changes: 25 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ on:
type: string
required: true
default: dev
evaluated_branch:
description: Branch to pull the evaluated projects from
branch:
description: Branch suffix to pull the evaluated projects from
type: string
required: true
default: ''
Expand Down Expand Up @@ -64,7 +64,8 @@ on:

jobs:
build_docs:
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true
# On merged PRs, workflow_call (pull_request event) or other events that can trigger this workflow (see above)
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && inputs.type == 'workflow_call') || github.event.pull_request.merged == true
name: Documentation
runs-on: 'ubuntu-latest'
timeout-minutes: 30
Expand All @@ -81,6 +82,8 @@ jobs:
run: |
echo ${{ github.ref_name }}
echo ${{ github.event_name }}
echo ${{ inputs.type }}
echo ${{ inputs.branch }}
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
Expand All @@ -91,12 +94,14 @@ jobs:
id: set-vars
run: |
EVENTNAME="${{ github.event_name }}"
# Called by pr_flow.yml, uses the tmp evaluated branch
# Called by pr_flow.yml, uses the tmp evaluated branch,
# github.event_name doesn't matter as we're using inputs.type to
# define the context.
if [ "${{ inputs.type }}" == "workflow_call" ]; then
NAME="${{ inputs.evaluated_branch }}"
NAME="tmp_evaluated_fghgf_${{ inputs.branch }}"
TARGET="dev"
# Merged PRs, use the evaluated branch
elif [ "$EVENTNAME" == "pull_request" ]; then
elif [ "$EVENTNAME" == "pull_request" -a "${{ github.event.pull_request.merged }}" == "true" ]; then
NAME="tmp_evaluated_fghgf_${{ github.event.pull_request.head.ref }}"
TARGET="main"
elif [ "$EVENTNAME" == "workflow_dispatch" ]; then
Expand Down Expand Up @@ -225,6 +230,7 @@ jobs:
git config user.name "travis"
git fetch https://github.com/${GITHUB_REPOSITORY}.git evaluated:refs/remotes/evaluated
git fetch https://github.com/${GITHUB_REPOSITORY}.git $DEVBRANCH:refs/remotes/$DEVBRANCH
git fetch https://github.com/${GITHUB_REPOSITORY}.git ${{ inputs.branch }}:refs/remotes/${{ inputs.branch }}
git fetch https://github.com/${GITHUB_REPOSITORY}.git main:refs/remotes/main
git checkout evaluated
git checkout -b evaluated
Expand All @@ -243,7 +249,7 @@ jobs:
# This isn't meant to be pushed, it's just for this docs build
git add './doc/'
git commit -m "Add $CHANGEDPROJECTS"
git checkout ${{ github.ref_name }}
git checkout ${{ inputs.branch }}
# Checkout only the /doc folder than contains the evaluated artefacts
git checkout evaluated -- ./doc
git diff
Expand All @@ -258,6 +264,7 @@ jobs:
git config user.email "travis@travis.org"
git config user.name "travis"
git fetch https://github.com/${GITHUB_REPOSITORY}.git evaluated:refs/remotes/evaluated
git fetch https://github.com/${GITHUB_REPOSITORY}.git ${{ inputs.branch }}:refs/remotes/${{ inputs.branch }}
git fetch https://github.com/${GITHUB_REPOSITORY}.git main:refs/remotes/main
git checkout evaluated
git checkout -b evaluated
Expand All @@ -273,7 +280,7 @@ jobs:
git diff
# This isn't meant to be pushed, it's just for this docs build
git commit -m "Remove $REMOVEDPROJECTS"
git checkout ${{ github.ref_name }}
git checkout ${{ inputs.branch }}
# Checkout only the /doc folder than contains the evaluated artefacts
git checkout evaluated -- ./doc
git diff
Expand Down Expand Up @@ -347,3 +354,13 @@ jobs:
# run: git diff
# - name: Check clean up
# run: git diff --quiet --exit-code
- name: Comment PR
# Only display the comment in a pr_flow context
if: inputs.type == 'workflow_call'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Your changes were successfully integrated in the dev site, make sure to review
the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/.
You can also download an archive of the site from the workflow summary page which comes in handy
when your dev site built was overriden by another PR (we have a single dev site!).
15 changes: 10 additions & 5 deletions .github/workflows/pr_flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
name: test+build+doc

on:
push:
branches-ignore:
pull_request:
branches:
- "main"
- "evaluated"
- "tmp_evaluated_fghgf_**"

# Cancel previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
setup:
Expand All @@ -28,6 +31,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- uses: hmarr/debug-action@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
Expand Down Expand Up @@ -66,13 +70,14 @@ jobs:
with:
projects: ${{ needs.setup.outputs.changedprojects }}
type: workflow_call
branch: ${{ github.event.pull_request.head.ref }}
docs:
needs: [setup, build]
if: needs.build.result == 'success' || needs.build.result == 'skipped'
uses: ./.github/workflows/docs.yml
with:
target: dev
evaluated_branch: "tmp_evaluated_fghgf_${{ github.ref_name }}"
branch: ${{ github.event.pull_request.head.ref }}
changedprojects: ${{ needs.setup.outputs.changedprojects }}
removedprojects: ${{ needs.setup.outputs.removedprojects }}
type: workflow_call
Expand Down
2 changes: 2 additions & 0 deletions template/anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: This is the example project
# required: config
examples_config:
#### REQUIRED ###

# Creation date following the YYYY-MM-DD format
created: 2022-01-20
# List of the GITHUB handle of the authors/maintainers
Expand All @@ -22,6 +23,7 @@ examples_config:
- "panel"

### OPTIONAL ###

# The project title is used to display the project name in the gallery. The
# default title is a prettyfied version of the project name,
# i.e. 'foo_bar' becomes 'Foo Bar'.
Expand Down

0 comments on commit 451bf7e

Please sign in to comment.