Fix --tobiko-refspec option in IR tobiko plugin

Change-Id: Ifaf1d5946ec2dad569faa3e205f4f50018ed63be
This commit is contained in:
Federico Ressi 2020-11-30 13:45:48 +01:00
parent d1fe262992
commit 7d5d82d02e
7 changed files with 29 additions and 48 deletions

View File

@ -37,7 +37,7 @@ subparsers:
clean:
type: Flag
help: Cleanup directory where test cases will be downloaded
ansible_variable: clean_deploy_dir
ansible_variable: deploy_clean
git-base:
type: Value
help: Git Url prefix where test projects are fetched from
@ -58,10 +58,6 @@ subparsers:
type: Value
help: Git URL from where to download test files
ansible_variable: test_git_repo
test-version:
type: Value
help: Git version to be used for checking out test scripts
ansible_variable: test_git_version
test-remote:
type: Value
help: Git remote name to be used for checking out test scripts
@ -91,10 +87,6 @@ subparsers:
help: Git URL from where to download tobiko files
ansible_variable: tobiko_git_repo
default: 'https://opendev.org/x/tobiko.git'
tobiko-version:
type: Value
help: Git version to be used for checking out Tobiko scripts
ansible_variable: tobiko_git_version
tobiko-remote:
type: Value
help: Git remote name to be used for checking out test scripts

View File

@ -1,10 +1,9 @@
---
deploy_dir: ''
deploy_clean: no
deploy_clean: '{{ (deploy_git_refspec | length) > 0 | default(false) }}'
deploy_src_dir: ''
deploy_git_repo: ''
deploy_git_version: ''
deploy_git_refspec: ''
deploy_git_remote: ''

View File

@ -5,7 +5,7 @@
path: "{{ deploy_dir | realpath }}"
state: absent
when:
- deploy_clean | bool
- (deploy_clean | bool)
- name: "ensure target directory exists: '{{ deploy_dir }}'"
@ -15,6 +15,19 @@
register: create_dest_dir
- name: "checkout files from '{{ deploy_git_repo }}[{{ deploy_git_refspec }}]' to '{{ deploy_dir }}'"
git:
dest: '{{ deploy_dir }}'
repo: '{{ deploy_git_repo }}'
refspec: '{{ deploy_git_refspec }}'
version: FETCH_HEAD
remote: '{{ deploy_git_remote or omit }}'
force: yes
register: checkout_files
when:
- (deploy_git_refspec | length) > 0
- name: "copy '{{ deploy_src_dir }}' to '{{ deploy_dir }}'"
synchronize:
src: "{{ deploy_src_dir | realpath }}/."
@ -26,27 +39,7 @@
register: copy_src_dir
when:
- (deploy_src_dir | length) > 0
- when: copy_src_dir is skipped
block:
- name: "override deploy_git_version and deploy_src_dir because deploy_git_refspec is '{{ deploy_git_refspec }}'"
set_fact:
deploy_git_version: 'FETCH_HEAD'
when: "(deploy_git_refspec | length) > 0"
- name: "checkout files from '{{ deploy_git_repo }}[{{ deploy_git_refspec | default(deploy_git_version) }}]' to '{{ deploy_dir }}'"
git:
dest: '{{ deploy_dir }}'
repo: '{{ deploy_git_repo }}'
refspec: '{{ deploy_git_refspec or omit }}'
version: '{{ deploy_git_version or omit }}'
remote: '{{ deploy_git_remote or omit }}'
force: yes
register: checkout_files
when:
- (deploy_git_version | length) > 0
- checkout_files is skipped
- name: "get last change details for '{{ deploy_dir }}'" # noqa 303
@ -60,8 +53,9 @@
- name: "show last change details"
debug: var=get_git_log.stdout_lines
#we install validations-common here since it's
#packaged by rhel-osp
# we install validations-common here since it's
# packaged by rhel-osp
- name: install validations-common
ignore_errors: yes
become: true

View File

@ -12,9 +12,8 @@
vars:
deploy_dir: '{{ tobiko_src_dir | realpath }}'
deploy_git_repo: '{{ tobiko_git_repo }}'
deploy_git_version: "{{ tobiko_git_version | default('HEAD') }}"
deploy_git_refspec: "{{ tobiko_git_refspec | default('') }}"
deploy_git_remote: '{{ tobiko_git_remote | default(omit) }}'
deploy_git_refspec: "{{ tobiko_git_refspec | default('latest') }}"
deploy_git_remote: "{{ tobiko_git_remote | default('') }}"
when: create_tobiko_dir is changed

View File

@ -0,0 +1,7 @@
---
# tobiko_git_refspec is empty to allow copying files from tobini_src_dir
tobiko_git_refspec: ''
test_git_refspec: ''
tobiko_git_remote: ''
test_git_remote: ''

View File

@ -9,13 +9,11 @@
tobiko_dir: '{{ tobiko_dir | realpath }}'
tobiko_src_dir: '{{ tobiko_src_dir | realpath }}'
tobiko_git_repo: '{{ tobiko_git_repo }}'
tobiko_git_version: "{{ tobiko_git_version }}"
tobiko_git_refspec: "{{ tobiko_git_refspec }}"
tobiko_git_remote: "{{ tobiko_git_remote }}"
test_dir: '{{ test_dir | realpath }}'
test_src_dir: '{{ test_src_dir | realpath }}'
test_git_repo: '{{ test_git_repo }}'
test_git_version: "{{ test_git_version }}"
test_git_refspec: "{{ test_git_refspec }}"
test_git_remote: "{{ test_git_remote }}"
@ -25,7 +23,6 @@
deploy_dir: '{{ tobiko_dir }}'
deploy_src_dir: '{{ tobiko_src_dir }}'
deploy_git_repo: '{{ tobiko_git_repo }}'
deploy_git_version: "{{ tobiko_git_version }}"
deploy_git_refspec: "{{ tobiko_git_refspec }}"
deploy_git_remote: '{{ tobiko_git_remote }}'
@ -35,7 +32,6 @@
deploy_dir: '{{ test_dir }}'
deploy_src_dir: '{{ test_src_dir }}'
deploy_git_repo: '{{ test_git_repo }}'
deploy_git_version: "{{ test_git_version }}"
deploy_git_refspec: "{{ test_git_refspec }}"
deploy_git_remote: '{{ test_git_remote }}'
when: test_dir != tobiko_dir

View File

@ -16,9 +16,6 @@ test_dir: "{{ test_deploy_home }}/{{ test_project }}"
test_project:
"{{ test_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
test_git_repo: '{{ git_base }}/x/tobiko.git'
test_git_refspec: ''
test_git_remote: ''
test_git_version: ''
test_src_dir: ''
@ -30,9 +27,6 @@ tobiko_dir: "{{ test_deploy_home }}/{{ tobiko_project }}"
tobiko_project:
"{{ tobiko_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
tobiko_git_repo: '{{ git_base }}/x/tobiko.git'
tobiko_git_refspec: ''
tobiko_git_remote: ''
tobiko_git_version: ''
tobiko_src_dir: ''