diff --git a/roles/nimble/README.rst b/roles/nimble/README.rst index 671d9c421..4dceab4f3 100644 --- a/roles/nimble/README.rst +++ b/roles/nimble/README.rst @@ -10,7 +10,22 @@ Run nimble command in a source directory. Assumes the appropriate version of nim .. zuul:rolevar:: nim_path - Path where nim and nimble are installed. + Path to a directory where nim and nimble are installed. + +.. zuul:rolevar:: nimble_use_siblings + :type: bool + :default: true + + Whether to configure nimble to build with siblings or not. + +.. zuul:rolevar:: nimble_siblings + :type: list + + List of paths to directories containing nim projects to + configure nimble with ``nimble develop``. The projects + have to be managed by nimble and contain a ``.nimble`` + file. By default this role will try to configure any + repos made available with ``job.required-projects``. .. zuul:rolevar:: zuul_work_dir :default: {{ zuul.project.src_dir }} diff --git a/roles/nimble/defaults/main.yaml b/roles/nimble/defaults/main.yaml index 63dd89c64..c5c4da803 100644 --- a/roles/nimble/defaults/main.yaml +++ b/roles/nimble/defaults/main.yaml @@ -1,2 +1,5 @@ nimble_command: build +nimble_use_siblings: true +nimble_siblings: "{{ zuul.projects.values() | selectattr('required') | map(attribute='src_dir') | list }}" zuul_work_dir: "{{ zuul.project.src_dir }}" + diff --git a/roles/nimble/tasks/main.yaml b/roles/nimble/tasks/main.yaml index e97656511..155e01e8f 100644 --- a/roles/nimble/tasks/main.yaml +++ b/roles/nimble/tasks/main.yaml @@ -1,3 +1,14 @@ +- name: Configure siblings + when: nimble_use_siblings + command: nimble develop + environment: + PATH: "{{ nim_path }}:{{ ansible_env.PATH }}" + args: + chdir: "{{ zj_nimble_siblings }}" + loop: "{{ nimble_siblings }}" + loop_control: + loop_var: zj_nimble_siblings + - name: Run nimble command: "nimble {{ nimble_command }} --accept" args: diff --git a/test-playbooks/nimble/sibling/sibling.nimble b/test-playbooks/nimble/sibling/sibling.nimble new file mode 100644 index 000000000..d50dc4707 --- /dev/null +++ b/test-playbooks/nimble/sibling/sibling.nimble @@ -0,0 +1,12 @@ +# Package + +version = "0.1.0" +author = "Albin Vass" +description = "A new awesome nimble package" +license = "MIT" +srcDir = "src" + + +# Dependencies + +requires "nim >= 1.4.2" diff --git a/test-playbooks/nimble/sibling/src/sibling.nim b/test-playbooks/nimble/sibling/src/sibling.nim new file mode 100644 index 000000000..251453c29 --- /dev/null +++ b/test-playbooks/nimble/sibling/src/sibling.nim @@ -0,0 +1,2 @@ +proc helloWorld*() = + echo "Hello world!" diff --git a/test-playbooks/nimble/src/test.nim b/test-playbooks/nimble/src/test.nim index f42ff3959..e8d5ef797 100644 --- a/test-playbooks/nimble/src/test.nim +++ b/test-playbooks/nimble/src/test.nim @@ -1 +1,3 @@ -echo "Hello world!" +import sibling + +helloWorld() diff --git a/test-playbooks/nimble/test.nimble b/test-playbooks/nimble/test.nimble index 8631c2635..85e13f89b 100644 --- a/test-playbooks/nimble/test.nimble +++ b/test-playbooks/nimble/test.nimble @@ -11,3 +11,4 @@ bin = @["test"] # Dependencies requires "nim >= 1.4.0" +requires "sibling" diff --git a/zuul-tests.d/nim-jobs.yaml b/zuul-tests.d/nim-jobs.yaml index 09af17957..e23def2a6 100644 --- a/zuul-tests.d/nim-jobs.yaml +++ b/zuul-tests.d/nim-jobs.yaml @@ -10,6 +10,8 @@ - test-playbooks/nimble vars: zuul_work_dir: '{{ zuul.project.src_dir }}/test-playbooks/nimble' + nimble_siblings: + - '{{ zuul.project.src_dir }}/test-playbooks/nimble/sibling' - job: name: zuul-jobs-test-nimble-centos-7