Created
May 3, 2022 11:41
-
-
Save hem-brahmbhatt/c9a31e50db607b9f133cbef5e83b3181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This makefile would be used to run command from circleci | |
| .DEFAULT_GOAL := help | |
| GOSS_VERSION=0.3.6 | |
| .PHONY: build | |
| build: ## Builds docker image, ie. IMAGE_NAME=wd-tools MODULE_PATH=wd-tools/ make build | |
| docker build -t $(IMAGE_NAME):node12 $(MODULE_PATH) | |
| .PHONY: test | |
| test: ## Tests image. Execute make build first, ie. IMAGE_NAME=wd-tools MODULE_PATH=wd-tools/ make test | |
| docker run -i --rm \ | |
| -v $(PWD)/$(MODULE_PATH):/src \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| -e GOSS_FILES_STRATEGY=cp \ | |
| -e GOSS_FILES_PATH=/src \ | |
| kiwicom/dgoss:$(GOSS_VERSION) dgoss run --rm -i $(IMAGE_NAME) | |
| .PHONY: test-edit | |
| test-edit: ## Edit tests using goss, ie. IMAGE_NAME=wd-tools MODULE_PATH=wd-tools/ make test-edit | |
| docker run --rm -it \ | |
| -v $(PWD)/$(MODULE_PATH):/src \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| -e GOSS_FILES_STRATEGY=cp \ | |
| -e GOSS_FILES_PATH=/src \ | |
| kiwicom/dgoss:$(GOSS_VERSION) dgoss edit --rm -it $(IMAGE_NAME) | |
| .PHONY: load | |
| load: ## Loads saved tar file so it can be pushed to artifactory, ie. DOCKER_ARCHIVE_NAME=wd-tools.tar make load | |
| docker load -i $(DOCKER_ARCHIVE_NAME) | |
| .PHONY: save-local | |
| save-local: ## Saves copy of the docker image, ie. DOCKER_ARCHIVE_NAME=wd-tools.tar IMAGE_NAME=wd-tools make save-local | |
| docker save $(IMAGE_NAME):latest -o $(DOCKER_ARCHIVE_NAME) | |
| .PHONY: push | |
| push: ## Pushes the image to artifactory, ie. IMAGE_NAME=wd-tools make push | |
| docker push $(IMAGE_NAME):node12 | |
| .PHONY: validate-circleci | |
| validate-circleci: ## Validates the circleci config at ./circleci/config.yaml e.g. TOKEN=<TOKEN> make validate-circleci | |
| @[ "$(TOKEN)" ] || ( echo ">> CircleCI Token 'TOKEN' is not set"; exit 1 ) | |
| docker run --rm -v $(shell pwd):/data circleci/circleci-cli:alpine config validate /data/.circleci/config.yml --token $(TOKEN) | |
| .PHONY: help | |
| help: # parse jobs and descriptions from this Makefile | |
| @grep -E '^[ a-zA-Z0-9_-]+:([^=]|$$)' $(MAKEFILE_LIST) \ | |
| | grep -Ev '^(help)\b[[:space:]]*:' \ | |
| | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m \t%s\n", $$1, $$2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment