Skip to content

Commit

Permalink
ci: switch to GitHub Actions
Browse files Browse the repository at this point in the history
With the go.mod update in this series, building pkgr on Drone is now
failing with several error messages that say

  //go:build comment without // +build comment

Based on a quick search, it seems like a bug with Go 1.16 (see
golang's issue 51436).  That lines up with the Go version we pull in
to build the binary and the Go version bundled with the r-dev-ci
images.

We were planning to switch to GitHub Actions soon, but, with the above
Drone error, it makes sense to do with this series.

The Drone build primarily tested on r-dev-ci:4.1.0.  The exceptions
were

 * r-dev-ci:4.0.5 for the mixed-source tests

 * r-dev-ci-mpn-4.1:2022-02-11 and r-dev-ci-mpn-4.1:cran-latest for
   the renv library checks

For the first point, using 4.0.5 is no longer necessary now that
TestMixedSource generates its own repo.

Under GitHub Actions, handle the 'renv vs no renv' by setting up two
different jobs, one with a system-wide renv installation and one
without.  Unlike Drone, this leaves out testing an renv version before
0.15 [*], which should be okay given the renv 0.15 release is now over
two years old.

Note that the library for renv is set up via Rprofile.site rather than
communicated through an environment variable (e.g., R_LIBS_USER or
R_LIBS_SITE) because getRenvLibrary uses RunRscriptWithArgs, which
intentionally discards these.  (getRenvLibrary should probably be
adjusted to avoid that behavior.)

For the OS, hold off on adding a job for the latest Ubuntu because
that triggers several 'pkgr install' tests to fail due to a fansi
build error.

[*] See 0a4a8ee (ci: test configlib and integration_tests/library with
    system renv, 2022-03-08) and f5c120d (config: invoke renv to
    discover library path, 2022-01-21) for why testing an renv version
    before 0.15 was of interest.
  • Loading branch information
kyleam committed Aug 13, 2024
1 parent edf5d91 commit 35eb4df
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 296 deletions.
296 changes: 0 additions & 296 deletions .drone.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI
on:
push:
branches:
- main
- 'scratch/**'
tags:
- 'v*'
pull_request:

jobs:
check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} / go ${{ matrix.config.go }} / R ${{ matrix.config.r }} ${{ matrix.config.renv && 'renv' || '' }}
strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-20.04
go: 1.21.x
r: 4.2.3
renv: false
- os: ubuntu-20.04
go: stable
r: 4.3.1
renv: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.config.go }}
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
- name: Install other system dependencies
shell: bash
run: |
sudo DEBIAN_FRONTEND=noninteractive \
apt-get install -y libcurl4-openssl-dev
- name: Disable R_LIBS_USER
shell: bash
run: echo 'R_LIBS_USER=:' >>"$GITHUB_ENV"
- name: Adjust Rprofile.site
if: matrix.config.renv
shell: sudo Rscript {0}
run: |
dir.create("/opt/rpkgs")
cat(
'\n\n.libPaths("/opt/rpkgs")\n',
sep = "",
file = file.path(R.home("etc"), "Rprofile.site"),
append = TRUE
)
- name: Install renv system-wide
if: matrix.config.renv
shell: sudo Rscript {0}
run: install.packages("renv", repos = "https://cran.rstudio.com")
- name: Build
shell: bash
run: go get -t ./... && go build ./...
- name: Unit tests
shell: bash
run: ./scripts/run-unit-tests
env:
PKGR_TESTS_SYS_RENV: ${{ matrix.config.renv && '1' || '' }}
- name: Integration tests
shell: bash
run: ./scripts/run-integration-tests
env:
PKGR_TESTS_SYS_RENV: ${{ matrix.config.renv && '1' || '' }}
release:
if: github.ref_type == 'tag'
name: Make release
needs: check
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
workdir: cmd/pkgr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 35eb4df

Please sign in to comment.