Skip to content

Commit

Permalink
[ci] Move CI to GitHub Actions (fixes #286) (#287)
Browse files Browse the repository at this point in the history
* [ci] Move CI to GitHub Actions (fixes #286)

* fixing OS

* shell env vars

* missing quotes

* comments

* pandoc

* pdflatex

* fix NOTEs about unrecognized files

* weird linux stuff I h8 the tidyverse

* better mirror

* use test.sh

* unnecessary installs

* better path

* Update .github/workflows/ci.yml

* misc changes

* errors are bad

* add pkgdown

* poppin

* I h8 LaTeX

* revert tinytex

* stuff

* more stuff

* explicit exit

* fix return codes

* fix pandoc stuff

* fix masking

* remove commented-out stuff

* NOT_CRAN

* just test on r-release

* just test oon r-release

* more cleanup

* simpler config

* Update CONTRIBUTING.md

* remove some installs
  • Loading branch information
jameslamb committed Nov 28, 2020
1 parent 1d5a01c commit 96ac2f1
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 42 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
@@ -1,7 +1,10 @@
# Files currently checked into the repo
^.*\.ci
^.*\.github
^docs$
^_pkgdown\.yml$
^pkgdown$
^smoke_tests
^cran-comments\.md$
^CODE_OF_CONDUCT\.md$
^LICENSE\.MD$
Expand Down Expand Up @@ -64,4 +67,3 @@ vignettes/*\.pdf
# Stuff
.Rbuildignore
.*\.gitkeep

22 changes: 22 additions & 0 deletions .github/setup.sh
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

if [[ "${OS_NAME}" == "ubuntu-latest" ]]; then
sudo apt-get update
sudo apt-get install \
--no-install-recommends \
-y \
--allow-downgrades \
libcurl4-openssl-dev \
libfribidi-dev \
libharfbuzz-dev \
curl \
|| exit -1
fi

Rscript -e "
options(install.packages.check.source = 'no');
install.packages('remotes', repos = 'https://cran.r-project.org')
remotes::install_deps(dependencies = TRUE)
"
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,47 @@
name: Tests

on: [push]

jobs:
test:
name: ${{ matrix.os }} (R ${{ matrix.r-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
r-version: 'release'
- os: macos-latest
r-version: 'release'
steps:
- name: checkout repository
uses: actions/checkout@v2.3.4
with:
fetch-depth: 1
- name: set up R
uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.r-version }}
- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-tinytex@v1
- name: set up dependencies
shell: bash
env:
OS_NAME: ${{ matrix.os }}
run: $GITHUB_WORKSPACE/.github/setup.sh
- name: run tests
shell: bash
run: $GITHUB_WORKSPACE/test.sh
- name: upload coverage
if: ${{ matrix.os == 'macos-latest' && matrix.r-version == 'release' }}
shell: Rscript {0}
run: covr::codecov()
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
all-successful:
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Note that all tests succeeded
run: echo "🎉"
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -244,7 +244,7 @@ All comments should be above code, not beside it.
***
## Running Tests Locally <a name="testing"></a>

We use Travis CI to automatically run unit tests and a serious of other automated checks on every PR commit and merge to `main`. Every `pkgnet` release also goes through a battery of automated tests run on CRAN before becoming officially available through CRAN.
We use GitHub Actions to automatically run unit tests and a series of other automated checks on every PR commit and merge to `main`. Every `pkgnet` release also goes through a battery of automated tests run on CRAN before becoming officially available through CRAN.

However, these options can lengthen your testing cycle and make the process of contributing tedious. If you wish to run tests locally on whatever machine you are developing `pkgnet` code on, run the following from the repo root:

Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Expand Up @@ -31,6 +31,7 @@ Imports:
visNetwork
Suggests:
ggplot2,
pkgdown,
testthat,
webshot,
withr
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# pkgnet <img src="man/figures/logo.png" align="right" alt="" width="120" />

[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version-last-release/pkgnet)](https://cran.r-project.org/package=pkgnet) [![CRAN\_Download\_Badge](https://cranlogs.r-pkg.org/badges/grand-total/pkgnet)](https://cran.r-project.org/package=pkgnet) [![Build Status](https://img.shields.io/travis/uptake/pkgnet.svg?label=build&logo=travis&branch=main)](https://travis-ci.org/uptake/pkgnet)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version-last-release/pkgnet)](https://cran.r-project.org/package=pkgnet) [![CRAN\_Download\_Badge](https://cranlogs.r-pkg.org/badges/grand-total/pkgnet)](https://cran.r-project.org/package=pkgnet) [![GitHub Actions Build Status](https://github.com/uptake/pkgnet/workflows/Tests/badge.svg?branch=main)](https://github.com/uptake/pkgnet/actions?query=workflow%3ATests+branch%3Amain)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/github/uptake/pkgnet?branch=main&svg=true)](https://ci.appveyor.com/project/jameslamb/pkgnet)
[![codecov](https://codecov.io/gh/uptake/pkgnet/branch/main/graph/badge.svg)](https://codecov.io/gh/uptake/pkgnet)
[![Lifecycle badge](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/)
Expand Down
42 changes: 36 additions & 6 deletions test.sh
@@ -1,15 +1,45 @@
#!/bin/bash

rm *.tar.gz
rm ~/thing.txt
R CMD BUILD .
set -e pipefail

rm -f *.tar.gz
R CMD build .

# Work outside of the source directory to avoid false
# positives (i.e. test the tarball in isolation)
mkdir -p ~/pkgnet_test_dir
cp *.tar.gz ~/pkgnet_test_dir

export _R_CHECK_CRAN_INCOMING_=false
pushd ~/pkgnet_test_dir
R CMD CHECK *.tar.gz --as-cran
cat ~/thing.txt
popd
R CMD check *.tar.gz --as-cran || exit 1

LOG_FILE_NAME="pkgnet.Rcheck/00check.log"

echo ""
echo "----- R CMD check logs -----"
echo ""
cat pkgnet.Rcheck/00check.log

echo ""
echo "----- test outputs -----"
echo ""
cat pkgnet.Rcheck/tests/testthat.Rout

if grep -q -R "WARNING" "$LOG_FILE_NAME"; then
echo "WARNINGS have been found by R CMD check!"
exit 1
fi

ALLOWED_CHECK_NOTES=0
NUM_CHECK_NOTES=$(
cat ${LOG_FILE_NAME} \
| grep -e '^Status: .* NOTE.*' \
| sed 's/[^0-9]*//g'
)
if [[ ${NUM_CHECK_NOTES} -gt ${ALLOWED_CHECK_NOTES} ]]; then
echo "Found ${NUM_CHECK_NOTES} NOTEs from R CMD check. Only ${ALLOWED_CHECK_NOTES} are allowed"
exit 1
fi

popd || exit 0
8 changes: 4 additions & 4 deletions tests/testthat.R
Expand Up @@ -9,13 +9,13 @@ Sys.setenv("R_TESTS" = "")


####### TESTING ON vs. OFF CRAN #############
# Due to complications on CRAN with handling of temporary packages during testing, TRAVIS
# Due to complications on CRAN with handling of temporary packages during testing, continuous integration (CI)
# and local testing will remain the main test processes for pkgnet.
# See https://github.com/uptake/pkgnet/issues/160 for details on this decision.

cat("testthat.R | NOT_CRAN =", Sys.getenv("NOT_CRAN"), "\n")
if(identical(Sys.getenv("NOT_CRAN"), "true")){
######## TRAVIS and LOCAL TEST PROCEDURE #############
######## CI and LOCAL TEST PROCEDURE #############

# Check if setup and helper funs have been run.
# If in R CMD CHECK, they may not have been run yet.
Expand All @@ -26,7 +26,7 @@ if(identical(Sys.getenv("NOT_CRAN"), "true")){
library(pkgnet)
## ******************************************************************************************
## THIS IS THIS SAME CONTENT as setup_setTestEnv.R but neccessary to paste here due to
## travis checks.
## CI checks.
## ******************************************************************************************

# [DEBUG] write("PKGNET_REBUILD triggered", file = "~/thing.txt", append = TRUE)
Expand Down Expand Up @@ -70,7 +70,7 @@ if(identical(Sys.getenv("NOT_CRAN"), "true")){

## ******************************************************************************************
## THIS IS THIS SAME CONTENT as teardown_setTestEnv.R but neccessary to paste here due to
## travis checks.
## CI checks.
## ******************************************************************************************

# [DEBUG] write("PKGNET_REBUILD tear-down triggered", file = "~/thing.txt", append = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/setup-setTestEnv.R
Expand Up @@ -4,7 +4,7 @@

cat("setup-setTestEnv.R | NOT_CRAN =", Sys.getenv("NOT_CRAN"), "\n")
if(identical(Sys.getenv("NOT_CRAN"), "true")){
######## TRAVIS and LOCAL TEST PROCEDURE #############
######## CI and LOCAL TEST PROCEDURE #############

# record original libpaths in order to reset later.
# This should be unnecessary since tests are conducted within a seperate enviornment.
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-AbstractPackageReporter.R
Expand Up @@ -67,7 +67,9 @@ test_that(".is.PackageReporter correctly identifies package reporters", {
expect_true(pkgnet:::.is.PackageReporter(DependencyReporter$new()))
expect_true(pkgnet:::.is.PackageReporter(FunctionReporter$new()))
expect_true(pkgnet:::.is.PackageReporter(InheritanceReporter$new()))
expect_true(pkgnet:::.is.PackageReporter(SummaryReporter$new()))

# using :: to avoid masking by testthat::SummaryReporter
expect_true(pkgnet:::.is.PackageReporter(pkgnet::SummaryReporter$new()))

DependencyTabloid <- R6::R6Class(
classname = "DependencyTabloid"
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-CreatePackageVignette.R
Expand Up @@ -100,10 +100,11 @@ test_that("Test that CreatePackageVignette runs end-to-end with non-default repo
)
outputPath <- tempfile(pattern = "vignette", fileext = ".html")

# using :: to avoid masking by testthat::SummaryReporter
expect_true({
CreatePackageVignette(pkg = pkgPath
, pkg_reporters = list(
SummaryReporter$new()
pkgnet::SummaryReporter$new()
, DependencyReporter$new()
)
, vignette_path = vignettePath
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-PackageReport.R
Expand Up @@ -87,7 +87,7 @@ test_that('PackageReport works with pkg_path', {
)
reporterObj$DependencyReporter <- DependencyReporter$new()
expect_true(reporterObj$pkg_path == MILNE_PKG_PATH)
# The below test fails on macOS Travis for some mysterious reason.
# The below test fails on macOS CI for some mysterious reason.
#expect_true(reporterObj$DependencyReporter$.__enclos_env__$private$pkg_path == MILNE_PKG_PATH)

})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-cran-true.R
@@ -1,5 +1,5 @@
context("always true for cran")
# Due to complications on CRAN with handling of temporary packages during testing, TRAVIS
# Due to complications on CRAN with handling of temporary packages during testing, CI
# and local testing will remain the main test processes for pkgnet.
# See https://github.com/uptake/pkgnet/issues/160 for details on this decision.

Expand Down

0 comments on commit 96ac2f1

Please sign in to comment.