From f6d5dcce5493333959877c1d075ec76a1c57da7b Mon Sep 17 00:00:00 2001 From: Luke Zappia Date: Fri, 4 Oct 2024 16:44:18 +0200 Subject: [PATCH] Add GitHub actions CI (#11) * Add standard R-CMD-check action * Add pr-commands action * Add lint action * Add check badge to README * update changelog --------- Co-authored-by: Robrecht Cannoodt --- .Rbuildignore | 1 + .github/.gitignore | 1 + .github/workflows/R-CMD-check.yaml | 52 ++++++++++++++++++ .github/workflows/lint.yaml | 34 ++++++++++++ .github/workflows/pr-commands.yaml | 85 ++++++++++++++++++++++++++++++ CHANGELOG.md | 5 ++ README.md | 19 ++++--- README.qmd | 4 ++ 8 files changed, 194 insertions(+), 7 deletions(-) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/R-CMD-check.yaml create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/pr-commands.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 279117a..fb7695e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,6 +3,7 @@ ^LICENSE\.md$ ^experiments$ ^\.lintr$ +^\.github$ ^CHANGELOG\.md$ ^README\.qmd$ ^docs$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..6248078 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,52 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main] + pull_request: + branches: [main] + +name: R-CMD-check.yaml + +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")' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..52cceba --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,34 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main] + pull_request: + branches: [main] + +name: lint.yaml + +permissions: read-all + +jobs: + lint: + 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::lintr, local::. + needs: lint + + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..2edd93f --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,85 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + issue_comment: + types: [created] + +name: pr-commands.yaml + +permissions: read-all + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7509f60..17bbc0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ * Refactored the internal class data structures for better modularity and extensibility (PR #8). +* Added GitHub actions to the project (PR #11): + - Standard R-CMD-check workflow. + - Linting action. + - Commands for roxygenizing (`/document`) and restyling the source code (`/style`). + # laminr v0.0.1 Initial POC implementation of the LaminDB API client for R. diff --git a/README.md b/README.md index b46a090..a7d5a2a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # LaminDB interface in R + + +[![R-CMD-check](https://github.com/laminlabs/laminr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/laminlabs/laminr/actions/workflows/R-CMD-check.yaml) + + This package provides an interface to the LaminDB database. It allows you to query the database and download data from it. @@ -201,8 +206,8 @@ artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") artifact ``` - - Inherits from: + + Inherits from: Public: _accessor: active binding _action_targets: active binding @@ -309,7 +314,7 @@ artifact$storage Warning: Data is missing expected fields: run_id, created_by_id - + Inherits from: Public: _previous_runs: active binding @@ -337,7 +342,7 @@ artifact$storage artifact$created_by ``` - + Inherits from: Public: created_artifacts: active binding @@ -367,7 +372,7 @@ artifact$experimental_factors Data is missing expected fields: run_id, source_id, created_by_id [[1]] - + Inherits from: Public: _previous_runs: active binding @@ -399,7 +404,7 @@ artifact$experimental_factors get_value: function (key) [[2]] - + Inherits from: Public: _previous_runs: active binding @@ -431,7 +436,7 @@ artifact$experimental_factors get_value: function (key) [[3]] - + Inherits from: Public: _previous_runs: active binding diff --git a/README.qmd b/README.qmd index fc9740e..7d7a267 100644 --- a/README.qmd +++ b/README.qmd @@ -3,6 +3,10 @@ title: LaminDB interface in R format: gfm --- + +[![R-CMD-check](https://github.com/laminlabs/laminr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/laminlabs/laminr/actions/workflows/R-CMD-check.yaml) + + This package provides an interface to the LaminDB database. It allows you to query the database and download data from it. ## Installation