File tree Expand file tree Collapse file tree 3 files changed +104
-0
lines changed Expand file tree Collapse file tree 3 files changed +104
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Sanity tests
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ pull_request :
7
+ branches : [main]
8
+ # Run once per week (Monday at 04:00 UTC)
9
+ schedule :
10
+ - cron : ' 0 4 * * 1'
11
+
12
+ jobs :
13
+ build :
14
+ name : ' ${{ matrix.name }}'
15
+ runs-on : ubuntu-latest
16
+ strategy :
17
+ fail-fast : false
18
+ matrix :
19
+ include :
20
+ - name : latest Ansible 5 release
21
+ options : ' -e galaxy_requirements="{{ playbook_dir | dirname }}/5/galaxy-requirements.yaml"'
22
+ - name : latest Ansible 6 release
23
+ options : ' -e galaxy_requirements="{{ playbook_dir | dirname }}/6/galaxy-requirements.yaml"'
24
+
25
+ steps :
26
+ - name : Check out ansible-build-data
27
+ uses : actions/checkout@v3
28
+ with :
29
+ path : ansible-build-data
30
+
31
+ - name : Set up Python 3.9
32
+ uses : actions/setup-python@v2
33
+ with :
34
+ python-version : 3.9
35
+
36
+ - name : Install dependencies
37
+ run : |
38
+ python3 -m pip install --upgrade pip
39
+ python3 -m pip install ansible-core
40
+
41
+ - name : " Run sanity tests for ${{ matrix.name }}"
42
+ run : |
43
+ ansible-playbook -vv tests/collection-tests.yaml ${{ matrix.options }}
44
+ working-directory : ansible-build-data
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Run tests on packaged collections
3
+ hosts : localhost
4
+ gather_facts : false
5
+ vars :
6
+ galaxy_requirements : " {{ playbook_dir | dirname }}/6/galaxy-requirements.yaml"
7
+ collections_path : /tmp/ansible_collections
8
+ tasks :
9
+ - name : Get list of installed packages to verify if podman is installed
10
+ package_facts :
11
+ manager : " auto"
12
+ # This is noisy (and potentially sensitive) to print on stdout
13
+ no_log : true
14
+
15
+ # This is so we can otherwise run unprivileged if podman is already installed
16
+ - when : " 'podman' not in ansible_facts['packages'].keys()"
17
+ become : true
18
+ block :
19
+ - name : Install podman
20
+ package :
21
+ name : podman
22
+ state : present
23
+ rescue :
24
+ - name : Could not install podman
25
+ fail :
26
+ msg : |
27
+ Failed to elevate privileges and install podman.
28
+ Install podman manually or run ansible-playbook with elevated privileges.
29
+
30
+ - name : Install collections from galaxy
31
+ environment :
32
+ ANSIBLE_COLLECTIONS_PATH : " {{ collections_path }}"
33
+ command : ansible-galaxy collection install -r {{ galaxy_requirements }}
34
+ args :
35
+ creates : " {{ collections_path }}"
36
+
37
+ # ansible.builtin.find doesn't have mindepth
38
+ # https://github.com/ansible/ansible/issues/36369
39
+ - name : Find collection directories
40
+ command : find {{ collections_path }} -mindepth 2 -maxdepth 2 -type d
41
+ changed_when : false
42
+ register : _collection_directories
43
+
44
+ # Tests are broken up such that there is a task per collection (instead of one very long task)
45
+ - name : Run sanity tests
46
+ include_tasks : tasks/sanity-tests.yaml
47
+ loop : " {{ _collection_directories.stdout_lines }}"
48
+ loop_control :
49
+ loop_var : _collection_directory
Original file line number Diff line number Diff line change
1
+ - name : " Run sanity tests for {{ _collection_name }}"
2
+ vars :
3
+ _collection_name : >-
4
+ {%- set _namespace = _collection_directory.split('/')[-2] -%}
5
+ {%- set _name = _collection_directory.split('/')[-1] -%}
6
+ {{ _namespace }}.{{ _name }}
7
+ command : ansible-test sanity --skip-test pylint --docker --color yes
8
+ changed_when : false
9
+ ignore_errors : true
10
+ args :
11
+ chdir : " {{ _collection_directory }}"
You can’t perform that action at this time.
0 commit comments