File tree Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Expand file tree Collapse file tree 3 files changed +103
-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+ matrix :
18+ include :
19+ - name : latest Ansible 5 release
20+ options : ' -e galaxy_requirements="{{ playbook_dir | dirname }}/5/galaxy-requirements.yaml"'
21+ - name : latest Ansible 6 release
22+ options : ' -e galaxy_requirements="{{ playbook_dir | dirname }}/6/galaxy-requirements.yaml"'
23+
24+ steps :
25+ - name : Check out ansible-build-data
26+ uses : actions/checkout@v3
27+ with :
28+ path : ansible-build-data
29+
30+ - name : Set up Python 3.9
31+ uses : actions/setup-python@v2
32+ with :
33+ python-version : 3.9
34+
35+ - name : Install dependencies
36+ run : |
37+ python3 -m pip install --upgrade pip
38+ python3 -m pip install ansible-core
39+
40+ - name : " Run sanity tests for ${{ matrix.name }}"
41+ run : |
42+ ansible-playbook -vv tests/collection-tests.yaml ${{ matrix.options }}
43+ 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
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