-
Notifications
You must be signed in to change notification settings - Fork 27
created animint2pages() #101
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
|
looks like a good start. could you please add a test similar to what we were doing to test animint2gist? |
…hub.com/tdhock/animint2 into 84-move-gallery-from-blocks-to-gh-pages
|
I encountered an issue when trying to use the animint2pages() function in my local environment. Also, the git2r::commit() function requires a 'commit' of S3 class git_commit, which is not created when initializing a new repository. |
…hub.com/tdhock/animint2 into 84-move-gallery-from-blocks-to-gh-pages
library(gh)
library(git2r)
# Create a new GitHub repository
gh("POST /user/repos", name = "testrepo")
# Define a temporary directory
tmp_dir <- tempfile()
if (!dir.exists(tmp_dir)) {
dir.create(tmp_dir)
}
# echo "# animint2pages-test" >> README.md
# git init
repo <- git2r::init(tmp_dir)
config(repo, user.name = "Faye-yufan", user.email = "[email protected]")
readme_file_path <- file.path(tmp_dir, "README.md")
writeLines("# testrepo", readme_file_path)
# git add README.md
git2r::add(repo, "README.md")
# git commit -m "first commit"
git2r::commit(repo, "first commit")
# git branch -M main
git2r::branches(repo)
git2r::branch_rename(repository_head(repo), "main")
git2r::branches(repo)
# git remote add origin https://github.com/Faye-yufan/animint2pages-test.git
git2r::remote_add(repo, "origin", "https://github.com/Faye-yufan/animint2pages-test.git")
# git push -u origin main
git2r::push(repo, "origin", "refs/heads/main")
# Error in git2r::push(repo, "origin", "refs/heads/main") :
# Error in 'git2r_push': Unable to authenticate with supplied credentialsThe above code is not working on my local, cannot push the local branch to the remote, because of this issue in > sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.2.1 (2022-06-23)
os macOS Monterey 12.3
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2023-08-06
rstudio 2022.07.1+554 Spotted Wakerobin (desktop)
pandoc 2.19.2 @ /usr/local/bin/pandoc
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.0)
curl 5.0.0 2023-01-12 [1] CRAN (R 4.2.0)
gh * 1.4.0 2023-02-22 [1] CRAN (R 4.2.0)
git2r * 0.32.0 2023-04-12 [1] CRAN (R 4.2.0)
gitcreds 0.1.2 2022-09-08 [1] CRAN (R 4.2.0)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
httr2 0.2.2 2022-09-25 [1] CRAN (R 4.2.0)
jsonlite 1.8.4 2022-12-06 [1] CRAN (R 4.2.0)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.2.0)
rlang 1.1.0 2023-03-14 [1] CRAN (R 4.2.0)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.0)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
[1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library |
|
as I understand, the linked issue only happens when you use a ssh key with no passphrase, is that right? does it work if you use a ssh key with a passphrase? (re-generate one with ssh-keygen) |
|
@tdhock Thank you for the information! It's new to me, but I'll certainly look into this and see how it affect my issue. |
|
I found this function |
|
In the above commit: I have transitioned our Git-related code to use the Here is an animint viz example I uploaded onto gh page using the function: remotes::install_github("animint/animint2@1e7106855a2ed7a89c36e67b3ca71046b4d0138f")
library(animint2)
viz.point <- list(
pointtwo = ggplot() + geom_point(
data = mtcars,
size = 10,
aes(x=wt, y=mpg, fill=disp),
clickSelects = "gear"))
animint2::animint2pages(viz.point, "animinttest0831-private", private = TRUE)The output is on my own gh page: https://faye-yufan.github.io/animinttest0831-private/ Additionally, I use the original file structure to push onto github pages instead of flat structure in Regarding test cases, I'm wondering how to compile them. From what I see in the test case of |
|
hi @Faye-yufan this is great progress, thanks for sharing. I got This was on windows with https auth, but I can test on linux with ssh auth too. for test cases, it would be ideal if we could actually run it and then parse the web page, like we do in the headless browser tests. not sure how complicated that would be to implement though? (waiting for the github pages to deploy to the web server is maybe too much? maybe we just test the presence of files in the gh-pages branch of the repo?) |
|
Hi @tdhock , thank you for taking the time to test and glad to hear the messages are helpful! About the "private" repo visibility - Yes, the behavior you observed is normal. The argument About the user.name and user.email Configuration - I appreciate you pointing out the need for setting up the Git configuration. I didn't encounter this issue probably because I had previously configured these settings via RStudio. I agree that we should include this step in the documentation. Regarding test cases - testing the presence of files in the gh-pages branch of the repo seems like a practical approach, I will work on it :) |
|
on ubuntu I got > animint2::animint2pages(viz.point, "animint-test-2023-08-31")
Le chargement a nécessité le package : gert
Erreur dans animint2::animint2pages(viz.point, "animint-test-2023-08-31") :
A GitHub token is required to create and push to a new repo. |
|
On Ubuntu I followed these instructions to make it work (we should add them to our docs). > gitcreds::gitcreds_set()
-> Your current credentials for 'https://github.com':
protocol: https
host : github.com
username: PersonalAccessToken
password: <-- hidden -->
-> What would you like to do?
1: Abort update with error, and keep the existing credentials
2: Replace these credentials
3: See the password / token
Sélection : 2
-> Removing current credentials...
? Enter new password or token: -> Adding new credentials...
-> Removing credentials from cache...
-> Done.
> animint2::animint2pages(viz.point, "animint-test-2023-08-31")
Transferred 15 of 15 objects...done!
Checked out 1 of 1 commits... done!
Looking up https credentials for https://github.com/tdhock/animint-test-2023-08-31.git
Transferred 4 of 4 objects...done!
[status] refs/heads/gh-pages: unchanged
[updated] 16b89cd249..5919d9762c refs/remotes/origin/gh-pages
Visualization will be available at https://tdhock.github.io/animint-test-2023-08-31
Deployment via GitHub Pages may take a few minutes...
[1] "/tmp/RtmpkEtUh3/file62f193eb38d9/" |
|
@tdhock Thank you so much for the detailed testing and analysis! |
|
it is probably best to leave token creation up to the user. but we instead of "A GitHub token is required to create and push to a new repo." we could have an error message that explains how to create a token and then use |
|
hi @Faye-yufan I just pushed some major changes which probably overlap with your work in #107 |
A function to put animint object on to github pages