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

Feature/gitlab 02 #109

Closed
wants to merge 31 commits into from
Closed

Conversation

ntrlshrp
Copy link

@ntrlshrp ntrlshrp commented Jan 9, 2020

As suggested by @nevrome , I've created a PR relevant to issue #91 . Thanks.

ntrlshrp added 30 commits September 9, 2019 13:42
Created skeleton function that mirrors usethis::use_github().
Created template CI/CD file .gitlab-ci.yml that uses Dockerfile to do the work.
Added hello.R so code coverage can be tested.
Enabled push to registry, correct rocker and r_version, code coverage report
If this is not done, my Dockerfile fails to render `paper.html`
Previously this printed "" to the screen
Setting `branch.master.remote` to "origin" is useful to not print your auth_token to the screen each time you push
The readme uses default values (i.e., "github") at first but then overrides those with "gitlab"
It also tells user what to change to take further advantage of .gitlab-ci.yml
Variables let you turn jobs on and off. Documentation helps user learn more quickly how to use and extend `.gitlab-ci.yml`.
This enables devtools::check() to succeed
This allows README and CONTRIBUTING to conform to different remote git services such as github, gitlab, etc.
In order for `gitRemoteService` to be properly passed to README and CONTRIBUTING templates, I had to change some of the github specific functions. I also needed to recapture information that had been updated after create_compendium() by use_gitlab().
Allowed "github" and "gitlab" to return TRUE on some functions. Changed `<USERNAME>` and `<REPO>` github_dummy values to `USERNAME` and `REPO`, otherwise the .gitlab-ci.yml fails with:

`$ docker cp `dl`:<REPO>/analysis/paper/. $CI_PROJECT_DIR/public
    /bin/sh: eval: line 91: can't open REPO: no such file`
Added hello() as example of hello() in order to avoid a warning on devtools::document()
I had accidentally copied over this file with hard-coded rocker/verse:3.6.1 and have now rectified that.
This period helped me avoid this error when running devtools::check() within Docker container,

`Malformed Description field: should contain one or more complete sentences.`
code-coverage-report job was running at the wrong time because I had copied over the variable. Also clarified comments.
Used `usethis::use_github()` documentation as template to make helpfile more substantive.
git user.name is a "full name" while gitlab.username is the GitLab Login name. This piece also has an if-then to allow automated use of the function in a CI/CD.
If the project already has an `origin` remote associated with the local repo, it stops and warns user rather than trying to overwrite it.
Rather than ask the user to consent to overwriting CONDUCT, CONTRIBUTING, and README, now we rename those files. This also facilitates automated use of function.
Changed 'yes' to "yes" in 107/115.

Unfortunately, lots of whitespace changes. :(
Merge remote-tracking branch 'upstream/master' into feature/gitlab-02

# Conflicts:
#	R/core_use_analysis.R
#	R/core_use_compendium.R
devtools::check() creates a note when you use pkg:::function(). This replaces `usethis:::uses_git()` with its exported functions equivalent.
rrtools Dockerfile template currently uses `devtools::install(dep=TRUE)`. The gitlab-ci.yml now consistently uses the same.
When rrtools default was to produce `paper.html`, this could become `index.html` for easy publishing. rrtools default is now `paper.docx`. Will need to check if language in helpfile and README point users to published file or an error.
…1; added function helpfile to match `usethis::use_github()`

This `.gitlab-ci.yml` programatically tests use case (1) for `use_gitlab()`: user creates new compendium, immediately runs `rrtools::use_gitlab()`. Others should be able to test this case programatically (see below) and manually.

This fixed issue %1 where gitlab username does not equal the value returned by `git config user.name`--as a "full name", this will rarely equal the user's GitLab LOGIN which is what is needed.

See ?rrtools::use_gitlab for the helpfile.

Programatically, to make this work, https://gitlab.com/ntrlshrp/rrtools-mirror mirrors the GitHub repo forked from `benmarwick/rrtools`. When the `.gitlab-ci.yml` in this commit is run on GitLab, the `make-new-rrtools-compendium` job installs an rrtools branch from GitHub that exports the `use_gitlab()` function, then creates a new compendium, and immediately runs `rrtools::use_gitlab()`.
This pushes the local repo to a DIFFERENT GitLab remote repo, `newRRtoolsCompendium` (the user must manually delete `newRRtoolsCompendium` each time they want the `make-new-rrtools-compendium` job to succeed).
Then the job makes a commit that includes the now installed .gitlab-ci.yml template and pushes to `newRRtoolsCompendium`, this triggers GitLab CI/CD that creates a reproducible paper using the Dockerfile template.

The `.gitlab-ci.yml` only works if the user has added a variable to their GitLab rrtools (mirror) repo named `RRTOOLS_TOKEN`, the value of which is a GitLab personal access token with `api` scope. See ?rrtools::use_gitlab for help setting this up.
Copy link
Collaborator

@nevrome nevrome left a comment

Choose a reason for hiding this comment

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

It's really difficult to test all of this - especially when you consider the possible interactions of different web services - but I think the general workflow is fine.

Maybe somebody with much more gitlab experience could try it as well? Maybe @dakni?

@@ -0,0 +1,96 @@
image: docker:stable
Copy link
Collaborator

@nevrome nevrome Jan 11, 2020

Choose a reason for hiding this comment

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

I'm not sure if I understand why you added this .gitlab-ci.yml file - despite the explanation in #91 (comment).

I mean: This would be excellent to have if the rrtools package was hosted on gitlab. Then we would have a nice testing infrastructure. But it's currently not. So our .travis.yml is fine, this file will do nothing and we would have to maintain it without actually using it.

Or am I missing something?

pkg = pkg,
out_path = "")
# replace the README.md
file.rename("CONDUCT.md", "CONDUCT.md.bak")
Copy link
Collaborator

Choose a reason for hiding this comment

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

As already stated: Here should be a check for existence. I also think a console message that mentions this step would be nice.

nzchar(Sys.getenv("CI"))
}
# from https://github.com/hadley/devtools/blob/master/R/git.R
uses_github <- function(path = ".") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The function names in this file are technically not correct any more and I don't know if all of these functions work interchangeably for github and gitlab. Do they, @ntrlshrp?

@nevrome nevrome mentioned this pull request Jan 31, 2020
@nevrome nevrome mentioned this pull request Apr 5, 2020
@nevrome nevrome mentioned this pull request Jul 3, 2020
@benmarwick
Copy link
Owner

Closing this due to lack of recent activity.

@benmarwick benmarwick closed this Feb 5, 2024
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.

None yet

3 participants