Skip to content

Commit

Permalink
tar_dir attribute for the .tar output of r_library
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthab committed Oct 20, 2017
1 parent 852bf43 commit fb8ae2b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ r_library(
"//path/to/packageA:r_pkg_target",
"//path/to/packageB:r_pkg_target",
],
tar_dir = "r-libs",
)

load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
name = "image",
base = "@r_base//image",
directory = "/r-libs",
directory = "/",
env = {"R_LIBS_USER": "/r-libs"},
tars = [":my_r_library.tar"],
repository = "my_repo",
Expand Down Expand Up @@ -286,6 +287,9 @@ Executable rule to install the given packages and all dependencies to a user
provided or system default R library. Run the target with --help for usage
information.

This rule also creates an invisible {name}.tar target which outputs the R
library as a tar file; mainly for use with the Docker rules.

<table class="table table-condensed table-bordered table-params">
<colgroup>
<col class="col-param" />
Expand All @@ -312,6 +316,14 @@ information.
For runtime overrides, use bazel run [target] -- -l [path].</p>
</td>
</tr>
<tr>
<td><code>tar_dir</code></td>
<td>
<p><code>String; default "."</code></p>
<p>The root directory in the tar file under which the R library will be
copied.</p>
</td>
</tr>
</tbody>
</table>

Expand Down
10 changes: 9 additions & 1 deletion tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ r_library(
"//exampleC",
"@R_bitops//:bitops",
],
tar_dir = "r-libs",
)

load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
name = "image",
base = "@r_base//image",
directory = "/r-libs",
directory = "/",
env = {"R_LIBS_USER": "/r-libs"},
tars = [":library.tar"],
)

sh_test(
name = "image_test",
size = "small",
srcs = ["image_test.sh"],
data = [":image-layer.tar"],
)
22 changes: 22 additions & 0 deletions tests/image_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Copyright 2017 GRAIL, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eou pipefail

readonly LAYER_TAR="image-layer.tar"
readonly FILE_TO_CHECK="r-libs/exampleC/DESCRIPTION"

tar -tf "${LAYER_TAR}" | grep "${FILE_TO_CHECK}"

0 comments on commit fb8ae2b

Please sign in to comment.