diff --git a/.drone.yml b/.drone.yml index 70431301b..35b67e035 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,6 +2,18 @@ kind: pipeline name: default +services: + - name: docker + image: docker:dind + privileged: true + command: + - --dns=8.8.8.8 + volumes: + - name: dockersock + path: /var/run + - name: tmp + path: /tmp + steps: - name: fetch image: docker:git @@ -19,8 +31,8 @@ steps: commands: - make lint volumes: - - name: docker-socket - path: /var/run/docker.sock + - name: dockersock + path: /var/run depends_on: - fetch @@ -33,29 +45,27 @@ steps: commands: - make drone volumes: - - name: docker-socket - path: /var/run/docker.sock + - name: dockersock + path: /var/run depends_on: - - lint + - fetch - name: test - image: 'autonomy/test:${DRONE_COMMIT_SHA:0:7}' - privileged: true + image: autonomy/build-container:latest + pull: always + environment: + BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234 + BINDIR: /usr/local/bin commands: - - cd /src - - test.sh - - cp /src/coverage.txt /drone/src/coverage.txt + - make test volumes: - - name: docker-socket - path: /var/run/docker.sock - - name: containerd - path: /var/lib/containerd + - name: dockersock + path: /var/run depends_on: - build - name: coverage image: plugins/codecov - pull: always settings: token: from_secret: codecov_token @@ -72,9 +82,12 @@ steps: BINDIR: /usr/local/bin commands: - make basic-integration + - cp build/osctl-linux-amd64 /tmp/osctl + - cd /tmp + - ./osctl config generate cluster.local 1.2.3.4,2.3.4.5,3.4.5.6 volumes: - - name: docker-socket - path: /var/run/docker.sock + - name: dockersock + path: /var/run - name: tmp path: /tmp depends_on: @@ -83,6 +96,7 @@ steps: # - name: e2e-integration # image: autonomy/build-container:latest # pull: always + # ## Ignore errors for now, until we get the flakiness resolved in beta # err_ignore: true # environment: # BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234 @@ -96,8 +110,8 @@ steps: # commands: # - make e2e-integration # volumes: - # - name: docker-socket - # path: /var/run/docker.sock + # - name: dockersock + # path: /var/run # - name: tmp # path: /tmp # when: @@ -109,6 +123,40 @@ steps: # depends_on: # - basic-integration + - name: iso + image: autonomy/build-container:latest + pull: always + environment: + BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234 + BINDIR: /usr/local/bin + commands: + - make talos-iso + volumes: + - name: dockersock + path: /var/run + when: + event: tag + depends_on: + ## Should change to e2e once we get things more stable + - basic-integration + + - name: gce + image: autonomy/build-container:latest + pull: always + environment: + BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234 + BINDIR: /usr/local/bin + commands: + - make talos-gce + volumes: + - name: dockersock + path: /var/run + when: + event: tag + depends_on: + ## Should change to e2e once we get things more stable + - basic-integration + - name: push image: autonomy/build-container:latest pull: always @@ -122,47 +170,16 @@ steps: - make login - make push volumes: - - name: docker-socket - path: /var/run/docker.sock + - name: dockersock + path: /var/run when: event: exclude: - pull_request depends_on: + ## Should change to e2e once we get things more stable - basic-integration - - name: iso - image: 'autonomy/installer:${DRONE_COMMIT_SHA:0:7}' - pull: always - environment: - BUILDKIT_HOST: tcp://buildkitd.ci.svc:1234 - BINDIR: /usr/local/bin - commands: - - entrypoint.sh iso - volumes: - - name: docker-socket - path: /var/run/docker.sock - when: - event: tag - depends_on: - - push - - - name: gce - image: 'autonomy/installer:${DRONE_COMMIT_SHA:0:7}' - pull: always - privileged: true - commands: - - mkdir /out - - bash entrypoint.sh install -n disk -r -p googlecloud -u none - - tar -C /out -czf ./build/talos-gce.tar.gz disk.raw - volumes: - - name: dev - path: /dev - when: - event: tag - depends_on: - - push - - name: release image: plugins/github-release settings: @@ -177,20 +194,17 @@ steps: when: event: tag depends_on: + ## Should change to e2e once we get things more stable + - basic-integration - iso - gce volumes: - - name: docker-socket - host: - path: /run/docker.sock - - name: dev - host: - path: /dev + - name: dockersock + temp: {} - name: tmp temp: {} - - name: containerd - temp: {} + --- kind: pipeline name: notify diff --git a/.gitignore b/.gitignore index 4f5419570..9acae0608 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ vendor # Go coverage.txt +.artifacts/ # buildkit cache .buildkit/ diff --git a/Makefile b/Makefile index bc3a0c4fb..f278f7267 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ DOCKER_TEST_ARGS = --security-opt seccomp:unconfined --privileged -v /var/lib/co all: ci drone .PHONY: drone -drone: rootfs initramfs kernel binaries installer talos test +drone: rootfs initramfs kernel binaries installer talos .PHONY: ci ci: builddeps buildkitd @@ -212,7 +212,16 @@ e2e-integration: .PHONY: test test: buildkitd - @$(BINDIR)/buildctl --addr $(BUILDKIT_HOST) build --output type=docker,name=docker.io/autonomy/$@:$(TAG) --opt target=$@ $(COMMON_ARGS) | docker load + @mkdir -p build + @$(BINDIR)/buildctl --addr $(BUILDKIT_HOST) \ + build \ + --output type=docker,dest=/tmp/$@.tar,name=docker.io/autonomy/$@:$(TAG) \ + --opt target=$@ \ + $(COMMON_ARGS) + @docker load < /tmp/$@.tar + @trap "rm -rf ./.artifacts" EXIT; mkdir -p ./.artifacts && \ + docker run -i --rm $(DOCKER_TEST_ARGS) -v $(PWD)/.artifacts:/src/artifacts autonomy/$@:$(TAG) /bin/test.sh && \ + cp ./.artifacts/coverage.txt coverage.txt .PHONY: dev-test dev-test: diff --git a/hack/golang/test.sh b/hack/golang/test.sh index 877077c19..2d548f2f6 100755 --- a/hack/golang/test.sh +++ b/hack/golang/test.sh @@ -6,7 +6,7 @@ CGO_ENABLED=1 perform_tests() { echo "Performing tests" - go test -v -covermode=atomic -coverprofile=coverage.txt -p 1 ./... + go test -v -covermode=atomic -coverprofile=artifacts/coverage.txt -p 1 ./... } perform_short_tests() { diff --git a/hack/test/basic-integration.sh b/hack/test/basic-integration.sh index a13b381d7..e19e4172b 100755 --- a/hack/test/basic-integration.sh +++ b/hack/test/basic-integration.sh @@ -9,13 +9,11 @@ export KUBECONFIG="${TMP}/kubeconfig" cleanup() { - ${OSCTL} cluster destroy --name "${DRONE_COMMIT_SHA:0:7}" + ${OSCTL} cluster destroy --name integration rm -rf ${TMP} } trap cleanup EXIT ./hack/test/osctl-cluster-create.sh -${OSCTL} config generate cluster.local 1.2.3.4,2.3.4.5,3.4.5.6 - exit 0 diff --git a/hack/test/osctl-cluster-create.sh b/hack/test/osctl-cluster-create.sh index 9d7926189..8b274ca6e 100755 --- a/hack/test/osctl-cluster-create.sh +++ b/hack/test/osctl-cluster-create.sh @@ -5,28 +5,28 @@ set -eou pipefail ## If we take longer than 5m in docker, we're probably boned anyways TIMEOUT=300 -CONTAINER_ID=$(docker ps -f label=io.drone.build.number=${DRONE_BUILD_NUMBER} -f label=io.drone.repo.namespace=${DRONE_REPO_NAMESPACE} -f label=io.drone.repo.name=${DRONE_REPO_NAME} -f label=io.drone.step.name=basic-integration --format='{{ .ID }}') - run() { docker run \ --rm \ --interactive \ - --net="${DRONE_COMMIT_SHA:0:7}" \ + --net=integration \ --entrypoint=bash \ - --volumes-from=${CONTAINER_ID} \ + --mount type=bind,source=${TMP},target=${TMP} \ + --mount type=bind,source=${PWD}/hack/dev/manifests,target=/manifests \ + -v ${OSCTL}:/bin/osctl:ro \ -e KUBECONFIG=${KUBECONFIG} \ -e TALOSCONFIG=${TALOSCONFIG} \ k8s.gcr.io/hyperkube:${KUBERNETES_VERSION} -c "${1}" } -${OSCTL} cluster create --name "${DRONE_COMMIT_SHA:0:7}" +${OSCTL} cluster create --name integration ${OSCTL} config target 10.5.0.2 ## Fetch kubeconfig run "timeout=\$((\$(date +%s) + ${TIMEOUT})) - until ${OSCTL} kubeconfig > ${KUBECONFIG} + until osctl kubeconfig > ${KUBECONFIG} do - if [[ \$(date +%s) -gt \$timeout ]] + if [[ \$(date +%s) -gt \$timeout ]] then exit 1 fi @@ -34,9 +34,9 @@ run "timeout=\$((\$(date +%s) + ${TIMEOUT})) done" ## Wait for all nodes to report in -run "timeout=\$((\$(date +%s) + ${TIMEOUT})) +run "timeout=\$((\$(date +%s) + ${TIMEOUT})) until kubectl get nodes -o json | jq '.items | length' | grep 4 >/dev/null - do + do if [[ \$(date +%s) -gt \$timeout ]] then exit 1 @@ -46,8 +46,7 @@ run "timeout=\$((\$(date +%s) + ${TIMEOUT})) done" ## Deploy needed manifests -MANIFESTS="${PWD}/hack/dev/manifests" -run "kubectl apply -f ${MANIFESTS}/psp.yaml -f ${MANIFESTS}/flannel.yaml -f ${MANIFESTS}/coredns.yaml" +run "kubectl apply -f /manifests/psp.yaml -f /manifests/flannel.yaml -f /manifests/coredns.yaml" ## Wait for all nodes ready run "kubectl wait --timeout=${TIMEOUT}s --for=condition=ready=true --all nodes"