Skip to content

Commit

Permalink
Reproduce issue r-lib#614 with a copy of the package in a sub-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoporreca committed Sep 5, 2022
1 parent c5fb812 commit a4e0e1f
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ jobs:
with:
extra-packages: any::rcmdcheck
needs: check
working-directory: test_pkg_subdir

- uses: r-lib/actions/check-r-package@v2-branch
with:
check-dir: '"non-default-dir"'
upload-results: true
upload-snapshots: true
working-directory: test_pkg_subdir
13 changes: 13 additions & 0 deletions test_pkg_subdir/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
^pr-fetch$
^pr-push$
^run-rchk$
^setup-r$
^setup-pandoc$
^setup-tinytex$
^examples$
^LICENSE$
^.github$
^actions\.Rproj$
^\.Rproj\.user$
^Makefile$
^CITATION.cff$
3 changes: 3 additions & 0 deletions test_pkg_subdir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.Rproj.user
.Rhistory
13 changes: 13 additions & 0 deletions test_pkg_subdir/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: testpackage
Title: A Simple Test Description File to Test Packages
Version: 1.0.0
Authors@R:
c(person(given = "Jim",
family = "Hester",
role = c("aut", "cre"),
email = "james.hester@rstudio.com"))
Description: This is a simple package used to test the workflow files.
Imports: xml2, curl
Suggests: covr, knitr, rmarkdown, testthat
License: GPL (>= 2)
VignetteBuilder: knitr, rmarkdown
116 changes: 116 additions & 0 deletions test_pkg_subdir/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
CC0 1.0 Universal

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.

For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:

i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;

ii. moral rights retained by the original author(s) and/or performer(s);

iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;

iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;

v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;

vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and

vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.

b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.

c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.

d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.

For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>
1 change: 1 addition & 0 deletions test_pkg_subdir/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useDynLib(testpackage, .registration = TRUE)
9 changes: 9 additions & 0 deletions test_pkg_subdir/R/foo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_one <- function(x) {
curl::curl
xml2::read_xml
x + 1
}

times2 <- function(x) {
.Call(test_fun, as.integer(x)[1]);
}
111 changes: 111 additions & 0 deletions test_pkg_subdir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# GitHub Actions for the R language

[![R build status](https://github.com/r-lib/actions/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/actions/actions?workflow=R-CMD-check)
[![RStudio community](https://img.shields.io/badge/community-github--actions-blue?style=social&logo=rstudio&logoColor=75AADB)](https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions)

This repository stores [GitHub Actions](https://github.com/features/actions)
for R projects, which can be used to do a variety of CI tasks. It also has a
number of [example workflows](https://github.com/r-lib/actions/tree/v2/examples) which use
these actions.

## Getting started

See [this blog post](https://www.tidyverse.org/blog/2022/06/actions-2-0-0/) on the Tidyverse blog.

## Releases and tags

We use major version tags to mark breaking changes in these actions.
For the current version, please use the `v2` tag, e.g.:

```yaml
- uses: r-lib/actions/setup-r@v2
```
The `v2` tag occasionally changes, to introduce non-breaking fixes and
improvements. These changes use more fine-grained tags, e.g. `v2.0.1`.
You can refer to these as well in your workflow files if you need to.

## List of actions

1. [r-lib/actions/setup-r](https://github.com/r-lib/actions/tree/v2/setup-r) - Sets up [R](https://r-project.org)
1. [r-lib/actions/setup-r-dependencies](https://github.com/r-lib/actions/tree/v2/setup-r-dependencies) - Installs packages declared in `DESCRIPTION`
1. [r-lib/actions/setup-renv](https://github.com/r-lib/actions/tree/v2/setup-renv) - Installs packages from renv lockfile
1. [r-lib/actions/setup-pandoc](https://github.com/r-lib/actions/tree/v2/setup-pandoc) - Sets up [pandoc](https://pandoc.org/)
1. [r-lib/actions/setup-tinytex](https://github.com/r-lib/actions/tree/v2/setup-tinytex) - Sets up LaTeX with [tinytex](https://yihui.name/tinytex)
1. [r-lib/actions/check-r-package](https://github.com/r-lib/actions/tree/v2/check-r-package) - Runs `R CMD check` on an R package
1. [r-lib/actions/pr-fetch](https://github.com/r-lib/actions/tree/v2/pr-fetch) - Fetches changes of a PR associated with an event
1. [r-lib/actions/pr-push](https://github.com/r-lib/actions/tree/v2/pr-push) - Pushes changes to a PR associated with an event
1. [r-lib/actions/run-rchk](https://github.com/r-lib/actions/tree/v2/run-rchk) - Runs [rchk](https://github.com/kalibera/rchk) tests to detect memory protection errors in C source code

## What's new?

See the [`v2` release notes](https://github.com/r-lib/actions/releases/tag/v2).
These notes are kept current with the changes in `v2`.

## Examples

See the [r-lib/actions/examples](https://github.com/r-lib/actions/tree/v2/examples) directory
for a variety of example workflows using these actions.

## Where to find help

If your build fails, and you are unsure of why, here are some useful strategies for getting help.

1. Figure out what caused the error. Look for the _first_ time the word
'error' appears in the build log. Quite often errors at the end of the log are caused
by an earlier issue, so it is best to look for the root cause.
1. Take advantage of [GitHub's code search](https://github.com/search?q=path%3A.github%2Fworkflows) to find similar yaml files.
Use 'path:.github/workflows' to restrict your search to GitHub Action workflow files and also include additional terms specific to your problem.
e.g. If you need to figure out how to install geospatial libraries such as [gdal](https://gdal.org/), use a search like ['gdal path:.github/workflows'](https://github.com/search?q=gdal+path%3A.github%2Fworkflows).
If you want to restrict results only to GitHub Actions workflows that use R you can add search for ['"setup-r" path:.github/workflows](https://github.com/search?q=%22setup-r%22+path%3A.github%2Fworkflows)
1. Open an issue on [![RStudio
community](https://img.shields.io/badge/community-github--actions-blue?style=social&logo=rstudio&logoColor=75AADB)](https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions)
about your problem. Be sure to link to the workflow file you are using and a
failing build to help others help you.
1. If your issue seems related to GitHub Actions, but is not specific to R, open an
issue at the [GitHub Actions
Community](https://git.luolix.topmunity/t5/GitHub-Actions/bd-p/actions) page.
1. If you have done all of the above and are __absolutely__ sure there is a bug
in one of the R specific actions listed above, check if there is an open issue
about it [in this repo](https://github.com/r-lib/actions/issues). Look at the
pinned issues at the top first! We pin issues that affect many people, and the
issue discussions often contain workarounds.
1. Otherwise open a [new issue in this repo](https://github.com/r-lib/actions/issues/new/choose).

> If using a general search engine or GitHub search about your problem/idea, please note that content published prior to the Fall 2019 is probably outdated because the beta version of GitHub Actions was different. More recent posts or answers could be outdated too since GitHub Actions evolve, so refer to [GitHub Actions official docs](https://help.github.com/en/actions) in case of doubt (and to existing working workflows) and [GitHub changelog](https://github.blog/changelog/).

## Common questions

1. *Why are my builds with plots failing on macOS?*\
\
You need to install XQuartz to do plotting with the default quartz device on macOS. This can be done by adding the following to your workflow.
```yaml
- if: runner.os == 'macOS'
run: brew install --cask xquartz
```

1. *Why are my Windows builds failing with an error about `configure.ac` having CRLF line endings?*\
\
On Windows, when your repo is checked out using git, the line endings are automatically changed to CRLF. R's check process specifically checks if the `configure.ac` file has these line endings, and will error if it does. To avoid this, add a `.gitattributes` file to the top level of your package with the following to configure git to always use LF line endings for this file: \
`configure.ac text eol=lf`

1. *How can I customize an action to run R code?*\
\
The safest way is to add a `step` to your action, specifying `Rscript {0}` as the `shell` for that step. Here's an example from the [bookdown action](https://github.com/r-lib/actions/tree/v2-branch/examples#build-bookdown-site):
```yaml
- name: Build site
run: bookdown::render_book("index.Rmd", quiet = TRUE)
shell: Rscript {0}
```

## Additional resources

- [GitHub Actions for R](https://www.jimhester.com/talk/2020-rsc-github-actions/), Jim Hester's talk at rstudio::conf 2020. [Recording](https://resources.rstudio.com/rstudio-conf-2020/azure-pipelines-and-github-actions-jim-hester), [slidedeck](https://speakerdeck.com/jimhester/github-actions-for-r).
- [GitHub Actions advent calendar](https://www.edwardthomson.com/blog/github_actions_advent_calendar.html) a series of blogposts by Edward Thomson, one of the GitHub Actions product managers
highlighting features of GitHub Actions.
- [GitHub Actions with R](https://ropenscilabs.github.io/actions_sandbox/) - a short online book about using GitHub Actions with R, produced as part of the [rOpenSci OzUnconf](https://ozunconf19.ropensci.org/).
- [Awesome Actions](https://github.com/sdras/awesome-actions#awesome-actions---) - a curated list of custom actions. **Note** that many of these are from early in the GitHub Actions beta and may no longer work.

## License ![CC0 licensed](https://img.shields.io/github/license/r-lib/actions)

All examples in this repository are published with the [CC0](./LICENSE) license.
18 changes: 18 additions & 0 deletions test_pkg_subdir/src/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

#include <Rinternals.h>
#include <R_ext/Rdynload.h>

SEXP test_fun(SEXP arg) {
return ScalarInteger(INTEGER(arg)[0] * 2);
}

static const R_CallMethodDef callMethods[] = {
{ "test_fun", (DL_FUNC) test_fun, 1 },
{ NULL, NULL, 0 }
};

void R_init_testpackage(DllInfo *dll) {
R_registerRoutines(dll, NULL, callMethods, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
R_forceSymbols(dll, TRUE);
}
6 changes: 6 additions & 0 deletions test_pkg_subdir/tests/test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# artificial test failure
stopifnot(FALSE)

stopifnot(testpackage:::add_one(1) == 2)

stopifnot(testpackage:::times2(10) == 20L)
5 changes: 5 additions & 0 deletions test_pkg_subdir/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

library(testthat)
library(testpackage)

test_check("testpackage")
39 changes: 39 additions & 0 deletions test_pkg_subdir/tests/testthat/_snaps/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# snap

Code
mtcars
Output
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3
Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3
Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3
Cadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4
Lincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4
Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4
Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1
Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1
Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1
Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2
AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2
Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4
Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2
Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1
Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2
Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4
Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6
Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8
Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2

5 changes: 5 additions & 0 deletions test_pkg_subdir/tests/testthat/test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

test_that("snap", {
local_edition(3)
expect_snapshot(mtcars)
})
22 changes: 22 additions & 0 deletions test_pkg_subdir/vignettes/test.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: "Test vignette for GH Actions"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Test vignette for GH Actopns}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

Irure ad excepteur aliqua esse id sint ex aliquip laborum. Officia laborum ex cupidatat exercitation velit. Nisi elit incididunt nisi ullamco. Ut Lorem eiusmod anim ipsum dolore cupidatat officia non. Culpa voluptate consectetur in ullamco minim sit sunt. Ad aute laborum laborum cillum qui consequat proident sit ad incididunt. Enim nisi nulla aliquip anim fugiat deserunt aliqua aliqua sunt nisi commodo magna reprehenderit. Reprehenderit dolor sunt nulla mollit est magna exercitation dolore magna. Mollit qui labore tempor commodo veniam cupidatat esse irure nisi eiusmod qui dolore nisi.

```{r}
summary(mtcars)
```

0 comments on commit a4e0e1f

Please sign in to comment.