-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
165 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Cluster Integration Tests - private cluster | ||
on: | ||
pull_request: | ||
branches: | ||
- 'releases/*' | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run-integration-test: | ||
name: Run Minikube Integration Tests | ||
runs-on: ubuntu-latest | ||
env: | ||
KUBECONFIG: /home/runner/.kube/config | ||
NAMESPACE: test-${{ github.run_id }} | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: | | ||
rm -rf node_modules/ | ||
npm install | ||
- name: Install ncc | ||
run: npm i -g @vercel/ncc | ||
- name: Build | ||
run: ncc build src/run.ts -o lib | ||
- name: Azure login | ||
uses: azure/login@v1.4.3 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- uses: Azure/setup-kubectl@v3 | ||
name: Install Kubectl | ||
|
||
- name: Create private AKS cluster and set context | ||
run: | | ||
set +x | ||
# create cluster | ||
az group create --location eastus --name ${{ env.NAMESPACE }} | ||
az aks create --name ${{ env.NAMESPACE }} --resource-group ${{ env.NAMESPACE }} --enable-private-cluster --generate-ssh-keys | ||
az aks get-credentials --resource-group ${{ env.NAMESPACE }} --name ${{ env.NAMESPACE }} | ||
- name: Create namespace to run tests | ||
run: | | ||
az aks command invoke --resource-group ${{ env.NAMESPACE }} --name ${{ env.NAMESPACE }} --command "kubectl create ns ${{ env.NAMESPACE }}" | ||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Executing deploy action for pod | ||
uses: ./ | ||
with: | ||
namespace: ${{ env.NAMESPACE }} | ||
images: nginx:1.14.2 | ||
manifests: | | ||
test/integration/manifests/test.yml | ||
action: deploy | ||
private-cluster: true | ||
resource-group: ${{ env.NAMESPACE }} | ||
name: ${{ env.NAMESPACE }} | ||
|
||
- name: Checking if deployments and services were created | ||
run: | | ||
python test/integration/k8s-deploy-test.py private=${{ env.NAMESPACE }} namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Cluster_Integration_Tests_-_private_cluster selectorLabels=app:nginx | ||
python test/integration/k8s-deploy-test.py private=${{ env.NAMESPACE }} namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Cluster_Integration_Tests_-_private_cluster selectorLabels=app:nginx | ||
- name: Clean up AKS cluster | ||
if: ${{ always() }} | ||
run: | | ||
echo "deleting AKS cluster and resource group" | ||
az aks delete --yes --resource-group ${{ env.NAMESPACE }} --name ${{ env.NAMESPACE }} | ||
az group delete --resource-group ${{ env.NAMESPACE }} --yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {PrivateKubectl} from './privatekubectl' | ||
|
||
describe('Private kubectl', () => { | ||
const testString = `kubectl annotate -f test.yml,test2.yml,test3.yml -f test4.yml --filename test5.yml actions.github.com/k8s-deploy={"run":"3498366832","repository":"jaiveerk/k8s-deploy","workflow":"Minikube Integration Tests - private cluster","workflowFileName":"run-integration-tests-private.yml","jobName":"run-integration-test","createdBy":"jaiveerk","runUri":"https://github.com/jaiveerk/k8s-deploy/actions/runs/3498366832","commit":"c63b323186ea1320a31290de6dcc094c06385e75","lastSuccessRunCommit":"NA","branch":"refs/heads/main","deployTimestamp":1668787848577,"dockerfilePaths":{"nginx:1.14.2":""},"manifestsPaths":["https://github.com/jaiveerk/k8s-deploy/blob/c63b323186ea1320a31290de6dcc094c06385e75/test/integration/manifests/test.yml"],"helmChartPaths":[],"provider":"GitHub"} --overwrite --namespace test-3498366832` | ||
const mockKube = new PrivateKubectl('') | ||
|
||
it('should extract filenames correctly', () => { | ||
expect(mockKube.extractFilesnames(testString)).toEqual( | ||
'test.yml test2.yml test3.yml test4.yml test5.yml' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters