Skip to content
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
7 changes: 3 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ This has some additional requirements.
- You need a valid Connect license file (`.lic` file). Place it in the root of the repository as `connect-license.lic`.
- You need Docker.
- If you're running on an ARM (non-Intel) Mac, `export DOCKER_DEFAULT_PLATFORM=linux/amd64`
- Run `connectapi:::build_test_env(connect_license_path = "connect-license.lic")` to set up the Connect processes in docker
- 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()`.
- Set `CONNECTAPI_INTEGRATED=true` in the environment to enable running the integration tests (they're skipped by default).
- Run them with `source("tests/test-integrated.R")`
- Get the [with-connect](https://github.com/nealrichardson/with-connect/blob/dev/README.md) tool
Copy link
Collaborator

Choose a reason for hiding this comment

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

🥳

- Run them with `with-connect -e CONNECTAPI_INTEGRATED=true -- Rscript -e source("tests/test-integrated.R")`
- Specify a different Connect version with the `--version` command-line argument to `with-connect`, e.g. `--version 2024.06.0`

## Fixing typos

Expand Down
24 changes: 6 additions & 18 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,19 @@ but with integration tests too

### Integration Tests

Integration tests are designed to run the `connectapi` package against the
_actual_ latest version of Connect
Integration tests are designed to run the `connectapi` package against a running instance of Connect

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

To run integration tests interactively / locally run the following:
```
connectapi:::build_test_env()
readRenviron(".Renviron")

# or set this in .Renviron yourself
Sys.setenv("CONNECTAPI_INTEGRATED"="true")
To run integration tests interactively / locally, install the [with-connect](https://github.com/nealrichardson/with-connect/blob/dev/README.md) tool, then run:

# or run R CMD CHECK with that env var set, etc.
source("tests/test-integrated.R")
```
with-connect -e CONNECTAPI_INTEGRATED=true -- Rscript -e source("tests/test-integrated.R")
```

This requires a valid license file.
32 changes: 0 additions & 32 deletions .github/local/mail.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/local/make-network.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/local/run_tests.R

This file was deleted.

19 changes: 0 additions & 19 deletions .github/local/test-connect-ci.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/local/test.yml

This file was deleted.

50 changes: 19 additions & 31 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,29 @@ jobs:
fail-fast: false
matrix:
version:
- "jammy" # As long as we're building on ubuntu 22.04, this will track the latest release
- "2025.09.0" # jammy
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can also add "latest" here and that will solve #240, if we want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, latest doesn't get updated! It points at 2022.08.0. But jammy tracks the most recent release. I thought we had a nightly container build but I guess not. Until then, at least jammy will make sure we have the latest release in the matrix.

- "2025.03.0" # jammy
- "2024.09.0" # jammy
- "2024.03.0" # jammy
- "2023.09.0" # jammy
- "2023.03.0" # bionic
- "2022.09.0" # bionic
- "2022.03.2"
- "2021.09.0"
- "1.8.8.2"
- "2022.10.0" # bionic
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because with-connect relies on the bootstrap endpoint to set up the first user, this is now the minimum version we can test. It's 3 years ago though, so I think that's fine.

name: Connect ${{ matrix.version }}

env:
CONNECT_VERSION: ${{ matrix.version }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
CONNECTAPI_INTEGRATED: true

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::rcmdcheck, local::.
needs: check
extra-packages: local::.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't need rcmdcheck because we're just invoking the test file. We don't need to do R CMD check here, we do that in the other jobs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for cleaning this up


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

- name: Set up license file
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic

- name: Setup test environment
run: |
connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- name: Run integration tests
uses: nealrichardson/with-connect@dev
env:
CONNECTAPI_INTEGRATED: "true"
with:
name: ${{ runner.os }}-${{ matrix.version }}-results
path: check
version: ${{ matrix.version }}
license: ${{ secrets.CONNECT_LICENSE_FILE }}
# TODO: rewrite tests to use CONNECT_* env vars directly
command: |
Rscript -e '
Sys.setenv(
TEST_1_SERVER=Sys.getenv("CONNECT_SERVER"),
TEST_1_API_KEY=Sys.getenv("CONNECT_API_KEY")
)
source("tests/test-integrated.R")'
23 changes: 12 additions & 11 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CONNECT_VERSION: 2024.03.0
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}

steps:
- uses: actions/checkout@v4
Expand All @@ -35,16 +33,19 @@ jobs:
extra-packages: any::pkgdown, local::.
needs: website

- name: Set up license file
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic

- name: Start Connect
run: |
Rscript -e 'connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")'

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}
uses: nealrichardson/with-connect@dev
with:
# Runs on the default version in the with-connect action
license: ${{ secrets.CONNECT_LICENSE_FILE }}
# TODO: rewrite tests to use CONNECT_* env vars directly
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe reference the issue in this line, or just remove it since we have the issue?

Suggested change
# TODO: rewrite tests to use CONNECT_* env vars directly
[ # TODO: rewrite tests to use CONNECT_* env vars directly (issue #476)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Morally I agree, but I'm just going to do this once this PR lands, so I won't forget

command: |
Rscript -e '
Sys.setenv(
TEST_1_SERVER=Sys.getenv("CONNECT_SERVER"),
TEST_1_API_KEY=Sys.getenv("CONNECT_API_KEY")
)
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In a followup that will remediate the TEST_1_SERVER usage, I'll check for how exactly pkgdown needs a live Connect server, not sure it does or should. (But maybe it's fine?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,6 @@ on:
name: Commands

jobs:
update_snapshot:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is ever used.

if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/snapshot') }}
name: snapshot
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CONNECT_VERSION: 2024.03.0
CONNECT_LICENSE_FILE: ${{ secrets.CONNECT_LICENSE_FILE }}
CONNECTAPI_INTEGRATED: true
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::covr, local::.
needs: coverage

- name: Set up license file
run: echo "$CONNECT_LICENSE_FILE" > /tmp/connect.lic

- name: Setup test environment
run: |
connectapi:::build_test_env(connect_license_path = "/tmp/connect.lic")
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2

- name: Accept Snapshots
run: |
testthat::snapshot_accept(path = "tests/testthat")
testthat::snapshot_accept(path = "tests/integrated")

- name: Commit results
run: |
set -xe
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git commit tests/**/_snaps || echo "No changes to commit"

- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
Expand Down
Loading