From 7152c144461026459bf3dbf1107ee762ce6902d8 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Tue, 19 Mar 2024 12:43:37 -0300 Subject: [PATCH] Improve Makefile --- Makefile | 43 +++++++++++++++++++++++++++++-------------- README.md | 14 ++++++++++++++ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 6ff7372..e51ef74 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,30 @@ -.PHONY: lint run test +.PHONY: \ + __build_lint_ansible \ + __build_lint_sh \ + __build_lint_tests \ + lint \ + lint-fix \ + run \ + test + +DOCKER_RUN := docker run --rm -v $$(pwd):/code --name +DOCKER_BUILD := docker build -q -f + +__build_lint_sh: + @$(DOCKER_BUILD) .docker/lint-sh.Dockerfile -t lint-sh . + +__build_lint_ansible: + $(DOCKER_BUILD) .docker/lint-ansible.Dockerfile -t lint-ansible . + +__build_lint_tests: + @$(DOCKER_BUILD) .docker/tests.Dockerfile -t tests . + +lint: __build_lint_ansible __build_lint_sh + $(DOCKER_RUN) dotfiles-lint-ansible lint-ansible + $(DOCKER_RUN) dotfiles-lint-sh lint-sh ./scripts/lint-sh.sh + +lint-fix: __build_lint_sh + @$(DOCKER_RUN) dotfiles-lint-sh lint-sh shfmt -l -w . run: ansible-playbook \ @@ -9,16 +35,5 @@ run: -i inventory.ini \ playbook.yml -lint: - @docker build -q -f .docker/lint-ansible.Dockerfile -t lint-ansible . - @docker build -q -f .docker/lint-sh.Dockerfile -t lint-sh . - @docker run --rm --name dotfiles-lint-ansible -v $$(pwd):/code lint-ansible - @docker run --rm --name dotfiles-lint-sh -v $$(pwd):/code lint-sh ./scripts/lint-sh.sh - -lint-fix: - @docker build -q -f .docker/lint-sh.Dockerfile -t lint-sh . - @docker run --rm --name dotfiles-lint-sh -v $$(pwd):/code lint-sh shfmt -l -w . - -test: - @docker build -q -f .docker/tests.Dockerfile -t tests . - @docker run --rm --name tests -v $$(pwd):/code tests +test: __build_lint_tests + @$(DOCKER_RUN) dotfiles-tests tests diff --git a/README.md b/README.md index 5296578..83b1723 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ status](https://github.com/deniscostadsc/dotfiles/actions/workflows/ci.yml/badge - [Docker](#docker) - [Git](#git) - [SSH](#ssh) + - [Development](#development) + - [Running the tests](#running-the-tests) - [Troubleshooting](#troubleshooting) - [Pop!\_os](#pop_os) - [Could not import python modules: apt, apt\_pkg. Please install python3-apt package.](#could-not-import-python-modules-apt-apt_pkg-please-install-python3-apt-package) @@ -171,6 +173,18 @@ Look at [git role README](roles/git/README.md) To enable the coexistance of two SSH keys, one for work and one for personal purposes, I set the work SSH key to impact only the domain `work.github.com`. For that reason, after I clone the repositories from work I need to change the remote URL to add the suffix `work.`. +## Development + +### Running the tests + +There are make tasks to run lint and tests + +``` +make lint +make lint-fix +make test +``` + ## Troubleshooting ### Pop!_os