From 2998db08bf6ce5917e320c627eb65875ea6f5d30 Mon Sep 17 00:00:00 2001 From: Jakub Rak Date: Tue, 15 Oct 2024 11:03:16 +0200 Subject: [PATCH] Install collection for component tests with sudo --- .../action.yaml | 22 +++++++-------- .github/actions/run-sanity-tests/action.yaml | 27 +++++++++++++++++++ .github/workflows/build-and-test.yaml | 6 +++-- .github/workflows/build-test-and-publish.yaml | 6 +++-- .github/workflows/build-test-and-upload.yaml | 6 +++-- 5 files changed, 49 insertions(+), 18 deletions(-) rename .github/actions/{run-tests => run-component-tests}/action.yaml (73%) create mode 100644 .github/actions/run-sanity-tests/action.yaml diff --git a/.github/actions/run-tests/action.yaml b/.github/actions/run-component-tests/action.yaml similarity index 73% rename from .github/actions/run-tests/action.yaml rename to .github/actions/run-component-tests/action.yaml index ab0f7be..3cdde5c 100644 --- a/.github/actions/run-tests/action.yaml +++ b/.github/actions/run-component-tests/action.yaml @@ -12,29 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: run-tests -description: Runs the tests +name: run-component-tests +description: Runs component tests runs: using: composite steps: - - name: Install the collection - shell: bash - run: ansible-galaxy collection install -vvv dynatrace-oneagent* - - name: Run sanity test - shell: bash - run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd - - name: Prepare component tests - id: prepare-component-tests + - name: Prepare Python environment shell: bash run: python -m virtualenv roles/oneagent/tests/component/venv && source roles/oneagent/tests/component/venv/bin/activate && pip install -r roles/oneagent/tests/component/resources/requirements.txt + + - name: Install the collection + shell: bash + run: sudo bash -c "source venv/bin/activate && ansible-galaxy collection install -vvv dynatrace-oneagent*" + - name: Run component tests - id: component-tests shell: bash run: cd roles/oneagent/tests/component && - sudo bash -c "source venv/bin/activate; python run.py --linux_x86=localhost" + sudo bash -c "source venv/bin/activate && python run.py --linux_x86=localhost" + - name: Upload logs uses: actions/upload-artifact@v4 if: ${{ always() }} diff --git a/.github/actions/run-sanity-tests/action.yaml b/.github/actions/run-sanity-tests/action.yaml new file mode 100644 index 0000000..fa746ad --- /dev/null +++ b/.github/actions/run-sanity-tests/action.yaml @@ -0,0 +1,27 @@ +# Copyright 2024 Dynatrace LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: run-sanity-tests +description: Runs sanity tests + +runs: + using: composite + steps: + - name: Install the collection + shell: bash + run: ansible-galaxy collection install -vvv dynatrace-oneagent* + + - name: Run sanity test + shell: bash + run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 2d096d5..c2058d4 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -35,5 +35,7 @@ jobs: uses: ./.github/actions/setup-build-environment - name: Build the collection uses: ./.github/actions/build-collection - - name: Run tests - uses: ./.github/actions/run-tests + - name: Run sanity tests + uses: ./.github/actions/run-sanity-tests + - name: Run component tests + uses: ./.github/actions/run-component-tests diff --git a/.github/workflows/build-test-and-publish.yaml b/.github/workflows/build-test-and-publish.yaml index 6edf19a..0167230 100644 --- a/.github/workflows/build-test-and-publish.yaml +++ b/.github/workflows/build-test-and-publish.yaml @@ -33,8 +33,10 @@ jobs: uses: ./.github/actions/setup-build-environment - name: Build the collection uses: ./.github/actions/build-collection - - name: Run tests - uses: ./.github/actions/run-tests + - name: Run sanity tests + uses: ./.github/actions/run-sanity-tests + - name: Run component tests + uses: ./.github/actions/run-component-tests - name: Publish to Ansible Galaxy uses: ./.github/actions/publish-to-ansible-galaxy with: diff --git a/.github/workflows/build-test-and-upload.yaml b/.github/workflows/build-test-and-upload.yaml index 9e8c36c..2e7da53 100644 --- a/.github/workflows/build-test-and-upload.yaml +++ b/.github/workflows/build-test-and-upload.yaml @@ -28,7 +28,9 @@ jobs: uses: ./.github/actions/setup-build-environment - name: Build the collection uses: ./.github/actions/build-collection - - name: Run tests - uses: ./.github/actions/run-tests + - name: Run sanity tests + uses: ./.github/actions/run-sanity-tests + - name: Run component tests + uses: ./.github/actions/run-component-tests - name: Upload the collection uses: ./.github/actions/upload-collection