ansible test splitter #26
Workflow file for this run
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
name: Integration | |
on: | |
pull_request_target: | |
jobs: | |
splitter: | |
runs-on: ubuntu-latest | |
env: | |
source_dir: "cloud_awsops" | |
outputs: | |
test_targets: ${{ steps.display.outputs.test_targets }} | |
steps: | |
- name: Checkout collection | |
uses: actions/checkout@v3 | |
with: | |
path: ${{ env.source }} | |
- name: list changes for pull request | |
id: splitter | |
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main | |
with: | |
total_jobs: 2 | |
collections_to_test: ${{ env.source_dir }} | |
- name: display targets | |
id: display | |
run: echo "test_targets=${{ steps.splitter.outputs.test_targets }}" >> $GITHUB_OUTPUT | |
shell: bash | |
build_matrix: | |
runs-on: ubuntu-latest | |
needs: | |
- splitter | |
outputs: | |
test_matrix: ${{ steps.compute-matrix.outputs.test_matrix }} | |
test_targets: ${{ needs.splitter.outputs.test_targets }} | |
steps: | |
- name: Compute matrix | |
id: compute-matrix | |
run: | | |
import os, json | |
test_matrix=[ | |
item.split(":", maxsplit=1)[0].split('-', maxsplit=1)[1] | |
for item in os.environ.get('TEST_TARGETS').split(';') if item.split(':', maxsplit=1)[1] | |
] | |
output_path = os.environ.get('GITHUB_OUTPUT') | |
with open(output_path, "a", encoding="utf-8") as fw: | |
fw.write(f'test_matrix={json.dumps(test_matrix)}\n') | |
shell: python | |
env: | |
TEST_TARGETS: ${{ needs.splitter.outputs.test_targets }} | |
test: | |
runs-on: ubuntu-latest | |
needs: | |
- build_matrix | |
env: | |
source: "./source" | |
aws_dir: "./amazon_aws" | |
crypto_dir: "./community.crypto" | |
ansible_version: "stable-2.14" | |
python_version: "3.9" | |
strategy: | |
fail-fast: false | |
matrix: | |
workflow-id: ${{ fromJson(needs.build_matrix.outputs.test_matrix) }} | |
name: "Integration-cloud.aws_ops-py${{ env.python_version }}-${{ env.ansible_version }}-${{ matrix.workflow-id }}" | |
steps: | |
- name: Read ansible-test targets | |
id: read-targets | |
run: | | |
import os | |
workflow_test_prefix = "cloud.aws_ops-{0}:".format(os.environ.get('TEST_WORKFLOW_ID')) | |
for item in os.environ.get('TEST_TARGETS').split(';'): | |
if item.startswith(workflow_test_prefix): | |
targets=' '.join(item.split(':', maxsplit=1)[1].split(',')) | |
output_path = os.environ.get('GITHUB_OUTPUT') | |
with open(output_path, "a", encoding="utf-8") as fw: | |
fw.write(f"ansible_test_targets={targets}\n") | |
shell: python | |
env: | |
TEST_WORKFLOW_ID: "${{ matrix.workflow-id }}" | |
TEST_TARGETS: ${{ needs.build_matrix.outputs.test_targets }} | |
- name: Checkout collection | |
uses: actions/checkout@v3 | |
with: | |
path: ${{ env.source }} | |
- name: Build and install collection | |
id: install-collection | |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main | |
with: | |
install_python_dependencies: false | |
source_path: ${{ env.source }} | |
# checkout and install 'amazon.aws' | |
- name: checkout ansible-collections/amazon.aws | |
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main | |
with: | |
repository: ansible-collections/amazon.aws | |
path: ${{ env.amazon_aws }} | |
ref: main | |
- name: install amazon.aws collection | |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main | |
with: | |
install_python_dependencies: true | |
source_path: ${{ env.amazon_aws }} | |
# checkout and install 'community.crypto' | |
- name: checkout ansible-collections/community.crypto | |
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main | |
with: | |
repository: ansible-collections/community.crypto | |
path: ${{ env.crypto_dir }} | |
ref: main | |
- name: install community.crypto collection | |
uses: ansible-network/github_actions/.github/actions/build_install_collection@main | |
with: | |
install_python_dependencies: false | |
source_path: ${{ env.crypto_dir }} | |
- name: Create AWS/sts session credentials | |
uses: ansible-network/github_actions/.github/actions/ansible_aws_test_provider@main | |
with: | |
collection_path: ${{ steps.install-collection.outputs.collection_path }} | |
ansible_core_ci_key: ${{ secrets.ANSIBLE_CORE_CI_KEY }} | |
# we use raw git to create a repository in the tests | |
# this fails if the committer doesn't have a name and an email set | |
- name: Set up git | |
run: | | |
git config --global user.email gha@localhost | |
git config --global user.name "Github Actions" | |
shell: bash | |
- name: Run integration tests | |
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main | |
with: | |
collection_path: ${{ steps.install-collection.outputs.collection_path }} | |
python_version: ${{ env.python_version }} | |
ansible_version: ${{ env.ansible_version }} | |
ansible_test_requirement_files: 'test-requirements.txt' |