Skip to content

Commit

Permalink
ci: Updates from duckdb
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Oct 27, 2024
1 parent fee9d03 commit 7c40bab
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 9 deletions.
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
92 changes: 88 additions & 4 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 Down Expand Up @@ -51,6 +59,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 @@ -70,21 +110,25 @@ jobs:

- 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 +164,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
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

0 comments on commit 7c40bab

Please sign in to comment.