diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c316c36b40d..88b060b33c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: diff --git a/Makefile b/Makefile index a070adb3592..bfd7695fd04 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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) diff --git a/molecule/default/tasks/info.yml b/molecule/default/tasks/info.yml index ac27f06fd11..2c5d12e354a 100644 --- a/molecule/default/tasks/info.yml +++ b/molecule/default/tasks/info.yml @@ -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 @@ -11,7 +11,7 @@ apiVersion: v1 kind: Namespace metadata: - name: "{{ wait_namespace }}" + name: "{{ info_namespace }}" - name: Add a simple pod with initContainer k8s: @@ -20,7 +20,7 @@ kind: Pod metadata: name: "{{ k8s_pod_name }}" - namespace: "{{ wait_namespace }}" + namespace: "{{ info_namespace }}" spec: initContainers: - name: init-01 @@ -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 @@ -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 @@ -74,7 +74,7 @@ labels: run: multi-box name: "{{ multi_pod_one }}" - namespace: "{{ wait_namespace }}" + namespace: "{{ info_namespace }}" spec: initContainers: - name: init-01 @@ -94,7 +94,7 @@ labels: run: multi-box name: "{{ multi_pod_two }}" - namespace: "{{ wait_namespace }}" + namespace: "{{ info_namespace }}" spec: initContainers: - name: init-02 @@ -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 @@ -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 @@ -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 @@ -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 @@ -206,5 +206,5 @@ - name: Remove namespace k8s: kind: Namespace - name: "{{ wait_namespace }}" + name: "{{ info_namespace }}" state: absent