From b52c3224b1b18bf3965e260942622605cf493a22 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 19 Oct 2020 12:39:40 +0100 Subject: Stop using GOPATH for source code to ensure go modules are enabled Source code in GOPATH disables modules mode when GO111MODULES=auto, which is the default. Keeping it out should make things reliable here. Note that this is not yet tested. --- roles/pipeliner/tasks/pipeline.yml | 32 +++++++---------------------- roles/pipeliner/templates/updatepipeline.j2 | 11 ++++------ 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/roles/pipeliner/tasks/pipeline.yml b/roles/pipeliner/tasks/pipeline.yml index 61becfb..e85b612 100644 --- a/roles/pipeliner/tasks/pipeline.yml +++ b/roles/pipeliner/tasks/pipeline.yml @@ -1,6 +1,6 @@ --- -# Needed for stretch as we need golang >= 1.9 (for x/draw dependency), and stretch +# Needed for stretch as we need golang >= 1.11 (for modules), and stretch # only has 1.8 available - name: Install debian backports lineinfile: @@ -21,41 +21,23 @@ default_release: stretch-backports update_cache: yes -# Do this manually rather than relying on go get so that go get -# with modules enabled can be run to do the build - name: Get go repo git: - dest: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/{{ item }} - repo: https://git.rescribe.xyz/{{ item }} + dest: /home/{{ ansible_user }}/src/bookpipeline + repo: https://git.rescribe.xyz/bookpipeline force: yes become: no - with_items: - - bookpipeline - - preproc - - utils - name: Get and build bookpipeline and dependencies - shell: - cmd: GOPATH=/home/{{ ansible_user }}/src/go GO111MODULE=on go install rescribe.xyz/bookpipeline/... - chdir: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/bookpipeline + command: + cmd: go install ./... + chdir: /home/{{ ansible_user }}/src/bookpipeline become: no -# command fails because of a strange error with environment, resulting in -# 'go: unknown environment setting GO111MODULE=True' -# so we're setting it from the shell instead. -# we should be able to revert back to command once using a more recent -# go version where GO111MODULE is not required. -# command: -# cmd: go install rescribe.xyz/bookpipeline/... -# chdir: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/bookpipeline -# environment: -# GOPATH: /home/{{ ansible_user }}/src/go -# GO111MODULE: on -# become: no - name: Install bookpipeline binary copy: remote_src: true - src: /home/{{ ansible_user }}/src/go/bin/bookpipeline + src: /home/{{ ansible_user }}/go/bin/bookpipeline dest: /usr/local/bin/ owner: root group: root diff --git a/roles/pipeliner/templates/updatepipeline.j2 b/roles/pipeliner/templates/updatepipeline.j2 index 5b76f9a..efe04e1 100644 --- a/roles/pipeliner/templates/updatepipeline.j2 +++ b/roles/pipeliner/templates/updatepipeline.j2 @@ -1,14 +1,11 @@ #!/bin/sh -g="/home/{{ ansible_user }}/src/go" +s="/home/{{ ansible_user }}/src" t="/home/{{ ansible_user }}/trainings" -# The extra go install step ensures that go modules are used -# (they don't work for the go get stage in go 1.11) -export GOPATH="$g" -cd "$g/src/rescribe.xyz/bookpipeline" && \ +cd "$s/bookpipeline" && \ git pull && \ -GO111MODULE=on go install ./... && \ -sudo cp "$g/bin/bookpipeline" /usr/local/bin/ || exit 1 +go install ./... && \ +sudo cp "$HOME/go/bin/bookpipeline" /usr/local/bin/ || exit 1 cd "$t" && git pull && \ sudo cp "$t"/* /usr/local/share/tesseract-ocr/tessdata/ -- cgit v1.2.1-24-ge1ad