mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 13:02:37 +00:00
Issue #10: Attempt setting up a KinD cluster in CI workflow.g
This commit is contained in:
40
.github/workflows/ansible-test.yml
vendored
40
.github/workflows/ansible-test.yml
vendored
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
'on':
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 6 * * *'
|
||||
@@ -53,3 +53,39 @@ jobs:
|
||||
|
||||
- name: Upload coverage data
|
||||
run: tests/coverage.sh
|
||||
|
||||
molecule:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python_version: ['3.7']
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
path: ansible_collections/community/kubernetes
|
||||
|
||||
- name: Set up KinD cluster
|
||||
uses: engineerd/setup-kind@v0.3.0
|
||||
|
||||
- name: Set up Python ${{ matrix.python_version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
|
||||
- name: Install molecule and openshift dependencies
|
||||
run: pip install molecule openshift
|
||||
|
||||
- name: Install ansible-base
|
||||
run: pip install git+https://github.com/ansible-collection-migration/ansible-base.git --disable-pip-version-check
|
||||
|
||||
- name: Create default collection path symlink
|
||||
run: |
|
||||
mkdir -p /home/runner/.ansible
|
||||
ln -s /home/runner/work/kubernetes /home/runner/.ansible/collections
|
||||
|
||||
- name: Copy kubernetes integration test role into roles directory.
|
||||
run: cp -R tests/integration/targets/kubernetes roles/
|
||||
|
||||
- name: Run molecule default test scenario
|
||||
run: molecule --debug test
|
||||
|
||||
@@ -105,6 +105,8 @@ For documentation on how to use individual modules and other content included in
|
||||
|
||||
If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it into one of the configured [`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths), and work on it there.
|
||||
|
||||
### Testing with `ansible-test`
|
||||
|
||||
The `tests` directory contains configuration for running sanity and integration tests using [`ansible-test`](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html).
|
||||
|
||||
You can run the collection's test suites with the commands:
|
||||
@@ -112,6 +114,13 @@ You can run the collection's test suites with the commands:
|
||||
ansible-test sanity --docker -v --color
|
||||
ansible-test integration --docker -v --color
|
||||
|
||||
### Testing with `molecule`
|
||||
|
||||
There are also integration tests in the `molecule` directory which are meant to be run against a local Kubernetes cluster, e.g. using [KinD](https://kind.sigs.k8s.io) or [Minikube](https://minikube.sigs.k8s.io). To run the tests, set up a local cluster, then run Molecule:
|
||||
|
||||
kind create cluster
|
||||
molecule test
|
||||
|
||||
## Publishing New Versions
|
||||
|
||||
The current process for publishing new versions of the Kubernetes Collection is manual, and requires a user who has access to the `community.kubernetes` namespace on Ansible Galaxy to publish the build artifact.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
coverage:
|
||||
precision: 2
|
||||
round: down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
authors:
|
||||
- chouseknecht (https://github.com/chouseknecht)
|
||||
- geerlingguy (https://www.jeffgeerling.com/)
|
||||
|
||||
34
molecule/default/molecule.yml
Normal file
34
molecule/default/molecule.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
driver:
|
||||
name: delegated
|
||||
options:
|
||||
managed: false
|
||||
login_cmd_template: 'docker exec -ti {instance} bash'
|
||||
ansible_connection_options:
|
||||
ansible_connection: docker
|
||||
lint:
|
||||
name: yamllint
|
||||
options:
|
||||
config-data:
|
||||
line-length:
|
||||
max: 160
|
||||
platforms:
|
||||
- name: instance-kind
|
||||
provisioner:
|
||||
name: ansible
|
||||
log: true
|
||||
lint: {}
|
||||
inventory:
|
||||
host_vars:
|
||||
localhost:
|
||||
ansible_python_interpreter: '{{ ansible_playbook_python }}'
|
||||
env:
|
||||
ANSIBLE_ROLES_PATH: ${ANSIBLE_ROLES_PATH}:../../tests/integration/targets
|
||||
scenario:
|
||||
name: default
|
||||
test_sequence:
|
||||
# - lint
|
||||
- syntax
|
||||
- converge
|
||||
- idempotence
|
||||
- verify
|
||||
23
molecule/default/playbook.yml
Normal file
23
molecule/default/playbook.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
|
||||
collections:
|
||||
- community.kubernetes
|
||||
|
||||
tasks:
|
||||
- name: Testing.
|
||||
k8s_info:
|
||||
namespace: kube-system
|
||||
kind: Pod
|
||||
register: pod_list
|
||||
|
||||
- name: Testing listing.
|
||||
debug:
|
||||
msg: "{{ pod_list.resources | count }}"
|
||||
|
||||
- name: Include Kubernetes integration testing role.
|
||||
include_role:
|
||||
name: kubernetes
|
||||
Reference in New Issue
Block a user