From 2149261e92cb4bc148ff497ab12f97e5d38b26b1 Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Tue, 3 Jan 2023 14:05:36 +0100 Subject: [PATCH] Attempt GHA communication between container using "docker host network" https://docs.github.com/en/actions/using-containerized-services/about-service-containers I re-revert the workflow to use the new custom action. But I'm not sure it will works because I don't know how the container for ansible-test is started and if it will have access to the services containers. --- .github/workflows/ansible-test-plugins.yml | 65 +++++++++++----------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ansible-test-plugins.yml b/.github/workflows/ansible-test-plugins.yml index e91c544..eb0db1b 100644 --- a/.github/workflows/ansible-test-plugins.yml +++ b/.github/workflows/ansible-test-plugins.yml @@ -85,48 +85,47 @@ jobs: - python: 3.9 ansible: stable-2.12 - # runs all of the steps inside the specified container rather than on the VM host. - # Because of this the network configuration changes from host based network to a container network. services: - mariadb105: + db_primary: image: mariadb:10.5 env: MARIADB_ROOT_PASSWORD: msandbox ports: - 3307:3306 - # needed because the mariadb container does not provide a healthcheck - options: --health-cmd mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1 + # We write our own health-cmd because the mariadb container does not + # provide a healthcheck + options: &healthcheck > + --health-cmd mysqladmin ping -P 3306 -pmsandbox + | grep alive + || exit 1 + db_replica1: + image: mariadb:10.5 + env: + MARIADB_ROOT_PASSWORD: msandbox + ports: + - 3308:3306 + options: *healthcheck + db_replica2: + image: mariadb:10.5 + env: + MARIADB_ROOT_PASSWORD: msandbox + ports: + - 3309:3306 + options: *healthcheck steps: - - name: Check out code - uses: actions/checkout@v2 + - name: >- + Perform integration testing against + Ansible version ${{ matrix.ansible }} + under Python ${{ matrix.python }} + uses: ansible-community/ansible-test-gh-action@release/v1 with: - path: ansible_collections/community/mysql - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - - name: Set Connector version (${{ matrix.connector }}) - run: "sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }}" - - # TODO, add a loop that wait on mariadb container healthcheck here - - - name: Run integration tests - run: ansible-test integration --venv -v --color --retry-on-error --continue-on-error --python ${{ matrix.python }} --diff --coverage - working-directory: ./ansible_collections/community/mysql - - - name: Generate coverage report. - run: ansible-test coverage xml -v --requirements --group-by command --group-by version - working-directory: ./ansible_collections/community/mysql - - - uses: codecov/codecov-action@v1 - with: - fail_ci_if_error: false + ansible-core-version: ${{ matrix.ansible }} + pre-test-cmd: >- + >&2 echo Setting Connector version to ${{ matrix.connector }}...; + sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }} + target-python-version: ${{ matrix.python }} + testing-type: integration units: runs-on: ubuntu-20.04