21128: fixed navToOutput and circular deps Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[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 GOPATH=$(shell go env GOPATH)
40 export WORKSPACE?=$(shell pwd)
41
42 .PHONY: help clean* yarn-install test build packages packages-with-version integration-tests-in-docker
43
44 help:
45         @echo >&2
46         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
47         @echo >&2
48         @echo >&2 "More info:"
49         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
50         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
51         @echo >&2 "  Project home            --> https://arvados.org"
52         @echo >&2
53         @false
54
55 clean-deb:
56         rm -f $(WORKSPACE)/*.deb
57
58 clean-rpm:
59         rm -f $(WORKSPACE)/*.rpm
60
61 clean-node-modules:
62         rm -rf $(WORKSPACE)/node_modules
63
64 clean: clean-rpm clean-deb clean-node-modules
65
66 arvados-server-install: check-arvados-directory
67         cd $(ARVADOS_DIRECTORY)
68         go mod download
69         cd cmd/arvados-server
70         echo GOPATH is $(GOPATH)
71         GOFLAGS=-buildvcs=false go install
72         cd -
73         ls -l $(GOPATH)/bin/arvados-server
74         $(GOPATH)/bin/arvados-server install -type test
75
76 yarn-install: arvados-server-install
77         yarn install
78
79 unit-tests: yarn-install
80         yarn test --no-watchAll --bail --ci
81
82 integration-tests: yarn-install check-arvados-directory
83         yarn run cypress install
84         $(WORKSPACE)/tools/run-integration-tests.sh -a $(ARVADOS_DIRECTORY)
85
86 integration-tests-in-docker: workbench2-build-image check-arvados-directory
87         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
88
89 unit-tests-in-docker: workbench2-build-image check-arvados-directory
90         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
91
92 tests-in-docker: workbench2-build-image check-arvados-directory
93         docker run -t -v$(PWD):/usr/src/workbench2 -v$(ARVADOS_DIRECTORY):/usr/src/arvados -w /usr/src/workbench2 -e ARVADOS_DIRECTORY=/usr/src/arvados -e ci="${ci}" workbench2-build make test
94
95 test: unit-tests integration-tests
96
97 build: yarn-install
98         VERSION=$(VERSION) BUILD_NUMBER=$(BUILD_NUMBER) GIT_COMMIT=$(GIT_COMMIT) yarn build
99
100 $(DEB_FILE): build
101         fpm \
102          -s dir \
103          -t deb \
104          -n "$(APP_NAME)" \
105          -v "$(VERSION)" \
106          --iteration "$(ITERATION)" \
107          --vendor="The Arvados Authors" \
108          --maintainer="$(MAINTAINER)" \
109          --url="https://arvados.org" \
110          --license="GNU Affero General Public License, version 3.0" \
111          --description="$(DESCRIPTION)" \
112          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
113         $(WORKSPACE)/build/=$(DEST_DIR) \
114         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
115
116 $(RPM_FILE): build
117         fpm \
118          -s dir \
119          -t rpm \
120          -n "$(APP_NAME)" \
121          -v "$(VERSION)" \
122          --iteration "$(ITERATION)" \
123          --vendor="The Arvados Authors" \
124          --maintainer="$(MAINTAINER)" \
125          --url="https://arvados.org" \
126          --license="GNU Affero General Public License, version 3.0" \
127          --description="$(DESCRIPTION)" \
128          --config-files="etc/arvados/$(APP_NAME)/workbench2.example.json" \
129          $(WORKSPACE)/build/=$(DEST_DIR) \
130         etc/arvados/workbench2/workbench2.example.json=/etc/arvados/$(APP_NAME)/workbench2.example.json
131
132 copy: $(DEB_FILE) $(RPM_FILE)
133         for target in $(TARGETS); do \
134                 mkdir -p "packages/$$target" && \
135                 case "$$target" in \
136                         centos*|rocky*) cp -p "$(RPM_FILE)" "packages/$$target" ;; \
137                         debian*|ubuntu*) cp -p "$(DEB_FILE)" "packages/$$target" ;; \
138                         *) echo "Unknown copy target $$target"; exit 1 ;; \
139                 esac ; \
140         done ; \
141         rm -f "$(DEB_FILE)" "$(RPM_FILE)"
142
143 # use FPM to create DEB and RPM
144 packages: copy
145
146 check-arvados-directory:
147         @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
148         @if ! test -d "${ARVADOS_DIRECTORY}"; then echo "the environment variable ARVADOS_DIRECTORY does not point at a directory"; exit 1; fi
149
150 packages-in-docker: check-arvados-directory workbench2-build-image
151         docker run --env ci="true" \
152                 --env ARVADOS_DIRECTORY=/tmp/arvados \
153                 --env APP_NAME=${APP_NAME} \
154                 --env ITERATION=${ITERATION} \
155                 --env TARGETS="${TARGETS}" \
156                 -w="/tmp/workbench2" \
157                 -t -v ${WORKSPACE}:/tmp/workbench2 \
158                 -v ${ARVADOS_DIRECTORY}:/tmp/arvados workbench2-build:latest \
159                 sh -c 'git config --global --add safe.directory /tmp/workbench2 && make packages'
160
161 workbench2-build-image:
162         (cd docker && docker build -t workbench2-build .)