Skip to content

Commit

Permalink
ci: Use pkgdown branch (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviator-app[bot] authored Oct 27, 2024
2 parents b2c9687 + 324e984 commit 265e161
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/dep-suggests-matrix.json

This file was deleted.

1 change: 0 additions & 1 deletion .github/versions-matrix.json

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/R-CMD-check-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:

name: "Update commit status"

# Only run if triggered by rcc workflow
if: github.event.workflow_run.name == 'rcc'

steps:
- name: "Update commit status"
# Only run if triggered by rcc workflow
if: github.event.workflow_run.name == 'rcc'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
95 changes: 90 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ on:
workflow_dispatch:
inputs:
ref:
description: "Branch or tag to check out"
description: "Branch, tag, or commit to check out"
required: false
default: "main"
versions-matrix:
description: "Create a matrix of R versions"
type: boolean
default: false
dep-suggests-matrix:
description: "Create a matrix of suggested dependencies"
type: boolean
default: false
merge_group:
types:
- checks_requested
Expand All @@ -33,6 +41,7 @@ concurrency:

name: rcc


jobs:
rcc-smoke:
runs-on: ubuntu-latest
Expand All @@ -51,6 +60,38 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Update status for rcc
# FIXME: Wrap into action
if: github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check status of this workflow
state="pending"
sha=${{ inputs.ref }}
if [ -z "${sha}" ]; then
sha=${{ github.head_ref }}
fi
if [ -z "${sha}" ]; then
sha=${{ github.sha }}
fi
sha=$(git rev-parse ${sha})
html_url=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .html_url)
description="${{ github.workflow }} / ${{ github.job }}"
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${{ github.repository }}/statuses/${sha} \
-f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc"
shell: bash

- uses: ./.github/workflows/rate-limit
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -66,25 +107,29 @@ jobs:
cache-version: rcc-smoke-2
needs: check, website
# Beware of using dev pkgdown here, has brought in dev dependencies in the past
extra-packages: any::rcmdcheck r-lib/roxygen2 any::decor r-lib/styler pkgdown deps::.
extra-packages: any::rcmdcheck r-lib/roxygen2 any::decor r-lib/styler r-lib/pkgdown@f-readme-tweak deps::.

- name: Install package
run: |
R CMD INSTALL .
_R_SHLIB_STRIP_=true R CMD INSTALL .
shell: bash

- uses: ./.github/workflows/custom/after-install
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''

- id: versions-matrix
# Only run for pull requests if the base repo is different from the head repo, always run for other events
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
# Only run for pull requests if the base repo is different from the head repo, not for workflow_dispatch if not requested, always run for other events
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository) && (github.event_name != 'workflow_dispatch' || inputs.versions-matrix)
uses: ./.github/workflows/versions-matrix

- id: dep-suggests-matrix
# Not for workflow_dispatch if not requested, always run for other events
if: github.event_name != 'workflow_dispatch' || inputs.dep-suggests-matrix
uses: ./.github/workflows/dep-suggests-matrix

- uses: ./.github/workflows/update-snapshots
with:
base: ${{ inputs.ref || github.head_ref }}

- uses: ./.github/workflows/style

Expand Down Expand Up @@ -120,6 +165,46 @@ jobs:
name: rcc-smoke-sha
path: rcc-smoke-sha.txt

- name: Update status for rcc
# FIXME: Wrap into action
if: always() && github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check status of this workflow
if [ "${{ job.status }}" == "success" ]; then
state="success"
else
state="failure"
fi
sha=${{ steps.commit.outputs.sha }}
if [ -z "${sha}" ]; then
sha=${{ inputs.ref }}
fi
if [ -z "${sha}" ]; then
sha=${{ github.head_ref }}
fi
if [ -z "${sha}" ]; then
sha=${{ github.sha }}
fi
sha=$(git rev-parse ${sha})
html_url=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .html_url)
description="${{ github.workflow }} / ${{ github.job }}"
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${{ github.repository }}/statuses/${sha} \
-f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc"
shell: bash

rcc-smoke-check-matrix:
runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
install-r: false
cache-version: pkgdown-2
needs: website
extra-packages: pkgdown local::.
extra-packages: r-lib/pkgdown@f-readme-tweak local::.

- uses: ./.github/workflows/custom/after-install
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/update-snapshots/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ description: >
This action will run `testthat::test_local()` for tests that seem to use snapshots,
this is determined by reading and grepping the test files.
If the tests are failing, snapshots are updated, and a pull request is opened.
inputs:
base:
description: "The base branch to create the pull request against."
required: false
default: "main"

runs:
using: "composite"
Expand Down Expand Up @@ -67,8 +72,8 @@ runs:
id: cpr
uses: peter-evans/create-pull-request@v6
with:
base: ${{ github.head_ref }}
branch: snapshot-${{ github.ref_name }}-${{ github.job }}-${{ steps.matrix-desc.outputs.branch }}
base: ${{ inputs.base }}
branch: snapshot-${{ inputs.base }}-${{ github.job }}-${{ steps.matrix-desc.outputs.branch }}
delete-branch: true
title: "test: Snapshot updates for ${{ github.job }} (${{ steps.matrix-desc.outputs.text }})"
body: "Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action${{ github.event.number && format(' for #{0}', github.event.number) || '' }}."
Expand Down
3 changes: 1 addition & 2 deletions R/api-bump-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ bump_version <- function(
which = c("dev", "patch", "pre-minor", "minor", "pre-major", "major"),
...,
no_change_behavior = c("bump", "noop", "fail"),
check_default_branch = TRUE
) {
check_default_branch = TRUE) {
check_dots_empty()

which <- arg_match(which)
Expand Down

0 comments on commit 265e161

Please sign in to comment.