From c500e20aa2e073882f67444a7e3d4a9e96ee49cc Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Mon, 7 Oct 2024 17:49:42 +0200 Subject: [PATCH] add support for removing test files --- roles/redmine/defaults/main.yml | 16 ++++++++++++++++ roles/redmine/tasks/instance_plugin.yml | 24 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/roles/redmine/defaults/main.yml b/roles/redmine/defaults/main.yml index 0d182eb..2ea8ce2 100644 --- a/roles/redmine/defaults/main.yml +++ b/roles/redmine/defaults/main.yml @@ -286,6 +286,22 @@ redmine_write_permission_dirs: redmine_plugin_access: readonly +redmine_plugin_remove_test_files: false +redmine_plugin_test_files: + - .git + - .gitignore + - test + - Gemfile.release + - eslint.config.cjs + - package.json + - .flayignore + - .gitlab-ci.yml + - .reek.yml + - .rubocop.yml + - .slim-lint.yml + - .stylelintrc.json + - .rails_best_practices.yml + # https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/AsyncAdapter.html redmine_queue_adapter: async diff --git a/roles/redmine/tasks/instance_plugin.yml b/roles/redmine/tasks/instance_plugin.yml index 38612bd..70831d7 100644 --- a/roles/redmine/tasks/instance_plugin.yml +++ b/roles/redmine/tasks/instance_plugin.yml @@ -22,9 +22,31 @@ state: absent loop: '{{ plugin["remove_plugins"] | default([]) }}' +- name: Set plugin target path for {{ plugin_name }} + ansible.builtin.set_fact: + plugin_target_path: '{{ redmine_plugin_dir }}/{{ plugin["target_dir"] | default(plugin_name) }}' + +# this is required, because with git you can restore dev/test files +- name: Remove plugin dir before git fetch for product plugins {{ plugin_name }} + file: + path: '{{ plugin_target_path }}' + state: absent + when: + - redmine_plugin_remove_test_files + - plugin["product"] is defined and plugin["product"] + - name: Run remote deploy for plugin - {{ instance_name }} ansible.builtin.include_tasks: task_remote_deploy.yml vars: repo_url: '{{ plugin[preferred_git_url] | default(plugin["url"]) }}' - repo_dest: '{{ redmine_plugin_dir }}/{{ plugin["target_dir"] | default(plugin_name) }}' + repo_dest: '{{ plugin_target_path }}' repo_version: '{{ plugin["dev_version"] if instance.plugin_version is defined and instance.plugin_version == "dev" and plugin["dev_version"] is defined else plugin["version"] }}' + +- name: Remove test files for {{ plugin_name }} + file: + path: '{{ plugin_target_path }}/{{ item }}' + state: absent + loop: '{{ redmine_plugin_test_files }}' + when: + - redmine_plugin_remove_test_files + - plugin["product"] is defined and plugin["product"]