forked from charmed-hpc/slurm-snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (71 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 2024 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FORMAT_BOLD = \033[1m
FORMAT_YELLOW = \033[0;33m
FORMAT_BLUE = \033[0;34m
FORMAT_END = \033[0m
MUNGECTL := $(CURDIR)/src/mungectl
define INTEGRATION_TESTS
integration-configless
endef
define mungectl
@make -f $(MUNGECTL)/Makefile -C $(MUNGECTL) $(1)
endef
define slurmhelpers
@tox run -e $(1)
endef
##@ Build
.PHONY: snap
snap: ## Build snap package
snapcraft -v pack
##@ Lint
.PHONY: fmt
fmt: ## Format snap code
@$(call mungectl, "fmt")
@$(call slurmhelpers, "fmt")
.PHONY:
lint: ## Lint snap code
@$(call mungectl, "lint")
@$(call slurmhelpers, "lint")
##@ Test
.PHONY: unit
unit: ## Run snap unit tests
@$(call mungectl, "unit")
@$(call slurmhelpers, "unit")
.PHONY: integration
integration: $(INTEGRATION_TESTS) ## Run snap integration tests with gambol
.PHONY: check-snap-exists
check-snap-exists:
@[ -f slurm_*.snap ] || \
{ echo "slurm snap must be built before this test can run" && exit 1; }
.PHONY: integration-configless
integration-configless: check-snap-exists
@awk 'BEGIN {\
printf "running integration test: ${FORMAT_BOLD}configless slurm${FORMAT_END}\n" } '
@cp slurm_*.snap tests/integration/configless-slurm/testdata/slurm.snap
cd tests/integration/configless-slurm && gambol -v run configless-slurm.yaml
@rm -f tests/integration/configless-slurm/testdata/slurm_*.snap/slurm.snap
##@ Clean
.PHONY: clean
clean: ## Clean up build environment
snapcraft -v clean
.PHONY: help
help:
@awk 'BEGIN {\
FS = ":.*##"; \
printf "Usage: ${FORMAT_BLUE}OPTION${FORMAT_END}=<value> make ${FORMAT_YELLOW}<target>${FORMAT_END}\n"\
} \
/^[a-zA-Z0-9_-]+:.*?##/ { printf " ${FORMAT_BLUE}%-46s${FORMAT_END} %s\n", $$1, $$2 } \
/^.?.?##~/ { printf " %-46s${FORMAT_YELLOW}%-46s${FORMAT_END}\n", "", substr($$1, 6) } \
/^##@/ { printf "\n${FORMAT_BOLD}%s${FORMAT_END}\n", substr($$0, 5) } ' $(MAKEFILE_LIST)