Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rSharp-based reusable workflows #33

Merged
merged 8 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/R-CMD-check-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples

on:
workflow_call:

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: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}

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")'
error-on: 'c("error")'
Comment on lines +43 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should add --no-vignettes to the check args?
args: c("--no-manual", "--as-cran", "--no-vignettes")
Otherwise all vignettes outputs are created twice: first during the check step, and then during the build step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends if we want to make vignettes available for the users directly from R (with vignette(...)) or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this.
If the vignettes are built and delivered as part of the package: they can be accessed via vignette(..).. or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if they are not build during this process, they will not be available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, I think we should stick with the default behavior (this is the default from r-lib repo)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have created a separate issue for this: #34


- name: Build package
if: ${{ success() }}
run: |
output_dir <- file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "built_package")
dir.create(output_dir)
devtools::build(binary = TRUE, path = output_dir)
shell: Rscript {0}

- name: Get package package and R versions and store in environment
run: |
echo "PKG_VERSION=$(Rscript -e 'desc::desc_get_version()')" >> $GITHUB_ENV
echo "R_VERSION=$(Rscript -e 'cat(R.version$major, R.version$minor, sep = ".")')" >> $GITHUB_ENV
shell: bash

- name: Upload built package
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: ospsuite-v${{ env.PKG_VERSION }}-${{runner.os}}-r_${{ env.R_VERSION }}
path: ${{ runner.temp }}/built_package/*
64 changes: 64 additions & 0 deletions .github/workflows/bump_dev_version_tag_branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This reusable workflow will, if triggered by a merge:
# - Bump version if the current version is development (x.y.z.9000+)
# - Tag the target branch with version number
name: bump-dev-version

on:
workflow_call:
inputs:
app-id:
type: string
required: true
secrets:
private-key:
required: true

jobs:
bump-dev-version:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions: write-all
steps:

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ secrets.private-key }}

- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

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

- name: Install packages
run: |
install.packages("usethis")
shell: Rscript {0}

- name: Change DESCRIPTION file
run: |
if(usethis:::is_dev_version()){
desc::desc_set_version(version = usethis:::bump_version()[["dev"]])
}
shell: Rscript {0}

- name: Get package version from DESCRIPTION file and set as environment variable
run: |
echo "PKG_VERSION=$(Rscript -e 'desc::desc_get_version()')" >> $GITHUB_ENV
shell: bash

- uses: EndBug/add-and-commit@v9
if: ${{ success() }}
with:
message: '🤖 Bump version. [skip actions]'
default_author: github_actions
add: 'DESCRIPTION'
tag: 'v${{ env.PKG_VERSION }}'
File renamed without changes.
44 changes: 44 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples

on:
workflow_call:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
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.5.0
with:
clean: false
branch: gh-pages
folder: docs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ on:
default: '0.9.2'
extra-packages:
type: string
secrets:
CODECOV_TOKEN:
description: 'Token for codecov.io'
required: false

name: test-pkg-and-coverage

Expand Down Expand Up @@ -52,8 +48,6 @@ jobs:
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples

on:
workflow_call:

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
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package