Skip to content

Commit

Permalink
ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Jun 25, 2021
1 parent abcc3e8 commit 53bf539
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 16 deletions.
51 changes: 49 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,59 @@ jobs:
with:
fail_ci_if_error: false

molecule:
molecule-lint:
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 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 lint-molecule
working-directory: ./ansible_collections/kubernetes/core

molecule-converge:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ['3.7']
ansible_version: ['==2.9.*', '==2.10.*', '']
ansible_tags: ['access_review', 'append_hash', 'apply', 'cluster_info', 'crd', 'delete', 'exec', 'full', 'gc', 'info', 'json_patch', 'lists', 'log', 'rollback', 'scale', 'template', 'waiter', 'merge_type', 'patched', 'lookup', 'helm']
steps:
- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -114,7 +161,7 @@ jobs:
ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections
- name: Run molecule default test scenario
run: make test-molecule
run: make converge-molecule ANSIBLE_TAGS=${{ matrix.ansible_tags }}
working-directory: ./ansible_collections/kubernetes/core

unit:
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
VERSION = 2.1.1

TEST_ARGS ?= ""
ANSIBLE_TAGS ?= ""
PYTHON_VERSION ?= `python -c 'import platform; print("{0}.{1}".format(platform.python_version_tuple()[0], platform.python_version_tuple()[1]))'`

clean:
Expand All @@ -24,8 +25,11 @@ test-sanity:
test-integration:
ansible-test integration --docker -v --color --retry-on-error --python $(PYTHON_VERSION) --continue-on-error --diff --coverage $(?TEST_ARGS)

test-molecule:
molecule test
converge-molecule:
molecule converge -- -v --tags $(ANSIBLE_TAGS)

lint-molecule:
molecule lint

test-unit:
ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS)
24 changes: 12 additions & 12 deletions molecule/default/tasks/info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- block:
- set_fact:
wait_namespace: wait
info_namespace: info
multi_pod_one: multi-pod-1
multi_pod_two: multi-pod-2

Expand All @@ -11,7 +11,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: "{{ wait_namespace }}"
name: "{{ info_namespace }}"

- name: Add a simple pod with initContainer
k8s:
Expand All @@ -20,7 +20,7 @@
kind: Pod
metadata:
name: "{{ k8s_pod_name }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
spec:
initContainers:
- name: init-01
Expand All @@ -35,7 +35,7 @@
k8s_info:
name: "{{ k8s_pod_name }}"
kind: Pod
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
wait: yes
wait_sleep: 5
wait_timeout: 400
Expand All @@ -53,7 +53,7 @@
api_version: v1
kind: Pod
name: "{{ k8s_pod_name }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
state: absent
wait: yes
ignore_errors: yes
Expand All @@ -74,7 +74,7 @@
labels:
run: multi-box
name: "{{ multi_pod_one }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
spec:
initContainers:
- name: init-01
Expand All @@ -94,7 +94,7 @@
labels:
run: multi-box
name: "{{ multi_pod_two }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
spec:
initContainers:
- name: init-02
Expand All @@ -108,7 +108,7 @@
- name: Wait and gather information about new pods
k8s_info:
kind: Pod
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
wait: yes
wait_sleep: 5
wait_timeout: 400
Expand All @@ -129,7 +129,7 @@
api_version: v1
kind: Pod
name: "{{ multi_pod_one }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
state: absent
wait: yes
ignore_errors: yes
Expand All @@ -146,7 +146,7 @@
api_version: v1
kind: Pod
name: "{{ multi_pod_two }}"
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
state: absent
wait: yes
ignore_errors: yes
Expand Down Expand Up @@ -189,7 +189,7 @@
k8s_info:
kind: Pod
name: does-not-exist
namespace: "{{ wait_namespace }}"
namespace: "{{ info_namespace }}"
wait: yes
wait_timeout: 45
register: result
Expand All @@ -206,5 +206,5 @@
- name: Remove namespace
k8s:
kind: Namespace
name: "{{ wait_namespace }}"
name: "{{ info_namespace }}"
state: absent

0 comments on commit 53bf539

Please sign in to comment.