Skip to content

Commit

Permalink
Move workflow logic to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
WStechura committed Jun 6, 2024
1 parent d119f71 commit d65fda3
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 51 deletions.
26 changes: 26 additions & 0 deletions .github/actions/build-collection/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 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 $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR
- name: Building the collection
shell: bask
run: ansible-galaxy collection build .
26 changes: 26 additions & 0 deletions .github/actions/publish-collection/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 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: Publish artifact
uses: actions/upload-artifact@v4
with:
name: dynatrace-oneagent-${{ github.sha }}
retention-days: 7
path: dynatrace-oneagent*
26 changes: 26 additions & 0 deletions .github/actions/run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 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: Installing the collection
shell: bash
run: ansible-galaxy collection install dynatrace-oneagent*
- name: Running sanity test
shell: bash
run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd
26 changes: 26 additions & 0 deletions .github/actions/setup-build-environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 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: prepare-build-environment
description: Prepares build environment

runs:
using: composite
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Installing dependencies
shell: bash
run: pip install ansible
34 changes: 34 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 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
- uses: ./.github/actions/setup-build-environment
- uses: ./.github/actions/build-collection
- uses: ./.github/actions/run-tests
51 changes: 0 additions & 51 deletions .github/workflows/build-and-test.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/build-test-upload-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 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:
types: [ 'closed' ]
workflow_dispatch:

env:
FILES_DIR: roles/oneagent/files

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: ./.github/workflows/build-and-test.yaml
- uses: ./.github/actions/publish-collection

0 comments on commit d65fda3

Please sign in to comment.