Back to Skills

setup-github-actions-ci

pjt222
Updated 2 days ago
1 views
17
2
17
View on GitHub
Othergeneral

About

This skill sets up GitHub Actions CI/CD for R packages using r-lib/actions workflows. It configures multi-platform R CMD checks, test coverage reporting, and optional pkgdown site deployment. Use it when creating new R package CI/CD or adding these features to existing repositories.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-github-actions-ci

Copy and paste this command in Claude Code to install this skill

Documentation


name: setup-github-actions-ci description: > RパッケージのGitHub Actions CI/CDを設定する。複数プラットフォームでのR CMD check、 テストカバレッジレポート、pkgdownサイトのデプロイを含む。標準ワークフローに r-lib/actionsを使用。新規RパッケージのCI/CD設定、既存パッケージへのマルチ プラットフォームテスト追加、pkgdownサイトの自動デプロイ設定、またはリポジトリへの コードカバレッジレポート追加時に使用する。 locale: ja source_locale: en source_commit: 6f65f316 translator: claude-opus-4-6 translation_date: 2026-03-16 license: MIT allowed-tools: Read Write Edit Bash Grep Glob metadata: author: Philipp Thoss version: "1.0" domain: r-packages complexity: intermediate language: R tags: r, github-actions, ci-cd, testing, automation

RパッケージのGitHub Actions CI設定

GitHub Actionsを介した自動R CMD check、テストカバレッジ、ドキュメントデプロイを設定する。

使用タイミング

  • GitHubのRパッケージにCI/CDを設定する時
  • 既存パッケージにマルチプラットフォームテストを追加する時
  • pkgdownサイトの自動デプロイを設定する時
  • コードカバレッジレポートを追加する時

入力

  • 必須: 有効なDESCRIPTIONとテストを持つRパッケージ
  • 必須: GitHubリポジトリ(パブリックまたはプライベート)
  • 任意: pkgdownデプロイを含めるかどうか(デフォルト:いいえ)
  • 任意: カバレッジレポートを含めるかどうか(デフォルト:いいえ)

手順

ステップ1: R CMD Checkワークフローの作成

.github/workflows/R-CMD-check.yamlを作成する:

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

name: R-CMD-check

permissions: read-all

jobs:
  R-CMD-check:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }} (${{ matrix.config.r }})

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: macos-latest, r: 'release'}
          - {os: windows-latest, r: 'release'}
          - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
          - {os: ubuntu-latest, r: 'release'}
          - {os: ubuntu-latest, r: 'oldrel-1'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes

    steps:
      - uses: actions/checkout@v4

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

      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.r }}
          http-user-agent: ${{ matrix.config.http-user-agent }}
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::rcmdcheck
          needs: check

      - uses: r-lib/actions/check-r-package@v2
        with:
          upload-snapshots: true
          build_args: 'c("--no-manual", "--compact-vignettes=gs+qpdf")'

期待結果: ワークフローファイル.github/workflows/R-CMD-check.yamlが、release、devel、oldrelをカバーするマルチプラットフォームマトリクス(macOS、Windows、Ubuntu)で作成される。

失敗時: .github/workflows/ディレクトリが存在しない場合はmkdir -p .github/workflowsで作成する。YAML構文をYAMLリンターで確認する。

ステップ2: テストカバレッジワークフローの作成(任意)

.github/workflows/test-coverage.yamlを作成する:

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

name: test-coverage

permissions: read-all

jobs:
  test-coverage:
    runs-on: ubuntu-latest

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v4

      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::covr, any::xml2
          needs: coverage

      - name: Test coverage
        run: |
          cov <- covr::package_coverage(
            quiet = FALSE,
            clean = FALSE,
            install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
          )
          covr::to_cobertura(cov)
        shell: Rscript {0}

      - uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
          file: ./cobertura.xml
          plugin: noop
          token: ${{ secrets.CODECOV_TOKEN }}

期待結果: ワークフローファイル.github/workflows/test-coverage.yamlが作成される。カバレッジレポートが各プッシュとPRでCodecovにアップロードされる。

失敗時: Codecovのアップロードが失敗する場合、リポジトリ設定でCODECOV_TOKENシークレットが設定されているか確認する。パブリックリポジトリの場合、トークンは任意の場合がある。

ステップ3: pkgdownデプロイワークフローの作成(任意)

.github/workflows/pkgdown.yamlを作成する:

on:
  push:
    branches: [main, master]
  release:
    types: [published]
  workflow_dispatch:

name: pkgdown

permissions:
  contents: write
  pages: write

jobs:
  pkgdown:
    runs-on: ubuntu-latest

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v4

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

      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::pkgdown, local::.
          needs: website

      - name: Build site
        run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
        shell: Rscript {0}

      - name: Deploy to GitHub pages
        if: github.event_name != 'pull_request'
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          clean: false
          branch: gh-pages
          folder: docs

期待結果: ワークフローファイル.github/workflows/pkgdown.yamlが作成される。mainへのプッシュまたはリリース時にサイトがビルドされてgh-pagesブランチにデプロイされる。

失敗時: デプロイが失敗する場合、リポジトリにcontents: write権限が有効になっているか確認する。_pkgdown.ymldevelopment: mode: releaseが設定されているか確認する。

ステップ4: READMEへのステータスバッジの追加

README.mdに追加する:

[![R-CMD-check](https://github.com/USERNAME/REPO/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/USERNAME/REPO/actions/workflows/R-CMD-check.yaml)

期待結果: READMEに各ワークフロー実行後に自動更新されるライブCIステータスバッジが表示される。

失敗時: バッジが「ステータスなし」を表示する場合、バッジURLのワークフローファイル名が実際のファイルと一致しているか確認する。最初のワークフロー実行をトリガーするためにコミットをプッシュする。

ステップ5: GitHubリポジトリ設定の構成

  1. pkgdownを使用する場合はGitHub Pagesを有効化する(設定 > Pages)でgh-pagesブランチを指定
  2. カバレッジレポートを使用する場合はCODECOV_TOKENシークレットを追加する
  3. GITHUB_TOKENに適切な権限があることを確認する

期待結果: pkgdownデプロイ用にGitHub Pagesが設定される。必要なシークレットが設定される。トークンの権限がワークフローに対して十分である。

失敗時: Pagesデプロイが失敗する場合、設定 > Pagesでソースがgh-pagesブランチに設定されているか確認する。シークレットが欠如している場合は設定 > シークレットと変数 > Actionsで追加する。

ステップ6: プッシュと確認

git add .github/
git commit -m "Add GitHub Actions CI workflows"
git push

GitHubのActionsタブでワークフローが正常に実行されることを確認する。

期待結果: GitHubのActionsタブですべてのジョブに緑のチェックマークが表示される。ワークフローがプッシュとPRイベントの両方でトリガーされる。

失敗時: Actionsタブのワークフローログを確認する。一般的な問題:システム依存関係の欠如(extra-packagesに追加)、ビネットのビルド失敗(pandocセットアップステップが存在するか確認)、YAMLの構文エラー。

バリデーション

  • R CMD checkがすべてのマトリクスプラットフォームでパスする
  • カバレッジレポートが生成される(設定した場合)
  • pkgdownサイトがデプロイされる(設定した場合)
  • READMEにステータスバッジが表示される
  • ワークフローがプッシュとPRの両方でトリガーされる

よくある落とし穴

  • permissionsの欠如: GitHub Actionsは明示的な権限を要求するようになった。最低限permissions: read-allを追加する
  • システム依存関係: 一部のRパッケージはシステムライブラリを必要とする。ほとんどのケースを処理するr-lib/actions/setup-r-dependenciesを使用する
  • pandocなしのビネット: 常にr-lib/actions/setup-pandoc@v2を含める
  • pkgdownの開発モード: GitHub Pages用に_pkgdown.ymldevelopment: mode: releaseを確認する
  • キャッシュの問題: r-lib/actions/setup-r-dependenciesがキャッシュを自動的に処理する

関連スキル

  • create-r-package - CIワークフローを含む初期パッケージセットアップ
  • build-pkgdown-site - 詳細なpkgdown設定
  • submit-to-cran - CIチェックはCRANの期待値を反映すべき
  • release-package-version - リリース時にデプロイをトリガーする

GitHub Repository

pjt222/agent-almanac
Path: i18n/ja/skills/setup-github-actions-ci
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

llamaguard

Other

LlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.

View skill

cost-optimization

Other

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

View skill

quantizing-models-bitsandbytes

Other

This skill quantizes LLMs to 8-bit or 4-bit precision using bitsandbytes, achieving 50-75% memory reduction with minimal accuracy loss. It's ideal for running larger models on limited GPU memory or accelerating inference, supporting formats like INT8, NF4, and FP4. The skill integrates with HuggingFace Transformers and enables QLoRA training and 8-bit optimizers.

View skill

dispatching-parallel-agents

Other

This Claude Skill dispatches multiple agents to investigate and fix 3+ independent problems concurrently. It is designed for scenarios involving unrelated failures that can be resolved without shared state or dependencies. The core capability is parallel problem-solving, assigning one agent per independent problem domain to maximize efficiency.

View skill