#385 update source role documentation
Merged 3 years ago by astepano. Opened 3 years ago by bgoncalv.
bgoncalv/standard-test-roles fix-source-role  into  master

@@ -6,13 +6,17 @@ 

  can then use or execute files (usually tests) from the

  upstream sources in your playbook.

  

+ The whole playbook directory including tarball(s), patches and the spec file will be available on {{ tenv_workdir }}.

+ 

  You can redefine the following variables:

  

   * srcdir: A directory to extract sources into. This defaults

     to {{ playbook_dir }}/source/

+    This variable is ignored if fetch_only is True.

   * flatten: Strip one level of path prefix in source tree. This

     defaults to True

-  * fetch_only: If True the role will only fetch the source and will skip rpmbuild --bp part.

+    This variable is ignored if fetch_only is True.

+  * fetch_only: If True the role will fetch the source, copy files including source to test environment under {{ tenv_workdir }} and it will skip rpmbuild --bp part.

     Set to True if spec file %prep section requires packages that are not available on test runner.

     This defaults to False

  
@@ -40,22 +44,12 @@ 

      - hosts: localhost

        tags:

        - classic

-       vars:

-         # standard-test-basic directory for tests are relative to {{ tenv_workdir }}

-         tenv_workdir: /var/test

        pre_tasks:

        - import_role:

            name: standard-test-source

          vars:

            fetch_only: True

  

-       - name: Copy files including source to test environment

-         synchronize:

-           src: "{{ playbook_dir }}/.."

-           dest: "{{ tenv_workdir }}"

-           mode: push

-           ssh_args: "-o UserKnownHostsFile=/dev/null"

- 

        roles:

        - role: standard-test-basic

          required_packages:
@@ -65,11 +59,12 @@ 

          - rpm-build

          tests:

          - prepare-source:

+             # basic role uses the path from dir parameter as relative to test directory, therefore dir: "{{tenv_workdir}}" doesn't work

              dir: ./

-             run: rpmbuild -bp {{tenv_workdir}}/*.spec --nodeps --define "_sourcedir {{tenv_workdir}}" --define "_builddir {{tenv_workdir}}/source"

+             run: "rpmbuild -bp {{tenv_workdir}}/*.spec --nodeps --define '_sourcedir {{tenv_workdir}}' --define '_builddir {{tenv_workdir}}/source'"

          - flatten-source:

              dir: ./

-             run: shopt -s dotglob; mv {{tenv_workdir}}/source/*/* {{tenv_workdir}}/source

+             run: "shopt -s dotglob; mv {{tenv_workdir}}/source/*/* {{tenv_workdir}}/source"

          - smoke:

              dir: ./source

-             run: make check

+             run: "make check"

  • source role already copies files to the VM, no need to define it on test playbook

  • there is no need to set tenv_workdir in the playbooks anymore

  • Add quotes to example to make it more clear.
    Ansible requires quotes when parameter is just the ansible variable, but it is optional if it is part of string.

fix: https://pagure.io/standard-test-roles/issue/384

Suggestion: tarball(s), patches and the spec file

rebased onto 63be2a4

3 years ago

Thank you for updating the documentation.

Commit 90bd730 fixes this pull-request

Pull-Request has been merged by astepano

3 years ago