generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (60 loc) · 2.59 KB
/
Makefile
File metadata and controls
70 lines (60 loc) · 2.59 KB
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
SHELL = /usr/bin/env bash
.SHELLFLAGS = -ecuo pipefail
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
.DEFAULT_GOAL := help
# Bump version variables
DRYRUN ?= "false"
# Devcontainer variables
FEATURES ?= common-utils ## Feature to test. Default: 'common-utils'. Options: 'aws-cli', 'common-utils', 'docker-in-docker', 'docker-outside-of-docker', 'terraform'
BASE_IMAGE ?= archlinux:base ## Base image for testing. Must be Arch Linux with 'pacman'. Default: 'archlinux:base'.
PATH_TO_RUN ?= . ## Path to run the tests. Default: . (current directory). Change this in the Makefile or in the environment.
SCENARIOS_FILTER ?= ## Filter for feature scenarios. Default: empty. Change this in the Makefile or in the environment.
PRESERVE_TESTCONTAINERS ?= false ## Preserve test containers. Default: false. Change this in the Makefile or in the environment.
# Devcontainer command
DC=yarn devcontainer
DC_TEST=$(DC) features test
# Devcontainer flags
DC_TEST_GLOBAL_FLAGS=--global-scenarios-only
DC_TEST_AUTOGENERATED_FLAGS=--skip-scenarios \
-f $(FEATURES) \
-i $(BASE_IMAGE) \
--preserve-test-containers $(PRESERVE_TESTCONTAINERS)
DC_TEST_SCENARIOS_FLAGS=-f $(FEATURES) \
--skip-autogenerated \
--skip-duplicated \
--filter $(SCENARIOS_FILTER) \
--preserve-test-containers $(PRESERVE_TESTCONTAINERS)
SCRIPTSDIR=./scripts
## Testing:
.PHONY: test-global
test-global: ## Run global scenario tests.
$(DC_TEST) $(DC_TEST_GLOBAL_FLAGS) $(PATH_TO_RUN)
.PHONY: test-autogenerated
test-autogenerated: ## Run autogenerated tests for a specific feature against a base image. Arguments: FEATURES, BASE_IMAGE.
$(DC_TEST) $(DC_TEST_AUTOGENERATED_FLAGS) $(PATH_TO_RUN)
.PHONY: test-scenarios
test-scenarios: ## Run scenario tests for a specific feature. Argument: FEATURES.
$(DC_TEST) $(DC_TEST_SCENARIOS_FLAGS) $(PATH_TO_RUN)
## Build:
.PHONY: upgrade-lockfiles
upgrade-lockfiles: ## Run upgrade_lockfiles.sh script. Arguments: DRYRUN.
chmod +x $(SCRIPTSDIR)/upgrade_lockfiles.sh
$(SCRIPTSDIR)/upgrade_lockfiles.sh $(DRYRUN)
## Help:
.PHONY: help
help: GREEN := $(shell tput -Txterm setaf 2)
help: YELLOW := $(shell tput -Txterm setaf 3)
help: CYAN := $(shell tput -Txterm setaf 6)
help: RESET := $(shell tput -Txterm sgr0)
help: ## Show this help
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z0-9_\/-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)