mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-08 05:52:37 +00:00
test molecule zuul job (#180)
This commit is contained in:
144
.github/workflows/ci.yml
vendored
144
.github/workflows/ci.yml
vendored
@@ -1,144 +0,0 @@
|
|||||||
---
|
|
||||||
name: CI
|
|
||||||
'on':
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
sanity:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
ansible_version: ['stable-2.11', 'stable-2.10', 'stable-2.9', 'devel']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Check ansible version
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: ansible/ansible
|
|
||||||
ref: ${{ matrix.ansible_version }}
|
|
||||||
path: ansible_collections/kubernetes/core/ansible
|
|
||||||
|
|
||||||
- name: Run sanity tests on Python ${{ matrix.python_version }}
|
|
||||||
run: source ./ansible/hacking/env-setup && make test-sanity PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
integration:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
# Our old integration tests fail under newer Python versions.
|
|
||||||
python_version: ['3.6']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Install ansible base (devel branch)
|
|
||||||
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
|
|
||||||
- name: Run integration tests on Python ${{ matrix.python_version }}
|
|
||||||
run: make test-integration PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Generate coverage report.
|
|
||||||
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
fail_ci_if_error: false
|
|
||||||
|
|
||||||
molecule:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
ansible_version: ['==2.9.*', '==2.10.*', '']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
# We are facing some issue with the github action used to spawn k8s cluster
|
|
||||||
# This will be done into a dedicated prepare step for molecule, with the added benefit that
|
|
||||||
# it is no more github dependant
|
|
||||||
# - name: Set up KinD cluster
|
|
||||||
# uses: engineerd/setup-kind@v0.5.0
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
# The 3.3.0 release of molecule introduced a breaking change. See
|
|
||||||
# https://github.com/ansible-community/molecule/issues/3083
|
|
||||||
- name: Install molecule and kubernetes dependencies
|
|
||||||
run: pip install ansible${{ matrix.ansible_version }} "molecule<3.3.0" yamllint kubernetes flake8 jsonpatch
|
|
||||||
|
|
||||||
# The latest release doesn't work with Molecule currently.
|
|
||||||
# See: https://github.com/ansible-community/molecule/issues/2757
|
|
||||||
# - name: Install ansible base, latest release.
|
|
||||||
# run: |
|
|
||||||
# pip uninstall -y ansible
|
|
||||||
# pip install --pre ansible-base
|
|
||||||
|
|
||||||
# The devel branch doesn't work with Molecule currently.
|
|
||||||
# See: https://github.com/ansible-community/molecule/issues/2757
|
|
||||||
# - name: Install ansible base (devel branch)
|
|
||||||
# run: |
|
|
||||||
# pip uninstall -y ansible
|
|
||||||
# pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
- name: Create default collection path symlink
|
|
||||||
run: |
|
|
||||||
mkdir -p /home/runner/.ansible
|
|
||||||
ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections
|
|
||||||
|
|
||||||
- name: Run molecule default test scenario
|
|
||||||
run: make test-molecule
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
unit:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python_version: ['3.7']
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: ansible_collections/kubernetes/core
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python_version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
- name: Install ansible base (devel branch)
|
|
||||||
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
|
|
||||||
|
|
||||||
- name: Run unit tests on Python ${{ matrix.python_version }}
|
|
||||||
run: make test-unit PYTHON_VERSION=${{ matrix.python_version }}
|
|
||||||
working-directory: ./ansible_collections/kubernetes/core
|
|
||||||
@@ -6,10 +6,6 @@ driver:
|
|||||||
login_cmd_template: 'docker exec -ti {instance} bash'
|
login_cmd_template: 'docker exec -ti {instance} bash'
|
||||||
ansible_connection_options:
|
ansible_connection_options:
|
||||||
ansible_connection: docker
|
ansible_connection: docker
|
||||||
lint: |
|
|
||||||
set -e
|
|
||||||
yamllint .
|
|
||||||
flake8
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: instance-kind
|
- name: instance-kind
|
||||||
provisioner:
|
provisioner:
|
||||||
@@ -33,7 +29,6 @@ scenario:
|
|||||||
name: default
|
name: default
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- lint
|
|
||||||
- syntax
|
- syntax
|
||||||
- prepare
|
- prepare
|
||||||
- converge
|
- converge
|
||||||
|
|||||||
@@ -11,22 +11,35 @@
|
|||||||
- "node.kubernetes.io/not-ready"
|
- "node.kubernetes.io/not-ready"
|
||||||
- "node.kubernetes.io/unreachable"
|
- "node.kubernetes.io/unreachable"
|
||||||
- "node.kubernetes.io/unschedulable"
|
- "node.kubernetes.io/unschedulable"
|
||||||
|
kind_bin_path: "/usr/local/bin/kind"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
# We are spawning k8s cluster using kind executable and we ensure that the cluster is up
|
# We are spawning k8s cluster using kind executable and we ensure that the cluster is up
|
||||||
# and node is ready, if this is not validated we may face issue later on when running tests
|
# and node is ready, if this is not validated we may face issue later on when running tests
|
||||||
- name: Download kind
|
- name: Check if kind binary is available or not
|
||||||
|
stat:
|
||||||
|
path: "{{ kind_bin_path }}"
|
||||||
|
register: r
|
||||||
|
|
||||||
|
- name: Download kind if not available
|
||||||
get_url:
|
get_url:
|
||||||
url: https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
|
url: https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
|
||||||
dest: /tmp/kind
|
dest: "{{ kind_bin_path }}"
|
||||||
|
when: not r.stat.exists
|
||||||
|
|
||||||
- name: make kind executable
|
- name: Make kind executable
|
||||||
file:
|
file:
|
||||||
path: /tmp/kind
|
path: "{{ kind_bin_path }}"
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Check if Kind cluster exists
|
||||||
|
command: "{{ kind_bin_path }} get clusters"
|
||||||
|
register: r
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Create cluster
|
- name: Create cluster
|
||||||
command: "kind create cluster"
|
command: "{{ kind_bin_path }} create cluster"
|
||||||
|
when: r.stdout == ''
|
||||||
|
|
||||||
- name: Assert that nodes are ready
|
- name: Assert that nodes are ready
|
||||||
k8s_info:
|
k8s_info:
|
||||||
|
|||||||
Reference in New Issue
Block a user