Skip to content

Commit

Permalink
ci: Overwrite from actions-sync (#42)
Browse files Browse the repository at this point in the history
* ci: Overwrite from actions-sync

* ci: Explicit permissions
  • Loading branch information
krlmlr authored Nov 26, 2024
1 parent 277bea2 commit 1c5a44e
Show file tree
Hide file tree
Showing 26 changed files with 1,812 additions and 112 deletions.
146 changes: 146 additions & 0 deletions R-CMD-check-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# This workflow calls the GitHub API very frequently.
# Can't be run as part of commits
on:
schedule:
- cron: "5 0 * * *" # 05:00 UTC every day only run on main branch
push:
branches:
- "cran-*"
tags:
- "v*"

name: rcc dev

jobs:
matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

name: Collect deps

steps:
- uses: actions/checkout@v4

- uses: ./.github/workflows/rate-limit
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2

- id: set-matrix
uses: ./.github/workflows/dep-matrix

check-matrix:
runs-on: ubuntu-22.04
needs: matrix

name: Check deps

steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
R-CMD-check-base:
runs-on: ubuntu-22.04

name: base

# Begin custom: services
# End custom: services

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4

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

- uses: ./.github/workflows/install
with:
cache-version: rcc-dev-base-1
needs: check
extra-packages: "any::rcmdcheck any::remotes ."
token: ${{ secrets.GITHUB_TOKEN }}

- name: Session info
run: |
options(width = 100)
if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo")
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

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

- uses: ./.github/workflows/update-snapshots
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

- uses: ./.github/workflows/check
with:
results: ${{ matrix.package }}

R-CMD-check-dev:
needs:
- matrix
- R-CMD-check-base

runs-on: ubuntu-22.04

name: 'rcc-dev: ${{ matrix.package }}'

# Begin custom: services
# End custom: services

strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}

steps:
- uses: actions/checkout@v4

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

- uses: ./.github/workflows/install
with:
cache-version: rcc-dev-${{ matrix.package }}-1
needs: check
extra-packages: "any::rcmdcheck any::remotes ."
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dev version of ${{ matrix.package }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
remotes::install_dev("${{ matrix.package }}", "https://cloud.r-project.org", upgrade = "always")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo")
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

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

- uses: ./.github/workflows/update-snapshots
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

- uses: ./.github/workflows/check
with:
results: ${{ matrix.package }}
75 changes: 75 additions & 0 deletions R-CMD-check-status.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Workflow to update the status of a commit for the R-CMD-check workflow
# Necessary because remote PRs cannot update the status of the commit
on:
workflow_run:
workflows:
- rcc
types:
- requested
- completed

name: rcc-status

jobs:
rcc-status:
runs-on: ubuntu-24.04

name: "Update commit status"

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: |
set -x
if [ "${{ github.event.workflow_run.status }}" == "completed" ]; then
if [ "${{ github.event.workflow_run.conclusion }}" == "success" ]; then
state="success"
else
state="failure"
fi
# Read artifact ID
artifact_id=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts | jq -r '.artifacts[] | select(.name == "rcc-smoke-sha") | .id')
if [ -n "${artifact_id}" ]; then
# Download artifact
curl -L -o rcc-smoke-sha.zip \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${artifact_id}/zip
# Unzip artifact
unzip rcc-smoke-sha.zip
# Read artifact
sha=$(cat rcc-smoke-sha.txt)
# Clean up
rm rcc-smoke-sha.zip rcc-smoke-sha.txt
fi
else
state="pending"
fi
if [ -z "${sha}" ]; then
sha=${{ github.event.workflow_run.head_sha }}
fi
html_url=${{ github.event.workflow_run.html_url }}
description=${{ github.event.workflow_run.name }}
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
Loading

0 comments on commit 1c5a44e

Please sign in to comment.