From 77ff01123e64e42d227c3d3cc0671bd74773aacc Mon Sep 17 00:00:00 2001 From: Ana Zobec Date: Tue, 7 Mar 2023 09:25:35 +0100 Subject: [PATCH 1/6] Add examples run to workflow. --- .github/workflows/integ-test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index faf67c649..a2a2e07cc 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -43,6 +43,8 @@ jobs: env: DEBIAN_FRONTEND: noninteractive ANSIBLE_COLLECTIONS_PATH: /work-dir + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Checkout uses: actions/checkout@v3 @@ -65,6 +67,13 @@ jobs: ls -al tests/integration/integration_config.yml - run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_iso.yml - run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_vm.yml + + - id: set-matrix + shell: bash + run: |- + echo "matrix=$( + ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' + )" >> $GITHUB_OUTPUT if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}" integ-matrix: @@ -101,6 +110,7 @@ jobs: integ: needs: - integ-matrix + - integration-prepare-env # - units-test runs-on: [self-hosted2] container: python:3.10-slim-buster @@ -113,6 +123,7 @@ jobs: # python: [3.11] # test_name: [user_info] test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} + example_name: ${{ fromJson(needs.integration-prepare-env.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 @@ -138,6 +149,8 @@ jobs: echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml ls -al tests/integration/integration_config.yml - run: cd $WORKDIR && ansible-test integration --local ${{ matrix.test_name }} + - run: cd $WORKDIR && ansible-playbook --check ${{ matrix.example_name }} + replica_cleanup: needs: From 3821bddf66cc4adaf5684b098a800d5721809783 Mon Sep 17 00:00:00 2001 From: Ana Zobec Date: Tue, 7 Mar 2023 10:30:01 +0100 Subject: [PATCH 2/6] Update previously added examples run. --- .github/workflows/integ-test.yml | 43 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index a2a2e07cc..1cc528ed4 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -27,6 +27,8 @@ on: env: INTEG_TESTS_INCLUDE_SCHEDULE: "*" INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_" + EXAMPLES_INCLUDE: "*" + EXAMPLES_EXCLUDE: "^version_update_single_node$|^cluster_config$" WORKDIR: /work-dir/ansible_collections/scale_computing/hypercore # Run only one workflow for specific branch. concurrency: @@ -43,8 +45,6 @@ jobs: env: DEBIAN_FRONTEND: noninteractive ANSIBLE_COLLECTIONS_PATH: /work-dir - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Checkout uses: actions/checkout@v3 @@ -67,13 +67,6 @@ jobs: ls -al tests/integration/integration_config.yml - run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_iso.yml - run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_vm.yml - - - id: set-matrix - shell: bash - run: |- - echo "matrix=$( - ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' - )" >> $GITHUB_OUTPUT if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}" integ-matrix: @@ -107,10 +100,38 @@ jobs: )" >> $GITHUB_OUTPUT if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}" + examples-matrix: + runs-on: [ ubuntu-latest ] + container: python:3.10-slim-buster + env: + DEBIAN_FRONTEND: noninteractive + ANSIBLE_COLLECTIONS_PATH: /work-dir + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - run: apt update + - run: apt install -y jq + - run: mkdir -p $WORKDIR + - run: cp -a ./ $WORKDIR + # We want to run all integ tests periodically - "integ_tests_include || '*'", the '*' is used. + # When running with workflow-dispatch, user is required to put some non-empty string into integ_tests_include. + - run: echo 'EXAMPLES_INCLUDE=${{ github.event.inputs.integ_tests_include || env.EXAMPLES_INCLUDE }}' >> $GITHUB_ENV + - run: echo 'EXAMPLES_EXCLUDE=${{ github.event.inputs.integ_tests_exclude || env.EXAMPLES_EXCLUDE }}' >> $GITHUB_ENV + + - id: set-matrix + shell: bash + run: |- + echo "matrix=$( + ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' + )" >> $GITHUB_OUTPUT + if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}" + integ: needs: - integ-matrix - - integration-prepare-env + - examples-matrix # - units-test runs-on: [self-hosted2] container: python:3.10-slim-buster @@ -123,7 +144,7 @@ jobs: # python: [3.11] # test_name: [user_info] test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} - example_name: ${{ fromJson(needs.integration-prepare-env.outputs.matrix) }} + example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 From deaf63f66136d04c15741417e45339c1f673d16a Mon Sep 17 00:00:00 2001 From: Ana Zobec Date: Tue, 7 Mar 2023 10:31:10 +0100 Subject: [PATCH 3/6] Fix some of the examples. --- examples/time_server.yml | 14 +++++++++++--- examples/time_server_info.yml | 16 +++++++++++----- examples/time_zone.yml | 14 +++++++++++--- examples/time_zone_info.yml | 16 +++++++++++----- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/examples/time_server.yml b/examples/time_server.yml index b1ddfee34..880a69dc1 100644 --- a/examples/time_server.yml +++ b/examples/time_server.yml @@ -1,4 +1,12 @@ --- -- name: Modify current NTP Time Server entries (in HyperCore API settings) - scale_computing.hypercore.time_server: - source: pool.ntp.org # must be set if not already present in existing entries +- name: Example time_server module + hosts: localhost + connection: local + gather_facts: false + vars: + source: pool.ntp.org + + tasks: + - name: Modify current NTP Time Server entries (in HyperCore API settings) + scale_computing.hypercore.time_server: + source: "{{ source }}" # must be set if not already present in existing entries diff --git a/examples/time_server_info.yml b/examples/time_server_info.yml index d058ed375..e3849020a 100644 --- a/examples/time_server_info.yml +++ b/examples/time_server_info.yml @@ -1,6 +1,12 @@ --- -- name: List current Time Server entries - scale_computing.hypercore.time_server_info: - register: time_server_info -- ansible.builtin.debug: - msg: "{{ time_server_info }}" +- name: Example time_server_info module + hosts: localhost + connection: local + gather_facts: false + + tasks: + - name: List current Time Server entries + scale_computing.hypercore.time_server_info: + register: time_server_info + - ansible.builtin.debug: + msg: "{{ time_server_info }}" diff --git a/examples/time_zone.yml b/examples/time_zone.yml index 5caa51a09..7b8f83c26 100644 --- a/examples/time_zone.yml +++ b/examples/time_zone.yml @@ -1,4 +1,12 @@ --- -- name: Modify current Time Zone entries (in HyperCore API settings) - scale_computing.hypercore.time_zone: - zone: US/Eastern # must be set if not already present in existing entries +- name: Example time_zone module + hosts: localhost + connection: local + gather_facts: false + vars: + zone: US/Eastern + + tasks: + - name: Modify current Time Zone entries (in HyperCore API settings) + scale_computing.hypercore.time_zone: + zone: "{{ zone }}" # must be set if not already present in existing entries diff --git a/examples/time_zone_info.yml b/examples/time_zone_info.yml index 595466328..0dd971930 100644 --- a/examples/time_zone_info.yml +++ b/examples/time_zone_info.yml @@ -1,6 +1,12 @@ --- -- name: List current Time Zone entries -- scale_computing.hypercore.time_zone_info: - register: time_zone_info -- ansible.builtin.debug: - msg: "{{ time_zone_info }}" +- name: Example time_zone_info module + hosts: localhost + connection: local + gather_facts: false + + tasks: + - name: List current Time Zone entries + - scale_computing.hypercore.time_zone_info: + register: time_zone_info + - ansible.builtin.debug: + msg: "{{ time_zone_info }}" From 03717d473ace5ee848a8e34f984870b756bfa489 Mon Sep 17 00:00:00 2001 From: Ana Zobec Date: Tue, 7 Mar 2023 10:46:31 +0100 Subject: [PATCH 4/6] Update workflow according to requests. --- .github/workflows/integ-test.yml | 53 ++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index 1cc528ed4..cdf76f1a8 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -27,8 +27,6 @@ on: env: INTEG_TESTS_INCLUDE_SCHEDULE: "*" INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_" - EXAMPLES_INCLUDE: "*" - EXAMPLES_EXCLUDE: "^version_update_single_node$|^cluster_config$" WORKDIR: /work-dir/ansible_collections/scale_computing/hypercore # Run only one workflow for specific branch. concurrency: @@ -115,10 +113,6 @@ jobs: - run: apt install -y jq - run: mkdir -p $WORKDIR - run: cp -a ./ $WORKDIR - # We want to run all integ tests periodically - "integ_tests_include || '*'", the '*' is used. - # When running with workflow-dispatch, user is required to put some non-empty string into integ_tests_include. - - run: echo 'EXAMPLES_INCLUDE=${{ github.event.inputs.integ_tests_include || env.EXAMPLES_INCLUDE }}' >> $GITHUB_ENV - - run: echo 'EXAMPLES_EXCLUDE=${{ github.event.inputs.integ_tests_exclude || env.EXAMPLES_EXCLUDE }}' >> $GITHUB_ENV - id: set-matrix shell: bash @@ -126,12 +120,53 @@ jobs: echo "matrix=$( ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' )" >> $GITHUB_OUTPUT - if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}" + if: "${{ github.event.schedule }}" + + examples-run: + needs: + - examples-matrix + # - units-test + runs-on: [ self-hosted2 ] + container: python:3.10-slim-buster + env: + DEBIAN_FRONTEND: noninteractive + strategy: + fail-fast: false + matrix: + ansible: [ 2.13.0 ] + # python: [3.11] + # test_name: [user_info] + test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} + example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements + - run: apt update + - run: apt install -y git make + - run: apt install -y genisoimage qemu-utils + - run: pip install ansible-core~=${{ matrix.ansible }} + - run: mkdir -p $WORKDIR + - run: cp -a ./ $WORKDIR + # We have ansible.cfg "for testing" in git repo + # (it is excluded in galaxy.yml, so it is not part of collection artifact) + # But it does affect ansible-galaxy and ansible-test commands. + - run: cd $WORKDIR && ansible-galaxy collection install community.crypto + - run: cd $WORKDIR && ansible-galaxy collection list + # TODO - make integration_config.yml a reusable artifact/output of integration-prepare-env + - run: | + cd $WORKDIR + echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml + cat tests/integration/integration_config.yml + echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml + echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml + echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml + ls -al tests/integration/integration_config.yml + - run: cd $WORKDIR && ansible-playbook --check ${{ matrix.example_name }} integ: needs: - integ-matrix - - examples-matrix # - units-test runs-on: [self-hosted2] container: python:3.10-slim-buster @@ -144,7 +179,6 @@ jobs: # python: [3.11] # test_name: [user_info] test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} - example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 @@ -170,7 +204,6 @@ jobs: echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml ls -al tests/integration/integration_config.yml - run: cd $WORKDIR && ansible-test integration --local ${{ matrix.test_name }} - - run: cd $WORKDIR && ansible-playbook --check ${{ matrix.example_name }} replica_cleanup: From a32b0c74fb969592a5a22b3ecdf3d0cee1dddc6c Mon Sep 17 00:00:00 2001 From: Ana Zobec Date: Wed, 8 Mar 2023 14:14:48 +0100 Subject: [PATCH 5/6] Remove test_name from examples-run job, update job conditional. --- .github/workflows/integ-test.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index cdf76f1a8..236f0a5c1 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -120,12 +120,11 @@ jobs: echo "matrix=$( ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' )" >> $GITHUB_OUTPUT - if: "${{ github.event.schedule }}" + if: "${{ github.event.inputs || github.event.schedule }}" examples-run: needs: - examples-matrix - # - units-test runs-on: [ self-hosted2 ] container: python:3.10-slim-buster env: @@ -134,9 +133,6 @@ jobs: fail-fast: false matrix: ansible: [ 2.13.0 ] - # python: [3.11] - # test_name: [user_info] - test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }} steps: - name: Checkout @@ -148,12 +144,8 @@ jobs: - run: pip install ansible-core~=${{ matrix.ansible }} - run: mkdir -p $WORKDIR - run: cp -a ./ $WORKDIR - # We have ansible.cfg "for testing" in git repo - # (it is excluded in galaxy.yml, so it is not part of collection artifact) - # But it does affect ansible-galaxy and ansible-test commands. - run: cd $WORKDIR && ansible-galaxy collection install community.crypto - run: cd $WORKDIR && ansible-galaxy collection list - # TODO - make integration_config.yml a reusable artifact/output of integration-prepare-env - run: | cd $WORKDIR echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml From c87821a54616263ec0cdc114c4fab030652ed69c Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Wed, 8 Mar 2023 16:36:07 +0100 Subject: [PATCH 6/6] Trivial fix Signed-off-by: Justin Cinkelj --- .github/workflows/integ-test.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index 236f0a5c1..3c209ac07 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -113,12 +113,16 @@ jobs: - run: apt install -y jq - run: mkdir -p $WORKDIR - run: cp -a ./ $WORKDIR - + # A few files are not an example playbook: + # hypercore_inventory.yml - inventory example + # cloud-init-user-data-example.yml - cloud-init user-data example - id: set-matrix shell: bash run: |- echo "matrix=$( - ls -r $WORKDIR/examples | jq -R -s -c 'split("\n")[:-1]' + ls -r $WORKDIR/examples | + grep -v -E "^README.md$|^hypercore_inventory.yml$|^cloud-init-user-data-example.yml$" | + jq -R -s -c 'split("\n")[:-1]' )" >> $GITHUB_OUTPUT if: "${{ github.event.inputs || github.event.schedule }}" @@ -140,11 +144,12 @@ jobs: - run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements - run: apt update - run: apt install -y git make - - run: apt install -y genisoimage qemu-utils + - run: apt install -y genisoimage qemu-utils jq + - run: pip install yq - run: pip install ansible-core~=${{ matrix.ansible }} - run: mkdir -p $WORKDIR - run: cp -a ./ $WORKDIR - - run: cd $WORKDIR && ansible-galaxy collection install community.crypto + - run: cd $WORKDIR && ansible-galaxy collection install community.crypto community.general - run: cd $WORKDIR && ansible-galaxy collection list - run: | cd $WORKDIR @@ -154,7 +159,13 @@ jobs: echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml ls -al tests/integration/integration_config.yml - - run: cd $WORKDIR && ansible-playbook --check ${{ matrix.example_name }} + - run: | + cd $WORKDIR + eval export SC_HOST=$(cat tests/integration/integration_config.yml | yq '.sc_host') + eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_username') + eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_password') + eval export SC_TIMEOUT=$(cat tests/integration/integration_config.yml | yq '.sc_timeout') + ansible-playbook --check examples/${{ matrix.example_name }} integ: needs: