Update tobiko-deploy role

Change-Id: If4e5a74dcc90b18d060c4f8bf4f0a170d881d9d1
This commit is contained in:
Federico Ressi 2020-04-17 13:51:33 +02:00
parent ee2cbbbd1d
commit cfc5bc2607
4 changed files with 36 additions and 16 deletions

View File

@ -49,6 +49,10 @@ subparsers:
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
ansible_variable: test_git_remote
test-refspec:
type: Value
help: Git refspect to be used for checking out test scripts
@ -69,6 +73,10 @@ subparsers:
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
ansible_variable: tobiko_git_remote
tobiko-refspec:
type: Value
help: Git refspect to be used for checking out Tobiko scripts

View File

@ -16,9 +16,11 @@ 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: 'origin'
test_git_version: 'master'
test_src_dir: ''
# NOTE: if test_dir and tobiko_dir variables endup being the same actual
# directory then test_src and test_git_* variables will be overriden
# tobiko_src and tobiko_git_* variables
@ -28,6 +30,7 @@ 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: 'origin'
tobiko_git_version: 'master'
tobiko_src_dir: ''

View File

@ -10,6 +10,7 @@ test_deploy_dirs:
dest_dir: '{{ test_dir }}'
git_repo: '{{ test_git_repo }}'
git_refspec: '{{ test_git_refspec }}'
git_remote: '{{ test_git_remote }}'
git_version: '{{ test_git_version }}'
src_dir: '{{ test_src_dir }}'
@ -18,6 +19,7 @@ test_deploy_dirs:
dest_dir: '{{ tobiko_dir }}'
git_repo: '{{ tobiko_git_repo }}'
git_refspec: '{{ tobiko_git_refspec }}'
git_remote: '{{ tobiko_git_remote }}'
git_version: '{{ tobiko_git_version }}'
src_dir: '{{ tobiko_src_dir }}'

View File

@ -14,13 +14,32 @@
state: absent
when:
- clean_dir | bool
- (src_dir | length) == 0
- name: "create directory '{{ dest_dir }}'"
file:
path: "{{ dest_dir | realpath }}"
state: directory
register: create_dest_dir
- name: "override git_version and src_dir because git_refspec is '{{ git_refspec }}'"
set_fact:
git_version: 'FETCH_HEAD'
src_dir: ''
when: '(git_refspec | length) > 0'
- name: "checkout files from '{{ git_repo }}[{{ git_refspec or git_version }}]' to '{{ dest_dir }}'"
git:
dest: '{{ dest_dir }}'
repo: '{{ git_repo }}'
refspec: '{{ git_refspec }}'
version: '{{ git_version }}'
remote: '{{ git_remote }}'
force: yes
register: checkout_files
when: '((src_dir | length) == 0) or (create_dest_dir is changed)'
- name: "copy '{{ src_dir }}' to '{{ dest_dir }}'"
@ -31,21 +50,9 @@
recursive: yes
delete: "{{ clean_dir | bool }}"
rsync_opts:
- "--exclude-from={{ src_dir | realpath }}/.gitignore"
register: copied_dir
when:
- (src_dir | length) > 0
- name: "checkout test cases from '{{ git_repo }}[{{ git_refspec or git_version }}]' to '{{ dest_dir }}'"
git:
dest: '{{ dest_dir }}'
repo: '{{ git_repo }}'
refspec: '{{ git_refspec }}'
version: '{%if (git_refspec | length) %}FETCH_HEAD{% elif (git_version | length) %}{{ git_version }}{% else %}master{% endif %}'
force: yes
when:
- copied_dir is not defined
- '--exclude-from={{ src_dir | realpath }}/.gitignore'
register: copy_src_dir
when: '(src_dir | length) > 0'
- name: "get last change details for '{{ dest_dir }}'" # noqa 303