diff --git a/.github/actions/build-collection/action.yaml b/.github/actions/build-collection/action.yaml new file mode 100644 index 0000000..71ad46f --- /dev/null +++ b/.github/actions/build-collection/action.yaml @@ -0,0 +1,26 @@ +# 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: build-collection +description: Builds the collection + +runs: + using: composite + steps: + - name: Download certificate + shell: bash + run: mkdir -p $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR + - name: Build the collection + shell: bash + run: ansible-galaxy collection build . -vvv diff --git a/.github/actions/run-tests/action.yaml b/.github/actions/run-tests/action.yaml new file mode 100644 index 0000000..bf93c74 --- /dev/null +++ b/.github/actions/run-tests/action.yaml @@ -0,0 +1,26 @@ +# 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-tests +description: Runs the tests + +runs: + using: composite + steps: + - name: Install the collection + shell: bash + run: ansible-galaxy collection install dynatrace-oneagent* + - name: Run sanity test + shell: bash + run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd diff --git a/.github/actions/setup-build-environment/action.yaml b/.github/actions/setup-build-environment/action.yaml new file mode 100644 index 0000000..4d8f834 --- /dev/null +++ b/.github/actions/setup-build-environment/action.yaml @@ -0,0 +1,26 @@ +# 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: setup-build-environment +description: Prepares build environment + +runs: + using: composite + steps: + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + shell: bash + run: pip install ansible diff --git a/.github/actions/upload-collection/action.yaml b/.github/actions/upload-collection/action.yaml new file mode 100644 index 0000000..8676796 --- /dev/null +++ b/.github/actions/upload-collection/action.yaml @@ -0,0 +1,26 @@ +# 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: upload-collection +description: Uploads the collection locally + +runs: + using: composite + steps: + - name: Publish artifact + uses: actions/upload-artifact@v4 + with: + name: dynatrace-oneagent-${{ github.sha }} + retention-days: 7 + path: dynatrace-oneagent* \ No newline at end of file diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..efec9fe --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,37 @@ +# 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: Build and test +on: + pull_request: + branches: [ "*" ] + push: + branches: [ "*" ] + workflow_dispatch: + workflow_call: + +env: + FILES_DIR: roles/oneagent/files + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up environment + uses: ./.github/actions/setup-build-environment + - name: Build the collection + uses: ./.github/actions/build-collection + - name: Run tests + uses: ./.github/actions/run-tests diff --git a/.github/workflows/build-test-upload.yaml b/.github/workflows/build-test-upload.yaml new file mode 100644 index 0000000..a80f830 --- /dev/null +++ b/.github/workflows/build-test-upload.yaml @@ -0,0 +1,28 @@ +# 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: Build, test and upload +on: + push: + branches: [ 'main' ] + workflow_dispatch: + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Build and test + uses: ./.github/workflows/build-and-test.yaml + - name: Upload the collection + uses: ./.github/actions/upload-collection