From cbf0cbbb984885092fd24406f22134c7ddbc5a00 Mon Sep 17 00:00:00 2001 From: Matteo Silvestri Date: Wed, 27 Jul 2022 22:12:04 +0200 Subject: [PATCH] skip if not docker and bootstrap KinD in workflow action Signed-off-by: Matteo Silvestri --- .github/workflows/ci.yml | 6 ++++++ .../src/util/KubernetesContainerRunner.test.ts | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e732e49b43..5d886cddf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,6 +195,12 @@ jobs: - name: lint run: yarn backstage-cli repo lint --since origin/master + + - name: bootstrap kind + run: | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.14.0/kind-linux-amd64 + chmod +x ./kind + ./kind create cluster - name: test changed packages if: ${{ steps.yarn-lock.outcome == 'success' }} diff --git a/packages/backend-common/src/util/KubernetesContainerRunner.test.ts b/packages/backend-common/src/util/KubernetesContainerRunner.test.ts index b978855567..6b5b8df67e 100644 --- a/packages/backend-common/src/util/KubernetesContainerRunner.test.ts +++ b/packages/backend-common/src/util/KubernetesContainerRunner.test.ts @@ -25,10 +25,13 @@ import { } from './KubernetesContainerRunner'; import { RunContainerOptions } from './ContainerRunner'; import { PassThrough } from 'stream'; +import { isDockerDisabledForTests } from '@backstage/backend-test-utils'; + +const describeIfDocker = isDockerDisabledForTests() ? describe.skip : describe; jest.setTimeout(10 * 1000); -describe('KubernetesContainerRunner', () => { +describeIfDocker('KubernetesContainerRunner', () => { const kubeConfig = new KubeConfig(); kubeConfig.loadFromDefault(); const name = 'kube-runner'; @@ -183,10 +186,12 @@ describe('KubernetesContainerRunner', () => { }); describe('with namespace test', () => { - const api = kubeConfig.makeApiClient(CoreV1Api); - const authApi = kubeConfig.makeApiClient(RbacAuthorizationV1Api); + let api: CoreV1Api; + let authApi: RbacAuthorizationV1Api; beforeAll(async () => { + api = kubeConfig.makeApiClient(CoreV1Api); + authApi = kubeConfig.makeApiClient(RbacAuthorizationV1Api); await api.createNamespace({ metadata: { name: 'test',