-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream CI: run PR tests only for affected plugins
The current workflow for bug fixing or new enhancements in ansible-freeipa includes running Ansible playbooks tests for all the available plugins for every pull request, even for contained modifications. This patch creates a new workflow for pull requests where only the affected plugins are tested in the PR. Changes that might affect other parts of the code will trigger tests for the parts affected. A utility script, utils/filter_tests, is used to set the variables IPA_ENABLED_MODULES and IPA_ENABLED_TESTS before executing the tests, effectively limiting which tests are executed. The script uses the python plugin 'utils/filter_plugins.py' which lists all test modules that should be executed for a list of modified source files. Tests are selected for execution based on the plugin name. For example, a change to 'plugins/modules/ipalocation.py' would trigger all playbook tests under 'tests/location'. If a test playbook is modified, it is scheduled to be executed. Changes to any file under 'plugins/module_utils' will force the execution of all tests, since any module might be affected by that change. The nature of the change is not evaluated, so a simple typo fix of a comment in a file under 'plugins/module_utils' would still schedule all test playbooks to be executed. For roles, any file changed under the role directory would set the role to be included in the tests. Playbook tests for roles must be created under 'tests/<rolename>_role', where role name in the name of the role without 'ipa', for example, the 'ipabackup' role test playbooks would be stored under 'tests/backup_role'. Since there is the possibility that the list of tests to be executed might be less than the number of tests groups used (3), a new pytest dependency was added, pytest-custom_exit_code, so that having no tests to run isn't a test failure. A new pipeline on Azure needs to be created to use the new test script.
- Loading branch information
Showing
6 changed files
with
450 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
trigger: | ||
- master | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
stages: | ||
|
||
# Fedora | ||
|
||
- stage: Fedora_Latest | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: fedora-latest | ||
ansible_version: "-core >=2.12,<2.13" | ||
|
||
# Galaxy on Fedora | ||
|
||
- stage: Galaxy_Fedora_Latest | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: fedora-latest | ||
ansible_version: "-core >=2.12,<2.13" | ||
|
||
# CentOS 9 Stream | ||
|
||
- stage: CentOS_9_Stream | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: c9s | ||
ansible_version: "-core >=2.12,<2.13" | ||
|
||
# CentOS 8 Stream | ||
|
||
- stage: CentOS_8_Stream | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: c8s | ||
ansible_version: "-core >=2.12,<2.13" | ||
|
||
# CentOS 7 | ||
|
||
- stage: CentOS_7 | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: centos-7 | ||
ansible_version: "-core >=2.12,<2.13" | ||
|
||
# Rawhide | ||
|
||
- stage: Fedora_Rawhide | ||
dependsOn: [] | ||
jobs: | ||
- template: templates/fast_tests.yml | ||
parameters: | ||
build_number: $(Build.BuildNumber) | ||
scenario: fedora-rawhide | ||
ansible_version: "-core >=2.12,<2.13" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
parameters: | ||
- name: scenario | ||
type: string | ||
default: fedora-latest | ||
- name: build_number | ||
type: string | ||
- name: ansible_version | ||
type: string | ||
default: "" | ||
|
||
jobs: | ||
- template: playbook_fast.yml | ||
parameters: | ||
group_number: 1 | ||
number_of_groups: 3 | ||
build_number: ${{ parameters.build_number }} | ||
scenario: ${{ parameters.scenario }} | ||
ansible_version: ${{ parameters.ansible_version }} | ||
|
||
- template: playbook_fast.yml | ||
parameters: | ||
group_number: 2 | ||
number_of_groups: 3 | ||
build_number: ${{ parameters.build_number }} | ||
scenario: ${{ parameters.scenario }} | ||
ansible_version: ${{ parameters.ansible_version }} | ||
|
||
- template: playbook_fast.yml | ||
parameters: | ||
group_number: 3 | ||
number_of_groups: 3 | ||
build_number: ${{ parameters.build_number }} | ||
scenario: ${{ parameters.scenario }} | ||
ansible_version: ${{ parameters.ansible_version }}z | ||
|
||
# - template: pytest_tests.yml | ||
# parameters: | ||
# build_number: ${{ parameters.build_number }} | ||
# scenario: ${{ parameters.scenario }} | ||
# ansible_version: ${{ parameters.ansible_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
parameters: | ||
- name: group_number | ||
type: number | ||
default: 1 | ||
- name: number_of_groups | ||
type: number | ||
default: 1 | ||
- name: scenario | ||
type: string | ||
default: fedora-latest | ||
- name: ansible_version | ||
type: string | ||
default: "" | ||
- name: python_version | ||
type: string | ||
default: 3.x | ||
- name: build_number | ||
type: string | ||
|
||
jobs: | ||
- job: Test_Group${{ parameters.group_number }} | ||
displayName: Run playbook tests ${{ parameters.scenario }} (${{ parameters.group_number }}/${{ parameters.number_of_groups }}) | ||
timeoutInMinutes: 120 | ||
variables: | ||
- template: variables.yaml | ||
- template: variables_${{ parameters.scenario }}.yaml | ||
steps: | ||
- task: UsePythonVersion@0 | ||
inputs: | ||
versionSpec: '${{ parameters.python_version }}' | ||
|
||
- script: | | ||
pip install \ | ||
"molecule[docker]>=3" \ | ||
"ansible${{ parameters.ansible_version }}" | ||
displayName: Install molecule and Ansible | ||
- script: ansible-galaxy collection install community.docker ansible.posix | ||
displayName: Install Ansible collections | ||
|
||
- script: pip install -r requirements-tests.txt | ||
displayName: Install dependencies | ||
|
||
- script: | | ||
mkdir -p ~/.ansible/roles ~/.ansible/library ~/.ansible/module_utils | ||
cp -a roles/* ~/.ansible/roles | ||
cp -a plugins/modules/* ~/.ansible/library | ||
cp -a plugins/module_utils/* ~/.ansible/module_utils | ||
molecule create -s ${{ parameters.scenario }} | ||
displayName: Setup test container | ||
env: | ||
ANSIBLE_LIBRARY: ./molecule | ||
- script: | | ||
. utils/set_test_modules | ||
python utils/check_test_configuration.py ${{ parameters.scenario }} | ||
displayName: Check scenario test configuration | ||
- script: | | ||
. utils/set_test_modules | ||
if ! pytest \ | ||
-m "playbook" \ | ||
--verbose \ | ||
--color=yes \ | ||
--suppress-no-test-exit-code \ | ||
--splits=${{ parameters.number_of_groups }} \ | ||
--group=${{ parameters.group_number }} \ | ||
--junit-xml=TEST-results-group-${{ parameters.group_number }}.xml | ||
then | ||
[ $? -eq 5 ] && true || false | ||
fi | ||
displayName: Run playbook tests | ||
env: | ||
IPA_SERVER_HOST: ${{ parameters.scenario }} | ||
RUN_TESTS_IN_DOCKER: true | ||
IPA_DISABLED_MODULES: ${{ variables.ipa_disabled_modules }} | ||
IPA_DISABLED_TESTS: ${{ variables.ipa_disabled_tests }} | ||
- task: PublishTestResults@2 | ||
inputs: | ||
mergeTestResults: true | ||
testRunTitle: PlaybookTests-Build${{ parameters.build_number }} | ||
condition: succeededOrFailed() |
Oops, something went wrong.