15814: Remove .only
[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 export CYPRESS_FAIL_FAST_ENABLED?=false
45
46 ARVADOS_DIRECTORY?=$(shell env -C $(WORKSPACE) git rev-parse --show-toplevel)
47
48 ifndef ci
49         TI=-ti
50 else
51         TI=
52 endif
53
54 .PHONY: help clean* yarn-install test build packages packages-with-version integration-tests-in-docker
55
56 help:
57         @echo >&2
58         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
59         @echo >&2
60         @echo >&2 "More info:"
61         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
62         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
63         @echo >&2 "  Project home            --> https://arvados.org"
64         @echo >&2
65         @false
66
67 clean-deb:
68         rm -f $(WORKSPACE)/*.deb
69
70 clean-rpm:
71         rm -f $(WORKSPACE)/*.rpm
72
73 clean-node-modules:
74         rm -rf $(WORKSPACE)/node_modules
75
76 clean: clean-rpm clean-deb clean-node-modules
77
78 arvados-server-install: check-arvados-directory
79         cd $(ARVADOS_DIRECTORY)
80         go mod download
81         cd cmd/arvados-server
82         echo GOPATH is $(GOPATH)
83         GOFLAGS=-buildvcs=false go install
84         cd -
85         ls -l $(GOPATH)/bin/arvados-server
86         $(GOPATH)/bin/arvados-server install -type test
87
88 yarn-install:
89         yarn install
90
91 unit-tests: yarn-install
92         yarn test --no-watchAll --bail --ci
93
94 integration-tests: yarn-install check-arvados-directory
95         yarn run cypress install
96 ifeq ($(SPECFILE), ALL)
97         $(WORKSPACE)/tools/run-integration-tests.sh $(INTERACTIVE) -a $(ARVADOS_DIRECTORY)
98 else
99         $(WORKSPACE)/tools/run-integration-tests.sh $(INTERACTIVE) -a $(ARVADOS_DIRECTORY) -- --spec $(SPECFILE)
100 endif
101
102 integration-tests-in-docker: workbench2-build-image check-arvados-directory
103         docker run $(TI) --rm \
104                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
105                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
106                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
107                 -v $(ARVADOS_DIRECTORY):/usr/src/arvados \
108                 -w /usr/src/arvados/services/workbench2 \
109                 workbench2-build \
110                 make arvados-server-install integration-tests SPECFILE=$(SPECFILE)
111
112 unit-tests-in-docker: workbench2-build-image check-arvados-directory
113         docker run $(TI) --rm \
114                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
115                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
116                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
117                 -v $(ARVADOS_DIRECTORY):/usr/src/arvados \
118                 -w /usr/src/arvados/services/workbench2 \
119                 workbench2-build \
120                 make arvados-server-install unit-tests
121
122 tests-in-docker: workbench2-build-image check-arvados-directory
123         docker run $(TI) --rm \
124                 --env ARVADOS_DIRECTORY=/usr/src/arvados \
125                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
126                 --env ci="${ci}" \
127                 -v $(WORKSPACE):/usr/src/arvados/services/workbench2 \
128                 -v$(ARVADOS_DIRECTORY):/usr/src/arvados \
129                 -w /usr/src/arvados/services/workbench2 \
130                 workbench2-build \
131                 make test
132
133 test: unit-tests integration-tests
134
135 build: yarn-install
136         VERSION=$(VERSION) BUILD_NUMBER=$(BUILD_NUMBER) GIT_COMMIT=$(GIT_COMMIT) yarn build
137
138 $(DEB_FILE): build
139         fpm \
140          -s dir \
141          -t deb \
142          -n "$(APP_NAME)" \
143          -v "$(VERSION)" \
144          --iteration "$(ITERATION)" \
145          --vendor="The Arvados Authors" \
146          --maintainer="$(MAINTAINER)" \
147          --url="https://arvados.org" \
148          --license="GNU Affero General Public License, version 3.0" \
149          --description="$(DESCRIPTION)" \
150          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
151         $(WORKSPACE)/build/=$(DEST_DIR) \
152         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
153
154 $(RPM_FILE): build
155         fpm \
156          -s dir \
157          -t rpm \
158          -n "$(APP_NAME)" \
159          -v "$(VERSION)" \
160          --iteration "$(ITERATION)" \
161          --vendor="The Arvados Authors" \
162          --maintainer="$(MAINTAINER)" \
163          --url="https://arvados.org" \
164          --license="GNU Affero General Public License, version 3.0" \
165          --description="$(DESCRIPTION)" \
166          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
167          $(WORKSPACE)/build/=$(DEST_DIR) \
168         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
169
170 copy: $(DEB_FILE) $(RPM_FILE)
171         for target in $(TARGETS); do \
172                 mkdir -p "packages/$$target" && \
173                 case "$$target" in \
174                         centos*|rocky*) cp -p "$(RPM_FILE)" "packages/$$target" ;; \
175                         debian*|ubuntu*) cp -p "$(DEB_FILE)" "packages/$$target" ;; \
176                         *) echo "Unknown copy target $$target"; exit 1 ;; \
177                 esac ; \
178         done ; \
179         rm -f "$(DEB_FILE)" "$(RPM_FILE)"
180
181 # use FPM to create DEB and RPM
182 packages: copy
183
184 check-arvados-directory:
185         @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
186         @if ! test -d "${ARVADOS_DIRECTORY}"; then echo "the environment variable ARVADOS_DIRECTORY does not point at a directory"; exit 1; fi
187
188 packages-in-docker: check-arvados-directory workbench2-build-image
189         docker run -t --rm --env ci="true" \
190                 --env ARVADOS_DIRECTORY=/tmp/arvados \
191                 --env APP_NAME=${APP_NAME} \
192                 --env VERSION="${VERSION}" \
193                 --env ITERATION=${ITERATION} \
194                 --env TARGETS="${TARGETS}" \
195                 --env MAINTAINER="${MAINTAINER}" \
196                 --env DESCRIPTION="${DESCRIPTION}" \
197                 --env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
198                 -w "/tmp/workbench2" \
199                 -v ${WORKSPACE}:/tmp/workbench2 \
200                 -v ${ARVADOS_DIRECTORY}:/tmp/arvados \
201                 workbench2-build:latest \
202                 sh -c 'git config --global --add safe.directory /tmp/workbench2 && make packages'
203
204 workbench2-build-image:
205         docker inspect workbench2-build &> /dev/null || \
206                 docker build -t workbench2-build -f docker/Dockerfile ${ARVADOS_DIRECTORY}