Merge branch 'main' into 15768-multi-select-operations Arvados-DCO-1.1-Signed-off...
[arvados.git] / 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 APP_NAME?=arvados-workbench2
10
11 # VERSION uses all the above to produce X.Y.Z.timestamp
12 # something in the lines of 1.2.0.20180612145021, this will be the package version
13 # it can be overwritten when invoking make as in make packages VERSION=1.2.0
14 VERSION?=$(shell ./version-at-commit.sh HEAD)
15 # We don't use BUILD_NUMBER at the moment, but it needs to be defined
16 BUILD_NUMBER?=0
17 GIT_COMMIT?=$(shell git rev-parse --short HEAD)
18
19 # ITERATION is the package iteration, intended for manual change if anything non-code related
20 # changes in the package. (i.e. example config files externally added
21 ITERATION?=1
22
23 TARGETS?=centos7 rocky8 debian10 debian11 ubuntu1804 ubuntu2004
24
25 ARVADOS_DIRECTORY?=unset
26
27 DESCRIPTION=Arvados Workbench2 - Arvados is a free and open source platform for big data science.
28 MAINTAINER=Arvados Package Maintainers <packaging@arvados.org>
29
30 # DEST_DIR will have the build package copied.
31 DEST_DIR=/var/www/$(APP_NAME)/workbench2/
32
33 # Debian package file
34 DEB_FILE=$(APP_NAME)_$(VERSION)-$(ITERATION)_amd64.deb
35
36 # redHat package file
37 RPM_FILE=$(APP_NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
38
39 export WORKSPACE?=$(shell pwd)
40
41 .PHONY: help clean* yarn-install test build packages packages-with-version integration-tests-in-docker
42
43 help:
44         @echo >&2
45         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
46         @echo >&2
47         @echo >&2 "More info:"
48         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
49         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
50         @echo >&2 "  Project home            --> https://arvados.org"
51         @echo >&2
52         @false
53
54 clean-deb:
55         rm -f $(WORKSPACE)/*.deb
56
57 clean-rpm:
58         rm -f $(WORKSPACE)/*.rpm
59
60 clean-node-modules:
61         rm -rf $(WORKSPACE)/node_modules
62
63 clean: clean-rpm clean-deb clean-node-modules
64
65 arvados-server-install: check-arvados-directory
66         cd $(ARVADOS_DIRECTORY)
67         go mod download
68         cd cmd/arvados-server
69         go install
70         cd -
71         ls -l ~/go/bin/arvados-server
72         ~/go/bin/arvados-server install -type test
73
74 yarn-install: arvados-server-install
75         yarn install
76
77 unit-tests: yarn-install
78         yarn test --no-watchAll --bail --ci
79
80 integration-tests: yarn-install check-arvados-directory
81         yarn run cypress install
82         $(WORKSPACE)/tools/run-integration-tests.sh -a $(ARVADOS_DIRECTORY)
83
84 integration-tests-in-docker: workbench2-build-image check-arvados-directory
85         docker run -ti -v$(PWD):/usr/src/workbench2 -v$(ARVADOS_DIRECTORY):/usr/src/arvados -w /usr/src/workbench2 -e ARVADOS_DIRECTORY=/usr/src/arvados workbench2-build make integration-tests
86
87 unit-tests-in-docker: workbench2-build-image check-arvados-directory
88         docker run -ti -v$(PWD):/usr/src/workbench2 -v$(ARVADOS_DIRECTORY):/usr/src/arvados -w /usr/src/workbench2 -e ARVADOS_DIRECTORY=/usr/src/arvados workbench2-build make unit-tests
89
90 test: unit-tests integration-tests
91
92 build: yarn-install
93         VERSION=$(VERSION) BUILD_NUMBER=$(BUILD_NUMBER) GIT_COMMIT=$(GIT_COMMIT) yarn build
94
95 $(DEB_FILE): build
96         fpm \
97          -s dir \
98          -t deb \
99          -n "$(APP_NAME)" \
100          -v "$(VERSION)" \
101          --iteration "$(ITERATION)" \
102          --vendor="The Arvados Authors" \
103          --maintainer="$(MAINTAINER)" \
104          --url="https://arvados.org" \
105          --license="GNU Affero General Public License, version 3.0" \
106          --description="$(DESCRIPTION)" \
107          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
108         $(WORKSPACE)/build/=$(DEST_DIR) \
109         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
110
111 $(RPM_FILE): build
112         fpm \
113          -s dir \
114          -t rpm \
115          -n "$(APP_NAME)" \
116          -v "$(VERSION)" \
117          --iteration "$(ITERATION)" \
118          --vendor="The Arvados Authors" \
119          --maintainer="$(MAINTAINER)" \
120          --url="https://arvados.org" \
121          --license="GNU Affero General Public License, version 3.0" \
122          --description="$(DESCRIPTION)" \
123          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
124          $(WORKSPACE)/build/=$(DEST_DIR) \
125         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
126
127 copy: $(DEB_FILE) $(RPM_FILE)
128         for target in $(TARGETS); do \
129                 mkdir -p "packages/$$target" && \
130                 case "$$target" in \
131                         centos*|rocky*) cp -p "$(RPM_FILE)" "packages/$$target" ;; \
132                         debian*|ubuntu*) cp -p "$(DEB_FILE)" "packages/$$target" ;; \
133                         *) echo "Unknown copy target $$target"; exit 1 ;; \
134                 esac ; \
135         done ; \
136         rm -f "$(DEB_FILE)" "$(RPM_FILE)"
137
138 # use FPM to create DEB and RPM
139 packages: copy
140
141 check-arvados-directory:
142         @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
143         @if ! test -d "${ARVADOS_DIRECTORY}"; then echo "the environment variable ARVADOS_DIRECTORY does not point at a directory"; exit 1; fi
144
145 packages-in-docker: check-arvados-directory workbench2-build-image
146         docker run --env ci="true" \
147                 --env ARVADOS_DIRECTORY=/tmp/arvados \
148                 --env APP_NAME=${APP_NAME} \
149                 --env ITERATION=${ITERATION} \
150                 --env TARGETS="${TARGETS}" \
151                 -w="/tmp/workbench2" \
152                 -t -v ${WORKSPACE}:/tmp/workbench2 \
153                 -v ${ARVADOS_DIRECTORY}:/tmp/arvados workbench2-build:latest \
154                 make packages
155
156 workbench2-build-image:
157         (cd docker && docker build -t workbench2-build .)