From ac6dc08ad4a2db63c6c1729d1dab45a7430fba18 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 18 Jan 2020 02:50:47 -0400 Subject: [PATCH] Add makefile target to run GitLab CI jobs locally Requires installing the OS gitlab-runner package, and Docker. Signed-off-by: Roberto Rosario --- .gitignore | 1 + HISTORY.rst | 1 + Makefile | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 41c58947cd2..bbd915bc0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ node_modules/ docs/build/ docs/_templates/layout.html docs/_templates/footer.html +gitlab-ci-volume/ diff --git a/HISTORY.rst b/HISTORY.rst index 5be649ce35e..404334bb913 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,7 @@ - Cleanup repository top level. Moved helper scripts to contrib/scripts. - Add makefile target to make it easier to create the code coverage report. - Remove unused Magnum and Travis CI files. +- Add makefile target to run GitLab CI jobs locally. 3.3.8 (2020-01-17) ================== diff --git a/Makefile b/Makefile index 06d65a4e7ef..146ef253bf9 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,6 @@ test-with-mysql: test-launch-mysql @docker rm -f test-mysql || true @docker volume rm test-mysql || true - test-with-mysql-all: ## Run all tests against a MySQL database container. test-with-mysql-all: test-launch-mysql ./manage.py test --mayan-apps --settings=mayan.settings.testing.docker.db_mysql --nomigrations @@ -106,6 +105,16 @@ test-with-oracle-all: test-launch-oracle @docker rm -f test-oracle || true @docker volume rm test-oracle || true +gitlab-ci-run: ## Execute a GitLab CI job locally +gitlab-ci-run: + @if [ -z "$$(docker images gitlab-runner-helper:11.2.0)" ]; then \ + echo "1) Make sure to download the corresponding helper image from https://hub.docker.com/r/gitlab/gitlab-runner-helper/tags"; \ + echo "2) Tag the download image as gitlab-runner-helper:11.2.0"; \ + exit 1; \ + fi; \ + if [ -z $(GITLAB_CI_JOB) ]; then echo "Specify the job to execute using GITLAB_CI_JOB."; exit 1; fi; \ + gitlab-runner exec docker --docker-volumes $$PWD/gitlab-ci-volume:/builds $(GITLAB_CI_JOB) + # Coverage coverage-run: ## Run all tests and measure code execution.