k8s-deploy/.github/workflows/run-integration-tests-namespace-optional.yml
dependabot[bot] b35cf6be4f
Bump the actions group in /.github/workflows with 4 updates (#477)
Bumps the actions group in /.github/workflows with 4 updates: [actions/checkout](https://github.com/actions/checkout), [github/codeql-action](https://github.com/github/codeql-action), [actions/stale](https://github.com/actions/stale) and [actions/setup-python](https://github.com/actions/setup-python).


Updates `actions/checkout` from 6.0.0 to 6.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1af3b93b68...8e8c483db8)

Updates `github/codeql-action` from 4.31.5 to 4.31.7
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](fdbfb4d275...cf1bb45a27)

Updates `actions/stale` from 10.1.0 to 10.1.1
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](5f858e3efb...997185467f)

Updates `actions/setup-python` from 6.0.0 to 6.1.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](e797f83bcb...83679a892e)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: github/codeql-action
  dependency-version: 4.31.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/stale
  dependency-version: 10.1.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/setup-python
  dependency-version: 6.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-15 11:26:46 -05:00

138 lines
5.7 KiB
YAML

# This workflow is inspired by `run-integration-tests-bluegreen-ingress.yml` and introduces namespace-specific testing for manifests.
# It ensures deployments respect manifest-defined namespaces and tests deployments to multiple namespaces.
name: Minikube Integration Tests - Namespace Optional
on:
pull_request:
branches:
- main
- 'releases/*'
push:
branches:
- main
- 'releases/*'
workflow_dispatch:
jobs:
run-integration-test:
name: Run Namespace Optional Integration Tests
runs-on: ubuntu-22.04
env:
KUBECONFIG: /home/runner/.kube/config
NAMESPACE1: integration-test-namespace1-${{ github.run_id }}
NAMESPACE2: integration-test-namespace2-${{ github.run_id }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install dependencies
run: |
rm -rf node_modules/
npm install
- name: Install ncc
run: npm i -g @vercel/ncc
- name: Install conntrack
run: sudo apt-get install -y conntrack
- name: Build
run: ncc build src/run.ts -o lib
- uses: Azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1
name: Install Kubectl
- id: setup-minikube
name: Setup Minikube
uses: medyagh/setup-minikube@e3c7f79eb1e997eabccc536a6cf318a2b0fe19d9 # v0.0.20
with:
minikube-version: 1.34.0
kubernetes-version: 1.31.0
driver: 'none'
timeout-minutes: 3
- name: Create namespaces for tests
run: |
kubectl create ns ${{ env.NAMESPACE1 }}
kubectl create ns ${{ env.NAMESPACE2 }}
kubectl create ns test-namespace
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # 6.1.0
name: Install Python
with:
python-version: '3.x'
- name: Cleaning any previously created items
run: |
python test/integration/k8s-deploy-delete.py 'Deployment' 'all' ${{ env.NAMESPACE1 }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'all' ${{ env.NAMESPACE2 }}
# This tests whether the deployment respects the namespace defined in the manifest instead of defaulting to "default" when namespace is not provided.
- name: Test - Handles namespace correctly based on manifest
uses: ./
with:
images: nginx
manifests: |
test/integration/manifests/test_with_ns.yaml
test/integration/manifests/test_no_ns.yaml
action: deploy # Deploys manifests to specified namespaces or uses the namespace defined in the manifest
- name: Verify Deployment - test_with_ns.yaml (test-namespace)
run: |
python test/integration/k8s-deploy-test.py \
namespace=test-namespace \
kind=Deployment \
name=test-deployment \
containerName=nginx \
labels=app:test-app,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_Namespace_Optional \
selectorLabels=app:test-app
- name: Verify Deployment - test_no_ns.yaml (default namespace)
run: |
python test/integration/k8s-deploy-test.py \
namespace=default \
kind=Deployment \
name=test-deployment-no-ns \
containerName=nginx \
labels=app:test-app,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_Namespace_Optional \
selectorLabels=app:test-app
# This tests whether the deployment works when a file is deployed to two different provided namespaces.
- name: Test - Deploys the resource to namespace1
uses: ./
with:
namespace: ${{ env.NAMESPACE1 }}
images: nginx
manifests: |
test/integration/manifests/test_no_ns.yaml
action: deploy
- name: Test - Deploys the resource to namespace2
uses: ./
with:
namespace: ${{ env.NAMESPACE2 }}
images: nginx
manifests: |
test/integration/manifests/test_no_ns.yaml
action: deploy
- name: Verify Deployments in NAMESPACE1 & NAMESPACE2
run: |
for ns in ${{ env.NAMESPACE1 }} ${{ env.NAMESPACE2 }}; do
python test/integration/k8s-deploy-test.py \
namespace=$ns \
kind=Deployment \
name=test-deployment-no-ns \
containerName=nginx \
labels=app:test-app,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_Namespace_Optional \
selectorLabels=app:test-app
done
- name: Cleanup
run: |
echo "Cleaning up resources..."
python test/integration/k8s-deploy-delete.py 'Deployment' 'test-deployment' test-namespace
python test/integration/k8s-deploy-delete.py 'Deployment' 'test-deployment-no-ns' ${{ env.NAMESPACE1 }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'test-deployment-no-ns' ${{ env.NAMESPACE2 }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'test-deployment-no-ns' default
kubectl delete ns ${{ env.NAMESPACE1 }}
kubectl delete ns ${{ env.NAMESPACE2 }}
kubectl delete ns test-namespace
rm -rf test_with_ns.yaml test_no_ns.yaml