Skip to content

Commit

Permalink
fix cr_setup for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Jan 30, 2021
1 parent 94daefb commit 26aae36
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: googleCloudRunner
Type: Package
Title: R Scripts in the Google Cloud via Cloud Run, Cloud Build
and Cloud Scheduler
Version: 0.4.0.9000
Version: 0.4.1
Authors@R: c(person("Mark", "Edmondson", email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-8434-3881")),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# googleCloudRunner 0.4.0.9000
# googleCloudRunner 0.4.1

* Fix faulty test for `cr_setup_tests()` that was failing option 3 (#104)
* Fix R and bash scripts failing builds and schedules if they included a `$` character in the script (#103 - thanks @yfarjoun)
* Fix `cr_setup_auth()` not being called in `cr_setup()`

# googleCloudRunner 0.4.0

Expand Down
6 changes: 5 additions & 1 deletion R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ cr_setup <- function(){
do_function = gar_setup_env_check,
env_arg = "GCE_AUTH_FILE",
set_to = gar_setup_get_authenv(session_user = session_user,
env_arg = "GCE_AUTH_FILE"),
env_arg = "GCE_AUTH_FILE",
file = "googlecloudrunner-auth-key.json",
client_json = "GAR_CLIENT_JSON",
roles = cr_setup_role_lookup("local"),
default_key = "googlecloudrunner"),
edit_option = we_edit,
stop = TRUE,
session_user = session_user)
Expand Down
8 changes: 5 additions & 3 deletions inst/docker/packages/cloud_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ bs <- c(
dir = "inst/docker/packages/")
)

built <- cr_build(cr_build_yaml(bs, timeout = 1200))
build <- cr_build_yaml(bs, timeout = 2400)
cr_build_write(build, "inst/docker/packages/cloudbuild.yml")
# built <- cr_build(build)

s_me <- cr_build_schedule_http(built)
cr_schedule("packagetest-build", schedule = "15 9 * * 1", httpTarget = s_me)
s_me <- cr_build_schedule_http(build)
cr_schedule("packagetest-build2", schedule = "15 9 * * 1", httpTarget = s_me)
46 changes: 43 additions & 3 deletions inst/docker/packages/cloudbuild.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
steps:
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- gcloud secrets versions access latest --secret=github-ssh > /root/.ssh/id_rsa
id: git secret
volumes:
- name: ssh
path: /root/.ssh
- name: gcr.io/cloud-builders/git
entrypoint: bash
args:
- -c
- |-
chmod 600 /root/.ssh/id_rsa
cat <<EOF >known_hosts
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
EOF
cat <<EOF >/root/.ssh/config
Hostname github.com
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
git config --global user.name "googleCloudRunner"
git config --global user.email "[email protected]"
id: git setup script
volumes:
- name: ssh
path: /root/.ssh
- name: gcr.io/cloud-builders/git
args:
- clone
- [email protected]:MarkEdmondson1234/googleCloudRunner
- '.'
volumes:
- name: ssh
path: /root/.ssh
- name: gcr.io/cloud-builders/docker
args:
- build
- -f
- inst/docker/packages/Dockerfile
- Dockerfile
- --tag
- gcr.io/gcer-public/packagetools:latest
- --tag
- gcr.io/gcer-public/packagetools:$BRANCH_NAME
- gcr.io/gcer-public/packagetools:$BUILD_ID
- '.'
dir: inst/docker/packages/
- name: gcr.io/cloud-builders/docker
args:
- push
- gcr.io/gcer-public/packagetools
#Generated by googleCloudRunner::cr_build_write at 2020-05-29 16:57:13
dir: inst/docker/packages/
timeout: 2400s
#Generated by googleCloudRunner::cr_build_write at 2021-01-23 17:28:55

0 comments on commit 26aae36

Please sign in to comment.