name: KinD integration on: pull_request: {} push: paths-ignore: - '*.md' - '**/*.md' branches: - master env: GH_ANNOTATION: true jobs: docker_build: name: Docker build runs-on: ubuntu-18.04 steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Set environment variables from scripts run: | . bin/_tag.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) . bin/_docker.sh echo ::set-env name=DOCKER_REGISTRY::$DOCKER_REGISTRY - name: Setup SSH config for Packet if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork run: | mkdir -p ~/.ssh/ touch ~/.ssh/id && chmod 600 ~/.ssh/id echo "${{ secrets.DOCKER_SSH_CONFIG }}" > ~/.ssh/config echo "${{ secrets.DOCKER_PRIVATE_KEY }}" > ~/.ssh/id echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts ssh linkerd-docker docker version echo ::set-env name=DOCKER_HOST::ssh://linkerd-docker - name: Build docker images env: DOCKER_TRACE: 1 run: | export PATH="`pwd`/bin:$PATH" bin/docker-build - name: Create artifact with CLI and image archives env: ARCHIVES: /home/runner/archives run: | mkdir -p $ARCHIVES for image in proxy controller web cni-plugin debug cli-bin grafana; do docker save "$DOCKER_REGISTRY/$image:$TAG" > $ARCHIVES/$image.tar || tee save_fail & done # Wait for `docker save` background processes to complete. Exit early # if any job failed. wait < <(jobs -p) test -f save_fail && exit 1 || true # `with.path` values do not support environment variables yet, so an # absolute path is used here. # # https://github.com/actions/upload-artifact/issues/8 - name: Upload artifact # actions/upload-artifact@v1 uses: actions/upload-artifact@3446296 with: name: image-archives path: /home/runner/archives # todo: Keep in sync with `release.yml` kind_integration_tests: strategy: matrix: integration_test: [deep, upgrade, helm, helm_upgrade, uninstall, custom_domain, external_issuer] needs: [docker_build] name: Integration tests (${{ matrix.integration_test }}) runs-on: ubuntu-18.04 steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Try to load cached Go modules # actions/cache@v1.1.2 uses: actions/cache@70655ec with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Set environment variables from scripts run: | . bin/_tag.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) . bin/_docker.sh echo ::set-env name=DOCKER_REGISTRY::$DOCKER_REGISTRY - name: Setup SSH config for Packet if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork run: | mkdir -p ~/.ssh/ touch ~/.ssh/id && chmod 600 ~/.ssh/id echo "${{ secrets.DOCKER_SSH_CONFIG }}" > ~/.ssh/config echo "${{ secrets.DOCKER_PRIVATE_KEY }}" > ~/.ssh/id echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts - name: Download image archives (Forked repositories) if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork # actions/download-artifact@v1 uses: actions/download-artifact@18f0f59 with: name: image-archives - name: Load cli-bin image into local docker images if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork run: | # `docker load` only accepts input from STDIN, so pipe the image # archive into the command. # # In order to pipe the image archive, set `DOCKER_HOST` for a single # command and `docker save` the CLI image from the Packet host. DOCKER_HOST=ssh://linkerd-docker docker save "$DOCKER_REGISTRY/cli-bin:$TAG" | docker load - name: Load cli-bin image into local docker images (Forked repositories) if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork run: docker load < image-archives/cli-bin.tar - name: Install CLI run: | # Copy the CLI out of the local cli-bin container. container_id=$(docker create "$DOCKER_REGISTRY/cli-bin:$TAG") docker cp $container_id:/out/linkerd-linux $HOME/.linkerd # Validate the CLI version matches the current build tag. [[ "$TAG" == "$($HOME/.linkerd version --short --client)" ]] - name: Setup default KinD cluster if: matrix.integration_test != 'custom_domain' run: bin/kind create cluster - name: Setup custom_domain KinD cluster if: matrix.integration_test == 'custom_domain' run: bin/kind create cluster --config test/testdata/custom_cluster_domain_config.yaml - name: Load image archives into the local KinD cluster if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork env: PROXY_INIT_IMAGE_NAME: gcr.io/linkerd-io/proxy-init:v1.3.1 PROMETHEUS_IMAGE_NAME: prom/prometheus:v2.15.2 run: | # Fetch images from the Packet host and load them into the local KinD cluster bin/kind-load --images --images-host ssh://linkerd-docker # Load proxy-init and prometheus images into KinD while it is # available. Allow these commands to fail since they will be cached # for the next run. kind load image-archive <(DOCKER_HOST=ssh://linkerd-docker docker save $PROXY_INIT_IMAGE_NAME) 2>&1 || true kind load image-archive <(DOCKER_HOST=ssh://linkerd-docker docker save $PROMETHEUS_IMAGE_NAME) 2>&1 || true - name: Load image archives into the local KinD cluster (Forked repositories) if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork run: | bin/kind-load --images - name: Run integration tests run: | # Export `init_test_run` and `*_integration_tests` into the # environment. . bin/_test-run.sh init_test_run $HOME/.linkerd ${{ matrix.integration_test }}_integration_tests