Skip to content

Commit 690bb8c

Browse files
ci: Use with-connect action for integration tests (#475)
1 parent e4d9a7a commit 690bb8c

20 files changed

+74
-700
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ This has some additional requirements.
1616
- You need a valid Connect license file (`.lic` file). Place it in the root of the repository as `connect-license.lic`.
1717
- You need Docker.
1818
- If you're running on an ARM (non-Intel) Mac, `export DOCKER_DEFAULT_PLATFORM=linux/amd64`
19-
- Run `connectapi:::build_test_env(connect_license_path = "connect-license.lic")` to set up the Connect processes in docker
20-
- By default, this will run against a contemporary version of Connect. To test against an older version, set the environment variable `CONNECT_VERSION` to something else and then run `build_test_env()`.
21-
- Set `CONNECTAPI_INTEGRATED=true` in the environment to enable running the integration tests (they're skipped by default).
22-
- Run them with `source("tests/test-integrated.R")`
19+
- Get the [with-connect](https://github.com/nealrichardson/with-connect/blob/dev/README.md) tool
20+
- Run them with `with-connect -e CONNECTAPI_INTEGRATED=true -- Rscript -e source("tests/test-integrated.R")`
21+
- Specify a different Connect version with the `--version` command-line argument to `with-connect`, e.g. `--version 2024.06.0`
2322

2423
## Fixing typos
2524

.github/RELEASE.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,19 @@ but with integration tests too
2626

2727
### Integration Tests
2828

29-
Integration tests are designed to run the `connectapi` package against the
30-
_actual_ latest version of Connect
29+
Integration tests are designed to run the `connectapi` package against a running instance of Connect
3130

32-
- the "test environment" stands up two Connect instances as docker images using
33-
the un-exported `build_test_env()` function
34-
- this [uses `docker compose`](../inst/ci/) to build an environment
35-
- we also use some ["hacky" utilities](../R/utils-ci.R) to build an initial user and API key for executing
3631
- tests are written in the `tests/integration` directory
3732
- Each file should be able to be executed independently
3833
- There are occasional dependencies _across tests_ within a file (executed linearly)
3934
- (I know, this is terrible... we made choices for reasons)
4035
- We fudge the clean line of unit tests in order to ensure that complex
4136
functionalities work as expected without too much time or work
42-
- bootstrapping the "integration test" execution happens in [the
43-
`test-integrated.R` script](../tests/test-integrated.R), and keys mostly on the
44-
`CONNECTAPI_INTEGRATED=true` environment variable
4537

46-
To run integration tests interactively / locally run the following:
47-
```
48-
connectapi:::build_test_env()
49-
readRenviron(".Renviron")
50-
51-
# or set this in .Renviron yourself
52-
Sys.setenv("CONNECTAPI_INTEGRATED"="true")
38+
To run integration tests interactively / locally, install the [with-connect](https://github.com/nealrichardson/with-connect/blob/dev/README.md) tool, then run:
5339

54-
# or run R CMD CHECK with that env var set, etc.
55-
source("tests/test-integrated.R")
5640
```
41+
with-connect -e CONNECTAPI_INTEGRATED=true -- Rscript -e source("tests/test-integrated.R")
42+
```
43+
44+
This requires a valid license file.

.github/local/mail.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/local/make-network.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/local/run_tests.R

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/local/test-connect-ci.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/local/test.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/integration-tests.yaml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,29 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18+
- "jammy" # As long as we're building on ubuntu 22.04, this will track the latest release
19+
- "2025.09.0" # jammy
1820
- "2025.03.0" # jammy
1921
- "2024.09.0" # jammy
2022
- "2024.03.0" # jammy
2123
- "2023.09.0" # jammy
2224
- "2023.03.0" # bionic
23-
- "2022.09.0" # bionic
24-
- "2022.03.2"
25-
- "2021.09.0"
26-
- "1.8.8.2"
25+
- "2022.10.0" # bionic
26+
name: Connect ${{ matrix.version }}
2727

2828
env:
29-
CONNECT_VERSION: ${{ matrix.version }}
3029
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
31-
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
32-
CONNECTAPI_INTEGRATED: true
3330

3431
steps:
3532
- uses: actions/checkout@v4
3633

37-
- uses: r-lib/actions/setup-pandoc@v2
38-
3934
- uses: r-lib/actions/setup-r@v2
4035
with:
4136
use-public-rspm: true
4237

4338
- uses: r-lib/actions/setup-r-dependencies@v2
4439
with:
45-
extra-packages: any::rcmdcheck, local::.
46-
needs: check
40+
extra-packages: local::.
4741

4842
- name: Session info
4943
run: |
@@ -52,24 +46,18 @@ jobs:
5246
sessioninfo::session_info(pkgs, include_base = TRUE)
5347
shell: Rscript {0}
5448

55-
- name: Set up license file
56-
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic
57-
58-
- name: Setup test environment
59-
run: |
60-
connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")
61-
shell: Rscript {0}
62-
63-
- uses: r-lib/actions/check-r-package@v2
64-
65-
- name: Show testthat output
66-
if: always()
67-
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
68-
shell: bash
69-
70-
- name: Upload check results
71-
if: failure()
72-
uses: actions/upload-artifact@main
49+
- name: Run integration tests
50+
uses: nealrichardson/with-connect@dev
51+
env:
52+
CONNECTAPI_INTEGRATED: "true"
7353
with:
74-
name: ${{ runner.os }}-${{ matrix.version }}-results
75-
path: check
54+
version: ${{ matrix.version }}
55+
license: ${{ secrets.CONNECT_LICENSE_FILE }}
56+
# TODO: rewrite tests to use CONNECT_* env vars directly
57+
command: |
58+
Rscript -e '
59+
Sys.setenv(
60+
TEST_1_SERVER=Sys.getenv("CONNECT_SERVER"),
61+
TEST_1_API_KEY=Sys.getenv("CONNECT_API_KEY")
62+
)
63+
source("tests/test-integrated.R")'

.github/workflows/pkgdown.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ jobs:
1818
runs-on: ubuntu-latest
1919
env:
2020
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21-
CONNECT_VERSION: 2024.03.0
22-
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
2321

2422
steps:
2523
- uses: actions/checkout@v4
@@ -35,16 +33,19 @@ jobs:
3533
extra-packages: any::pkgdown, local::.
3634
needs: website
3735

38-
- name: Set up license file
39-
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic
40-
41-
- name: Start Connect
42-
run: |
43-
Rscript -e 'connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")'
44-
4536
- name: Build site
46-
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
47-
shell: Rscript {0}
37+
uses: nealrichardson/with-connect@dev
38+
with:
39+
# Runs on the default version in the with-connect action
40+
license: ${{ secrets.CONNECT_LICENSE_FILE }}
41+
# TODO: rewrite tests to use CONNECT_* env vars directly
42+
command: |
43+
Rscript -e '
44+
Sys.setenv(
45+
TEST_1_SERVER=Sys.getenv("CONNECT_SERVER"),
46+
TEST_1_API_KEY=Sys.getenv("CONNECT_API_KEY")
47+
)
48+
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)'
4849
4950
- name: Deploy to GitHub pages 🚀
5051
if: github.event_name != 'pull_request'

.github/workflows/pr-commands.yaml

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,6 @@ on:
77
name: Commands
88

99
jobs:
10-
update_snapshot:
11-
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/snapshot') }}
12-
name: snapshot
13-
runs-on: ubuntu-latest
14-
env:
15-
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16-
CONNECT_VERSION: 2024.03.0
17-
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
18-
CONNECTAPI_INTEGRATED: true
19-
steps:
20-
- uses: actions/checkout@v4
21-
22-
- uses: r-lib/actions/setup-pandoc@v2
23-
24-
- uses: r-lib/actions/setup-r@v2
25-
with:
26-
use-public-rspm: true
27-
28-
- uses: r-lib/actions/setup-r-dependencies@v2
29-
with:
30-
extra-packages: any::covr, local::.
31-
needs: coverage
32-
33-
- name: Set up license file
34-
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic
35-
36-
- name: Setup test environment
37-
run: |
38-
connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")
39-
shell: Rscript {0}
40-
41-
- uses: r-lib/actions/check-r-package@v2
42-
43-
- name: Accept Snapshots
44-
run: |
45-
testthat::snapshot_accept(path = "tests/testthat")
46-
testthat::snapshot_accept(path = "tests/integrated")
47-
48-
- name: Commit results
49-
run: |
50-
set -xe
51-
git config --local user.name "$GITHUB_ACTOR"
52-
git config --local user.email "[email protected]"
53-
git commit tests/**/_snaps || echo "No changes to commit"
54-
55-
- uses: r-lib/actions/pr-push@v2
56-
with:
57-
repo-token: ${{ secrets.GITHUB_TOKEN }}
58-
5910
document:
6011
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
6112
name: document

0 commit comments

Comments
 (0)