Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA as described in cloud-content-handbook #139

Merged
merged 6 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
profile: production

exclude_paths:
- tests/integration
- tests/sanity
- .github
- changelogs/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: CI

name: Changelog
concurrency:
group: changelog-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/galaxy-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: galaxy-import
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
galaxy_importer:
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
143 changes: 143 additions & 0 deletions .github/workflows/integration-tests-kubernetes-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
name: Integration tests
on:
pull_request:
branches:
- main
- stable-*

jobs:
splitter:
env:
source_dir: "./source"
runs-on: ubuntu-latest
outputs:
test_targets: ${{ steps.splitter.outputs.test_targets }}
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
steps:
- name: Checkout the collection repository
uses: actions/checkout@v3
with:
repository: ansible-collections/kubernetes.core
ref: main
path: ${{ env.source_dir }}
fetch-depth: "0"

- name: Split all Kubernetes targets into Job
id: splitter
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main
with:
collections_to_test: ${{ env.source_dir }}
total_jobs: 8
env:
ANSIBLE_TEST_ALL_THE_TARGETS: "true"
hakbailey marked this conversation as resolved.
Show resolved Hide resolved

- name: Display splitter output
run: |
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
shell: bash
integration:
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- splitter
if: ${{ needs.splitter.outputs.test_targets != '' }}
env:
ansible_version: "milestone"
python_version: "3.11"
abikouo marked this conversation as resolved.
Show resolved Hide resolved
source: "./cloud_common"
ansible_posix: "./ansible_posix"
kubernetes_core: "./kubernetes_core"
strategy:
fail-fast: false
matrix:
ansible-version:
- milestone
python-version:
- "3.12"
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
name: "integration-kubernetes-core-${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}"
steps:
- name: Read target
id: read-targets
run: |
import json, os
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
shell: python
env:
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
WORKFLOW_ID: ${{ matrix.workflow-id }}

- name: Display ansible test targets
run: |
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
shell: bash

- name: Checkout cloud.common repository
uses: actions/checkout@v3
with:
path: ${{ env.source }}
ref: ${{ github.event.pull_request.head.sha }}

- name: checkout ansible-collections/kubernetes.core
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
repository: ansible-collections/kubernetes.core
path: ${{ env.kubernetes_core }}
ref: main

- name: checkout ansible-collections/ansible.posix
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
repository: ansible-collections/ansible.posix
path: ${{ env.ansible_posix }}
ref: main

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# install ansible
- name: Install ansible-core (${{ matrix.ansible-version }})
run: >-
python3 -m pip install
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz
--disable-pip-version-check
shell: bash

- name: Build and install kuernetes.core collection
id: install-kubernetes-core
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.kubernetes_core }}

- name: install cloud.common collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.source }}

- name: install ansible.posix collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.ansible_posix }}

- name: Create kubernetes cluster
uses: helm/kind-action@v1.4.0

- name: Run integration tests
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
with:
collection_path: ${{ steps.install-kubernetes-core.outputs.collection_path }}
python_version: ${{ matrix.python-version }}
ansible_version: ${{ matrix.ansible-version }}
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }}
ansible_test_environment: |
ENABLE_TURBO_MODE=true
25 changes: 25 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Linters
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*
tags:
abikouo marked this conversation as resolved.
Show resolved Hide resolved
- '*'

jobs:
linters:
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main

ansible-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run ansible-lint
uses: ansible/ansible-lint@v6.21.0
16 changes: 0 additions & 16 deletions .github/workflows/linters.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/sanity-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Sanity tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
sanity:
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
Loading
Loading