Skip to content

Conversation

@nealrichardson
Copy link
Collaborator

@nealrichardson nealrichardson commented Oct 25, 2025

Intent

Remove HackyConnect and the related docker compose tooling for running integration tests, in favor of a new with-connect utility that @tdstein started work on.

The main purpose for doing this here is to prove out how with-connect and 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

  • Does this change update NEWS.md (referencing the connected issue if necessary)?
  • Does this change need documentation? Have you run devtools::document()?

@nealrichardson nealrichardson marked this pull request as ready for review October 26, 2025 18:42
fail-fast: false
matrix:
version:
- "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.

- "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.

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
Contributor

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)'
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: 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.

@nealrichardson nealrichardson changed the title ci: Try with-connect action ci: Use with-connect action for integration tests Oct 26, 2025
- 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.

🥳

Copy link
Collaborator

@tdstein tdstein left a 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!

@zackverham
Copy link

(lurking observation: this is excellent)

Copy link
Collaborator

@tdstein tdstein left a 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?

@nealrichardson
Copy link
Collaborator Author

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 .check_is_fatal = FALSE, it prints the error instead of raising it, and that output isn't being caught on https://github.com/posit-dev/connectapi/blob/main/tests/integrated/test-connect.R#L52-L56

Copy link
Collaborator

@tdstein tdstein left a 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!

Copy link
Collaborator

@toph-allen toph-allen left a 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
Copy link
Collaborator

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

token = if (token != "") token
)
shell: Rscript {0}
CONNECTAPI_INTEGRATED: "true"
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@nealrichardson
Copy link
Collaborator Author

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.

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.

@nealrichardson nealrichardson merged commit 690bb8c into main Oct 27, 2025
21 checks passed
@nealrichardson nealrichardson deleted the with-connect branch October 27, 2025 20:38
@nealrichardson
Copy link
Collaborator Author

nealrichardson commented Oct 27, 2025

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 connectapi that has HackyConnect, if that's needed. But we should just fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tidy up Makefile, docker compose files, etc. Test against dev Connect image Simplify docker compose for test setup

6 participants