-
Notifications
You must be signed in to change notification settings - Fork 26
ci: Use with-connect action for integration tests
#475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| fail-fast: false | ||
| matrix: | ||
| version: | ||
| - "2025.09.0" # jammy |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| - "2022.03.2" | ||
| - "2021.09.0" | ||
| - "1.8.8.2" | ||
| - "2022.10.0" # bionic |
There was a problem hiding this comment.
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.
| with: | ||
| extra-packages: any::rcmdcheck, local::. | ||
| needs: check | ||
| extra-packages: local::. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| 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)' |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| name: Commands | ||
|
|
||
| jobs: | ||
| update_snapshot: |
There was a problem hiding this comment.
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.
with-connect actionwith-connect action for integration tests
| - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
tdstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray! This is awesome!
|
(lurking observation: this is excellent) |
tdstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the integration test runs, I see the following:
Problem talking to Posit Connect at http://localhost:3939/__api__/server_settings
Invalid (empty) API key. Please provide a valid API key
Problem talking to Posit Connect at http://localhost:3939/__api__/server_settings
http://localhost:3939/__api__/server_settings request failed with Client error: (401) Unauthorized (code: 30, error: We couldn't log you in with the provided credentials. Please ask your administrator for assistance.)
Is this expected?
I suspected so since the rest of the tests succeed. It looks like a sloppy test: when |
tdstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
toph-allen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome @nealrichardson, thank you for integrating this! Also @tdstein! 👏🏻
I had thought some other tools used HackyConnect but a cursory GitHub search doesn't actually find anything using this, as far as I can tell.
| 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 |
There was a problem hiding this comment.
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?
| # TODO: rewrite tests to use CONNECT_* env vars directly | |
| [ # TODO: rewrite tests to use CONNECT_* env vars directly (issue #476) |
There was a problem hiding this comment.
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
| token = if (token != "") token | ||
| ) | ||
| shell: Rscript {0} | ||
| CONNECTAPI_INTEGRATED: "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My assumption is that our coverage tests need to use Connect because the tests need to actually run to determine what parts of the code are covered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the coverage stats are computed based on running both the unit+mock tests and the integration tests.
I've seen copies/translations of it in at least pins-python, and I thought other places--but I'm coming for them all now. |
|
pins-r integration tests use HackyConnect indirectly in order to create users and get their API keys: https://github.com/rstudio/pins-r/blob/main/.github/workflows/posit-connect.yaml#L41-L44 This can be rewritten without HackyConnect, but will take some refactoring. In the short run, that CI job could be touched up to install an old version of |
Intent
Remove
HackyConnectand the related docker compose tooling for running integration tests, in favor of a newwith-connectutility that @tdstein started work on.The main purpose for doing this here is to prove out how
with-connectand its accompanying GitHub Action can be used in CI, so that we can roll it out to the range of other open-source packages that need it. The code deletion here is a nice benefit.In the process, I discovered that the v1 git endpoints weren't operational in 2022.10.0, as we thought in #459, but rather in 2022.12.0, so I updated those version checks.
Fixes #446
Fixes #240 (as best we can)
Fixes #231 (in a way)
Approach
Iteration back and forth here and on https://github.com/nealrichardson/with-connect/tree/dev, my fork of the action. Once everything was switched over and confirmed working, delete as much as I could, including some stale local dev setup and a test file that was all skips.
There is some further simplification of the integration test suite to do, but I've deferred that here.
Checklist
NEWS.md(referencing the connected issue if necessary)?devtools::document()?