Skip to content
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

Use license file for integration tests #228

Merged
merged 14 commits into from
Apr 12, 2024
Merged

Use license file for integration tests #228

merged 14 commits into from
Apr 12, 2024

Conversation

nealrichardson
Copy link
Collaborator

@nealrichardson nealrichardson commented Apr 11, 2024

Fixes #227

It took a bit of trial and error to get the secret passed in correctly, and among the things I upgraded along the way:

  • Switch docker-compose to docker compose
  • Update workflows to use ubuntu-latest
  • Remove processx dependency in utils-ci.R. and other simplification in that script

Followups:

@nealrichardson
Copy link
Collaborator Author

This works locally for me: I can run the same docker-compose command to start Connect, having set the RSC_VERSION and RSC_LICENSE_FILE env vars appropriately, and when I hit the ping endpoint I get a 200 response and not 402. For some reason the license file isn't being picked up correctly in CI, and I'm not sure how to get more insight into what's happening in the container. Need to step away and poke at this some more later. @aronatkins lmk if you notice any gotchas I'm missing.

@@ -15,6 +15,7 @@ jobs:
RSC_VERSION: 2022.09.0
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSC_LICENSE: ${{ secrets.RSC_LICENSE }}
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 updated this secret in GH so that it is now a file path where a license file can be expected, not a license key.

Copy link
Contributor

Choose a reason for hiding this comment

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

In other contexts (Connect testing), we use CONNECT_LICENSE for a key and CONNECT_LICENSE_FILE for the file. That lets us understand if we should license-manager activate or copy the file to the landing place.

The Connect Docker images uses RSC_LICENSE for a key and RSC_LICENSE_FILE_PATH for file. That's probably what inspired this workflow. https://github.com/rstudio/rstudio-docker-products/blob/d075a3c0a7bd8efc6b679ae33eceaa905234c30b/connect/startup.sh#L32-L40

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I was going to rename a bunch of things once I got it working, I agree it's not ideal as it is.

Copy link
Contributor

@aronatkins aronatkins left a comment

Choose a reason for hiding this comment

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

Looks fine based on my understanding, but I don't have any history with this part of the CI configuration.

Later: The compose files may want to shift to using an OS other than Ubuntu Bionic.

@@ -15,6 +15,7 @@ jobs:
RSC_VERSION: 2022.09.0
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSC_LICENSE: ${{ secrets.RSC_LICENSE }}
Copy link
Contributor

Choose a reason for hiding this comment

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

In other contexts (Connect testing), we use CONNECT_LICENSE for a key and CONNECT_LICENSE_FILE for the file. That lets us understand if we should license-manager activate or copy the file to the landing place.

The Connect Docker images uses RSC_LICENSE for a key and RSC_LICENSE_FILE_PATH for file. That's probably what inspired this workflow. https://github.com/rstudio/rstudio-docker-products/blob/d075a3c0a7bd8efc6b679ae33eceaa905234c30b/connect/startup.sh#L32-L40

@@ -42,6 +43,9 @@ jobs:
remotes::install_github("r-lib/lifecycle")
shell: Rscript {0}

- name: Set up license file
run: echo ${CONNECT_LICENSE_FILE} > $RSC_LICENSE
Copy link
Contributor

Choose a reason for hiding this comment

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

Permissions are unlikely to matter in this context, but in case you want to see what we recommend: https://docs.posit.co/connect/admin/licensing/#license-file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The file permissions look to be the same as what I have locally, which works. IDK about the user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After a bunch of attempts, it turns out I needed echo "$CONNECT_LICENSE_FILE" with quotes in order to correctly handle the newlines in the license file-in-env-var. This is working now.

@@ -60,8 +62,7 @@ compose_start <- function(connect_license = Sys.getenv("RSC_LICENSE"), rsc_versi
compose_path <- find_compose()

license_details <- determine_license_env(connect_license)
compose_file <- switch(
license_details$type,
compose_file <- switch(license_details$type,
"file" = "ci/test-connect-lic.yml",
Copy link
Contributor

Choose a reason for hiding this comment

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

Future: We should squash these compose files into one (or remove them entirely) and simply provide the correct bind mounts and environment variables to the container as it starts.

@nealrichardson nealrichardson changed the title Try to use license file Use license file for integration tests Apr 12, 2024
@nealrichardson
Copy link
Collaborator Author

Remaining CI failures are unrelated. I'll explore them separately.

@nealrichardson nealrichardson merged commit 93d2031 into main Apr 12, 2024
10 of 12 checks passed
@nealrichardson nealrichardson deleted the license-key branch April 12, 2024 19:37
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.

Use license file for integration tests in CI
2 participants