From 4a88095c4698eb1d0bbc93dee003a4a709c90df2 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Tue, 2 Jun 2020 11:58:51 +0100 Subject: [PATCH] Switch CircleCI for GitHub Actions (#253) * Switch CircleCI for GitHub Actions * Build docker image and push to kind * Move k8s resources and add tests * Fix YAML * Add linting workflow and tidy tests * Reinstate interactive tty --- .circleci/config.yml | 33 ------------ .github/workflows/ci.yaml | 62 +++++++++++++++++++++++ ci/Dockerfile | 9 +--- {kubernetes => ci}/test-runner-setup.yaml | 0 4 files changed, 64 insertions(+), 40 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yaml rename {kubernetes => ci}/test-runner-setup.yaml (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 98766d1ab..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 2 - -jobs: - build: - machine: - image: ubuntu-1604:201903-01 - - steps: - - checkout - - run: - name: Install kubectl - command: sudo make kubectl-bootstrap BIN_PATH=/usr/local/bin - - run: - name: Install kind - command: sudo make kind-bootstrap BIN_PATH=/usr/local/bin - - run: - name: Start local Kubernetes Cluster and create context in ~/.kube/config - command: make kind-start - - run: - name: Build docker image for testing - command: make build - - run: - name: Lint containerized code - command: make docker-make COMMAND=lint - - run: - name: Make docker image available in-cluster - command: make push-kind - - run: - name: Create K8S resources needed for testing in-cluster - command: make k8s-deploy - - run: - name: Test containerized code in-cluster - command: make k8s-make COMMAND=test diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..6baa0a18b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,62 @@ +name: "CI" +on: [pull_request, push] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + pip install -r requirements-dev.txt + + - name: Lint + run: | + flake8 dask_kubernetes + black --check dask_kubernetes setup.py + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - name: Install and start kind (Kubernetes in Docker) + uses: engineerd/setup-kind@v0.4.0 + + - name: Get kind info + run: | + kubectl cluster-info + kubectl get pods -n kube-system + echo "current-context:" $(kubectl config current-context) + echo "environment-kubeconfig:" ${KUBECONFIG} + + - name: Build testing Docker image + run: | + docker build -t dask-kubernetes:test -f ci/Dockerfile . + kind load docker-image dask-kubernetes:test + + - name: Create test runner k8s resources + run: | + kubectl apply -f ci/test-runner-setup.yaml + + - name: Run tests inside container + run: | + kubectl -n dask-kubernetes-test \ + run -i --tty --restart=Never \ + dask-kubernetes-test \ + --serviceaccount=test-runner \ + --image=dask-kubernetes:test \ + --image-pull-policy=Never \ + --env="USER=tester" \ + --env="K8S_TEST_NAMESPACE=dask-kubernetes-test" \ + --env="EXTRA_TEST_ARGS=--in-cluster" \ + --rm=true \ + --command -- py.test dask_kubernetes -vvv --namespace=dask-kubernetes-test --worker-image=dask-kubernetes:test diff --git a/ci/Dockerfile b/ci/Dockerfile index a6eadd090..cf67e4f2b 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,11 +1,6 @@ FROM daskdev/dask:latest -RUN apt-get update && apt-get install -y --no-install-recommends \ - make \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /usr/local/src/dask_kubernetes +WORKDIR /usr/local/src COPY . . -RUN make install +RUN pip install -e . && pip install -r requirements-dev.txt diff --git a/kubernetes/test-runner-setup.yaml b/ci/test-runner-setup.yaml similarity index 100% rename from kubernetes/test-runner-setup.yaml rename to ci/test-runner-setup.yaml