mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
pkgng: clean up test package creation
Make pkg json manifest more readable. Create package using FreeBSD's `pkg create` instead of manually using tar. This change also simplifies the manifest to a single file for the integration test role.
This commit is contained in:
parent
ad42951b66
commit
75212ad73d
5 changed files with 46 additions and 32 deletions
|
@ -1,34 +1,35 @@
|
||||||
---
|
---
|
||||||
- name: Check if out-of-date test package has already been created
|
- name: Create temporary directory for package creation
|
||||||
stat:
|
tempfile:
|
||||||
path: '{{ pkgng_test_outofdate_pkg_path }}'
|
|
||||||
register: pkgng_test_outofdate_pkg_stat
|
|
||||||
|
|
||||||
- name: Create out-of-date test package
|
|
||||||
when: not pkgng_test_outofdate_pkg_stat.stat.exists
|
|
||||||
block:
|
|
||||||
- set_fact:
|
|
||||||
pkgng_test_outofdate_pkg_tempdir: '{{ pkgng_test_outofdate_pkg_path }}__tempdir'
|
|
||||||
|
|
||||||
- name: Create temporary directory to assemble test package
|
|
||||||
file:
|
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ pkgng_test_outofdate_pkg_tempdir }}'
|
register: pkgng_test_outofdate_pkg_tempdir
|
||||||
|
|
||||||
- name: Copy intentionally out-of-date package manifests to testhost
|
- name: Copy intentionally out-of-date package manifest to testhost
|
||||||
template:
|
template:
|
||||||
src: test_package_manifests/{{ item }}.json.j2
|
src: MANIFEST.json.j2
|
||||||
# Plus-sign must be added at the destination
|
# Plus-sign must be added at the destination
|
||||||
# CI doesn't like files with '+' in them in the repository
|
# CI doesn't like files with '+' in them in the repository
|
||||||
dest: '{{ pkgng_test_outofdate_pkg_tempdir }}/+{{ item }}'
|
dest: '{{ pkgng_test_outofdate_pkg_tempdir.path }}/MANIFEST'
|
||||||
loop:
|
|
||||||
- COMPACT_MANIFEST
|
|
||||||
- MANIFEST
|
|
||||||
|
|
||||||
- name: Create out-of-date test package file
|
- name: Create out-of-date test package file
|
||||||
command: 'tar -C {{ pkgng_test_outofdate_pkg_tempdir }} -cJf {{ pkgng_test_outofdate_pkg_path }} +COMPACT_MANIFEST +MANIFEST'
|
command:
|
||||||
|
argv:
|
||||||
|
- pkg
|
||||||
|
- create
|
||||||
|
- '--verbose'
|
||||||
|
- '--out-dir'
|
||||||
|
- '{{ pkgng_test_outofdate_pkg_tempdir.path }}'
|
||||||
|
- '--manifest'
|
||||||
|
- '{{ pkgng_test_outofdate_pkg_tempdir.path }}/MANIFEST'
|
||||||
|
warn: no
|
||||||
|
|
||||||
|
- name: Copy the created package file to the expected location
|
||||||
|
copy:
|
||||||
|
remote_src: yes
|
||||||
|
src: '{{ pkgng_test_outofdate_pkg_tempdir.path }}/{{ pkgng_test_pkg_name }}-0.pkg'
|
||||||
|
dest: '{{ pkgng_test_outofdate_pkg_path }}'
|
||||||
|
|
||||||
- name: Remove temporary directory
|
- name: Remove temporary directory
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{ pkgng_test_outofdate_pkg_tempdir }}'
|
path: '{{ pkgng_test_outofdate_pkg_tempdir.path }}'
|
||||||
|
|
16
tests/integration/targets/pkgng/templates/MANIFEST.json.j2
Normal file
16
tests/integration/targets/pkgng/templates/MANIFEST.json.j2
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "{{ pkgng_test_pkg_name }}",
|
||||||
|
"origin": "{{ pkgng_test_pkg_category }}/{{ pkgng_test_pkg_name }}",
|
||||||
|
"version": "{{ pkgng_test_pkg_version | default('0') }}",
|
||||||
|
"comment": "{{ pkgng_test_pkg_name }} (Ansible Integration Test Package)",
|
||||||
|
"maintainer": "ansible-devel@googlegroups.com",
|
||||||
|
"www": "https://github.com/ansible-collections/community.general",
|
||||||
|
"abi": "FreeBSD:*:*",
|
||||||
|
"arch": "freebsd:*:*",
|
||||||
|
"prefix": "/usr/local",
|
||||||
|
"flatsize":0,
|
||||||
|
"licenselogic": "single",
|
||||||
|
"licenses":["GPLv3"],
|
||||||
|
"desc": "This package is only installed temporarily for integration testing of the community.general.pkgng Ansible module.\nIts version number is 0 so that ANY version of the real package, with the same name, will be considered an upgrade.\nIts architecture and abi are FreeBSD:*:* so that it will install on any version or architecture of FreeBSD,\nthus future-proof as long as the package MANIFEST format does not change\nand a wildcard in the version portion of the abi or arch field is not prohibited.",
|
||||||
|
"categories":["{{ pkgng_test_pkg_category }}"]
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
{{ '{' }}{% include "test_package_metadata.j2" -%}{{ '}' }}
|
|
|
@ -1 +0,0 @@
|
||||||
{{ '{' }}{% include "test_package_metadata.j2" -%},"files":{}{{ '}' }}
|
|
|
@ -1 +0,0 @@
|
||||||
"name":"{{ pkgng_test_pkg_name }}","origin":"{{ pkgng_test_pkg_category }}/{{ pkgng_test_pkg_name }}","version":"0","comment":"{{ pkgng_test_pkg_name }} (Ansible Integration Test Package)","maintainer":"ansible-devel@googlegroups.com","www":"https://github.com/ansible-collections/community.general","abi":"FreeBSD:*:*","arch":"freebsd:*:*","prefix":"/usr/local","flatsize":0,"licenselogic":"single","licenses":["GPLv3"],"desc":"This package is only installed temporarily for integration testing of the community.general.pkgng Ansible module.\nIts version number is 0 so that ANY version of the real package, with the same name, will be considered an upgrade.\nIts architecture and abi are FreeBSD:*:* so that it will install on any version or architecture of FreeBSD,\nthus future-proof as long as the package MANIFEST format does not change\nand a wildcard in the version portion of the abi or arch field is not prohibited.","categories":["{{ pkgng_test_pkg_category }}"]
|
|
Loading…
Reference in a new issue