Git Product home page Git Product logo

drat.builder's Introduction

drat.builder

Build Status

Docker Build Status

The idea here is to make it extremely easy to keep a drat repository up to date.

Suppose you have a drat that tracks a number of upstream github repos (here the repos are the package repositories and drat repository will be the drat itself). Say, reomoji, rfiglet and cowsay

In the root of an existing drat repository or in a new empty directory, make a file called packages.txt containing:

richfitz/remoji
richfitz/rfiglet
sckott/cowsay

Then run

drat.builder::build()

which will download the most recent sources for those packages, build them (source versions only, but will build vignettes) and add them to drat following the best practice commit log so that each log entry reads like

<package_name> <version> <sha> <url>

e.g.,

rfiglet 0.1.0 4b65d19 https://github.com/richfitz/rfiglet.git

Command line use

Run

drat.builder::install_script("~/bin")

and then a shell script drat.builder is available. It takes all the arguments that drat.builder::build takes, but is useful to run from the command line. See

drat.builder --help

for help.

Options

drat.builder takes options

  • install -- installs packages before building so that vignettes can be built
  • install_local -- implies install, and installs locally and temporarily rather than into a system-readable library
  • no_fetch -- suppresses fetching packages

packages.txt

The file packages.txt roughly follows the convention started by devtools;

  • username/repo/subdir -- install package from a subdir
  • username/repo@ref -- install a particular reference
  • username/repo/subdir@ref -- both a subdir and a reference

The @ref syntax will be useful to anchor drat builds to particular versions, rather than constantly reading off HEAD of the upstream repo. This will be easy when the upstream repo uses github releases and semantic versioning as you can write:

Avoiding rebuilds

To avoid polluting the drat repo, drat.builder will try to avoid rebuilding. To do this it keeps a file packages.json with version numbers and sha values of the installed packages.

TODO

  • support for non-github packages (e.g., using full URL)
  • support for preventing vignette build (e.g. long options to R CMD build)

drat.builder's People

Contributors

cboettig avatar nbenn avatar richfitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

zkamvar nbenn

drat.builder's Issues

Drop git2r?

So many things needed that are not included now that accessing both ways is starting to feel a bit silly. So could drop the git2r dep and add a SystemDependencies for git (>= 1.8.0).

Support non-git-based deploy?

As awesome as the free hosting with super-stable GitHub servers and fast CDN and all is, there are some use cases for which it would make more sense to host elsewhere than on Github pages -- e.g. so we can parse server logs and compute download counts, etc. Seems the commit workflow is relatively hardwired into the top-level functions though. Probably just need a way to toggle off the call to update_drat in the build() call.

Using `build()` on multiple packages lists destroys previous source caching

In my drat repo, I call build("packages.txt") to install a list of hadleyverse packages, and then build("ropensci.txt") to build an automatically generated list of ropensci packages (using the ropkgs API).

Unfortunately, somehow the second call seems to be purging all the downloaded packages from the first list -- none of them are in packages any more, only the ropensci packages are. Meanwhile, drat.json seems to only have the entries for the packages in first list (packages.txt), and not the others. Consequently, an attempt to rebuild fails with:

Error in git2r::fetch(package_repo(p), "origin") : 
  error in evaluating the argument 'repo' in selecting a method for function 'fetch': Error in normalizePath(path, winslash = "/", mustWork = TRUE) : 
  path[1]="./packages/assertthat": No such file or directory
Calls: package_repo ... <Anonymous> -> <Anonymous> -> .local -> normalizePath
Calls: build ... fetch_package_sources -> fetch_package -> <Anonymous>
Execution halted

On the first package not to be in the packages list (e.g. assertthat here, after I manually clone a few of the previous to check). Deleting drat.json doesn't help, I still get this error. I have to manually remove packages_src to get rebuild going again.

Also noticed that somehow I ended up with a blank PACKAGES and PACKAGES.gz list in my repo -- not sure how that happened (but just in time for Prof to scold me for the packages not being there when I pushed a patch to RNeXML last night...).

multiple packages in same repo

It looks like drat.builder now supports the package root not being in the git root directory, but it still complains if two packages are in the same repo (which in my experience is the main reason someone uses this pattern in the first place), e.g.

egonw/rrdf/rrdflibs
egonw/rrdf/rrdf

I realize the logic is a bit tricky here, since drat.builder doesn't want to attempt to clone the repo twice..

add option to skip building of vignettes

vignette building is slow, adds dependencies and points of failure. It might be good to have the option to just skip the vignette building step? (e.g. --no-build-vignettes)

Remove packages

Should removal of a package from packages.txt remove the package? Does it already?

Support downloading of non github packages

Use full url, perhaps:

ropensci/lawn # comes from github
https://bitbucket.com/foo/bar # comes from bitbucket

Another option would be to use toml or yaml to break the file into different sources:

[github]
ropensci/lawn

[bitbucket]
foo/bar

[urls]
https://whatever....

But then, I don't have a need for this at present - for better or worse things seem pretty centralised on github...

build() only works once?

perhaps this package is only intended for CI use, so this may be a moot point...

I successfully setup a drat repository using drat.builder::build() but I am unable to run build() more than once.
Subsequent calls give the error below. Note, this also completely breaks the git submodule structure and breaks the repo.

> drat.builder::build()
*** [fetch] achubaty/amc@development
*** [fetch] PredictiveEcology/CBMutils@development
*** [fetch] PredictiveEcology/fireSenseUtils@development
*** [fetch] PredictiveEcology/LandR@development
*** [fetch] PredictiveEcology/LandWebUtils@development
*** [fetch] PredictiveEcology/map@development
*** [fetch] PredictiveEcology/pemisc@development
*** [fetch] PredictiveEcology/peutils@development
*** [fetch] PredictiveEcology/quickPlot@development
*** [fetch] PredictiveEcology/Require@development
*** [fetch] PredictiveEcology/reproducible@development
*** [fetch] PredictiveEcology/SpaDES.core@development
*** [fetch] PredictiveEcology/SpaDES.tools@development
Error in call_system(Sys_which("git"), args, ...) : Running command:
  '/usr/bin/git' clone -- packages_src/achubaty/amc ./packages/amc
had status 128
Program output:
----------------------------------------------------------------------------------------------------------
fatal: repository 'packages_src/achubaty/amc' does not exist
----------------------------------------------------------------------------------------------------------

same result on Ubuntu 20.04 and Windows 10.

Automatically keep bin paths up to date

I've been playing around a bit with {drat.builder} for the past couple of days, mainly b/c for the second time now, I ran into the issue that my drat repo did not contain the required bin paths (see PRs #23 and #24 and with the imminent release of 4.2 we'll face this once again). In my fork of your repo I added functionality that can check with CRAN to get all current macOS and Windows paths (see master...nbenn:master). This exposes an argument check_cran, which when TRUE will get the directories from CRAN (with a bit of cleanup required, as there are also dirs like tools, base, etc. that we don't want) and update the drat repo accordingly. I'm not fetching versions from metacran, as this would not have been able to save us from #24 and the only way to achieve this that I could think of, was accessing CRAN itself.

Happy to submit a PR if this is of interest to you.

binary package builds?

drat now supports binary packages, and CI infrastructure (e.g., GitHub Actions) typically support multilple OSes, so it's feasible to build binaries for Windows and macOS on the CI machines and push those to the drat repo.

It would be great if drat.builder could support this.

fetch fails when a package has been updated?

I often see fetch fail if a package has been updated since I last ran drat, and I still have a packages_src directory sitting around.

I haven't completely diagnosed this one yet, might be something in how you are doing the original clone command (e.g. perhaps you're doing shallow clones that don't pull the whole history? Of course that's nice for this context, but would create this issue I think).

e.g.:

Error in call_system(Sys_which("git"), c("-C", path, "fetch", "origin",  : 
  Running command:
  '/usr/bin/git' -C packages_src/knitr fetch origin *:*
had status 1
Program output:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
From https://github.com/yihui/knitr
 ! [rejected]        refs/pull/1073/merge -> refs/pull/1073/merge  (non-fast-forward)
 ! [rejected]        refs/pull/1080/merge -> refs/pull/1080/merge  (non-fast-forward)

I think the shallow clones are ideal (particularly since the nightly builds on circle are always doing fresh pulls anyway, so it's nice that's as fast as possible), and the ideal behaviour might be to catch this and delete the stored copy so we can shallow clone again. But otherwise full clones might be the quick fix. (Or maybe I'm way off and the issue is completely different).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.