21720: updated modulePaths
[arvados.git] / services / workbench2 / Makefile
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 # Use bash, and run all lines in each recipe as one shell command
6 SHELL := /bin/bash
7 .ONESHELL:
8
9 GOPATH?=~/go
10 APP_NAME?=arvados-workbench2
11
12 # Cypress test file that can be passed to the integration-test target
13 SPECFILE?=ALL
14
15 # VERSION uses all the above to produce X.Y.Z.timestamp
16 # something in the lines of 1.2.0.20180612145021, this will be the package version
17 # it can be overwritten when invoking make as in make packages VERSION=1.2.0
18 VERSION?=$(shell ./version-at-commit.sh HEAD)
19 # We don't use BUILD_NUMBER at the moment, but it needs to be defined
20 BUILD_NUMBER?=0
21 GIT_COMMIT?=$(shell git rev-parse --short HEAD)
22
23 # ITERATION is the package iteration, intended for manual change if anything non-code related
24 # changes in the package. (i.e. example config files externally added
25 ITERATION?=1
26
27 TARGETS?=rocky8 debian11 debian12 ubuntu2004 ubuntu2204
28
29 DESCRIPTION=Arvados Workbench2 - Arvados is a free and open source platform for big data science.
30 MAINTAINER=Arvados Package Maintainers <packaging@arvados.org>
31
32 # DEST_DIR will have the build package copied.
33 DEST_DIR=/var/www/$(APP_NAME)/workbench2/
34
35 # Debian package file
36 DEB_FILE=$(APP_NAME)_$(VERSION)-$(ITERATION)_amd64.deb
37
38 # redHat package file
39 RPM_FILE=$(APP_NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
40
41 GOPATH=$(shell go env GOPATH)
42 export WORKSPACE?=$(shell pwd)
43
44 ARVADOS_DIRECTORY?=$(shell env -C $(WORKSPACE) git rev-parse --show-toplevel)
45
46 ifndef ci
47         TI=-ti
48 else
49         TI=
50 endif
51
52 .PHONY: help clean* yarn-install test build packages packages-with-version integration-tests-in-docker
53
54 help:
55         @echo >&2
56         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
57         @echo >&2
58         @echo >&2 "More info:"
59         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
60         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
61         @echo >&2 "  Project home            --> https://arvados.org"
62         @echo >&2
63         @false
64
65 clean-deb:
66         rm -f $(WORKSPACE)/*.deb
67
68 clean-rpm:
69         rm -f $(WORKSPACE)/*.rpm
70
71 clean-node-modules:
72         rm -rf $(WORKSPACE)/node_modules
73
74 clean: clean-rpm clean-deb clean-node-modules
75
76 arvados-server-install: check-arvados-directory
77         cd $(ARVADOS_DIRECTORY)
78         go mod download
79         cd cmd/arvados-server
80         echo GOPATH is $(GOPATH)
81         GOFLAGS=-buildvcs=false go install
82         cd -
83         ls -l $(GOPATH)/bin/arvados-server
84         $(GOPATH)/bin/arvados-server install -type test
85
86 yarn-install:
87         yarn install
88
89 unit-tests: yarn-install
90         yarn test --no-watchAll --bail --ci
91
92 integration-tests: yarn-install check-arvados-directory
93         yarn run cypress install
94 ifeq ($(SPECFILE), ALL)
95         $(WORKSPACE)/tools/run-integration-tests.sh -a $(ARVADOS_DIRECTORY)
96 else
97         $(WORKSPACE)/tools/run-integration-tests.sh -a $(ARVADOS_DIRECTORY) -- --spec $(SPECFILE)
98 endif
99
100 integration-tests-in-docker: workbench2-build-image check-arvados-directory
101         docker run $(TI) --rm \
102                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
103                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
104                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
105                 -v $(ARVADOS_DIRECTORY):/usr/src/arvados \
106                 -w /usr/src/arvados/services/workbench2 \
107                 workbench2-build \
108                 make arvados-server-install integration-tests SPECFILE=$(SPECFILE)
109
110 unit-tests-in-docker: workbench2-build-image check-arvados-directory
111         docker run $(TI) --rm \
112                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
113                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
114                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
115                 -v $(ARVADOS_DIRECTORY):/usr/src/arvados \
116                 -w /usr/src/arvados/services/workbench2 \
117                 workbench2-build \
118                 make arvados-server-install unit-tests
119
120 tests-in-docker: workbench2-build-image check-arvados-directory
121         docker run $(TI) --rm \
122                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
123                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
124                 --env ci="${ci}" \
125                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
126                 -v$(ARVADOS_DIRECTORY):/usr/src/arvados \
127                 -w /usr/src/arvados/services/workbench2 \
128                 workbench2-build \
129                 make test
130
131 test: unit-tests integration-tests
132
133 build: yarn-install
134         VERSION=$(VERSION) BUILD_NUMBER=$(BUILD_NUMBER) GIT_COMMIT=$(GIT_COMMIT) yarn build
135
136 $(DEB_FILE): build
137         fpm \
138          -s dir \
139          -t deb \
140          -n "$(APP_NAME)" \
141          -v "$(VERSION)" \
142          --iteration "$(ITERATION)" \
143          --vendor="The Arvados Authors" \
144          --maintainer="$(MAINTAINER)" \
145          --url="https://arvados.org" \
146          --license="GNU Affero General Public License, version 3.0" \
147          --description="$(DESCRIPTION)" \
148          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
149         $(WORKSPACE)/build/=$(DEST_DIR) \
150         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
151
152 $(RPM_FILE): build
153         fpm \
154          -s dir \
155          -t rpm \
156          -n "$(APP_NAME)" \
157          -v "$(VERSION)" \
158          --iteration "$(ITERATION)" \
159          --vendor="The Arvados Authors" \
160          --maintainer="$(MAINTAINER)" \
161          --url="https://arvados.org" \
162          --license="GNU Affero General Public License, version 3.0" \
163          --description="$(DESCRIPTION)" \
164          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
165          $(WORKSPACE)/build/=$(DEST_DIR) \
166         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
167
168 copy: $(DEB_FILE) $(RPM_FILE)
169         for target in $(TARGETS); do \
170                 mkdir -p "packages/$$target" && \
171                 case "$$target" in \
172                         centos*|rocky*) cp -p "$(RPM_FILE)" "packages/$$target" ;; \
173                         debian*|ubuntu*) cp -p "$(DEB_FILE)" "packages/$$target" ;; \
174                         *) echo "Unknown copy target $$target"; exit 1 ;; \
175                 esac ; \
176         done ; \
177         rm -f "$(DEB_FILE)" "$(RPM_FILE)"
178
179 # use FPM to create DEB and RPM
180 packages: copy
181
182 check-arvados-directory:
183         @if test "${ARVADOS_DIRECTORY}" == "unset"; then echo "the environment variable ARVADOS_DIRECTORY must be set to the path of an arvados git checkout"; exit 1; fi
184         @if ! test -d "${ARVADOS_DIRECTORY}"; then echo "the environment variable ARVADOS_DIRECTORY does not point at a directory"; exit 1; fi
185
186 packages-in-docker: check-arvados-directory workbench2-build-image
187         docker run -t --rm --env ci="true" \
188                 --env ARVADOS_DIRECTORY=/tmp/arvados \
189                 --env APP_NAME=${APP_NAME} \
190                 --env VERSION="${VERSION}" \
191                 --env ITERATION=${ITERATION} \
192                 --env TARGETS="${TARGETS}" \
193                 --env MAINTAINER="${MAINTAINER}" \
194                 --env DESCRIPTION="${DESCRIPTION}" \
195                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
196                 -w "/tmp/workbench2" \
197                 -v ${WORKSPACE}:/tmp/workbench2 \
198                 -v ${ARVADOS_DIRECTORY}:/tmp/arvados \
199                 workbench2-build:latest \
200                 sh -c 'git config --global --add safe.directory /tmp/workbench2 && make packages'
201
202 workbench2-build-image:
203         docker inspect workbench2-build &> /dev/null || \
204                 docker build -t workbench2-build -f docker/Dockerfile ${ARVADOS_DIRECTORY}