Skip to content

Commit

Permalink
ci: Run integration tests on dedicated host (#358)
Browse files Browse the repository at this point in the history
Integration tests currently take 80+ minutes in GitHub Actions.

This change configures the integration test to be run on dedicated
Linkerd build infra, reducing the test time to ~30 minutes.
  • Loading branch information
olix0r authored Sep 23, 2019
1 parent 1382f0d commit 7626c2e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/actions/remote/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Intended to be run on a remote DOCKER_HOST
ARG RUST_IMAGE=rust:1.37.0-buster
FROM $RUST_IMAGE as build
WORKDIR /usr/src/linkerd2-proxy
COPY . ./
RUN ["make", "fetch"]
ENTRYPOINT ["make"]
57 changes: 54 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,59 @@ jobs:

integration:
runs-on: ubuntu-18.04
container:
image: docker://rust:1.37.0-buster
steps:
- uses: actions/checkout@v1
- run: make test-integration

# Forks run in GitHub actions, as they don't have access to secrets.
- name: Test (Fork)
if: github.event.pull_request.head.repo.fork
run: make test-integration

# Create a build image on a Linkerd build host.
- name: Setup (Origin)
if: '!github.event.pull_request.head.repo.fork'
env:
DOCKER_HOST: "ssh://linkerd-docker"
run: |
mkdir -p ~/.ssh
# Create an identity file and protect before writing contents to it.
touch ~/.ssh/id && chmod 600 ~/.ssh/id
echo "${{ secrets.DOCKER_PRIVATE_KEY }}" >~/.ssh/id
# Use well-known public keys for the host to prevent middlemen.
echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" >~/.ssh/known_hosts
# Configure host with ServerAliveInterval to ensure that the client
# stays alive even when the server is busy emitting nothing.
# ServerAliveCountMax ensures that server responds to these pings
# within ~5 minutes.
(
echo "Host linkerd-docker"
echo " User github"
echo " Hostname ${{ secrets.DOCKER_ADDRESS }}"
echo " IdentityFile ~/.ssh/id"
echo " BatchMode yes"
echo " ServerAliveInterval 60"
echo " ServerAliveCountMax 5"
) >~/.ssh/config
# Confirm that the SSH configuration works.
ssh linkerd-docker docker version
# Build once with output, then build again to get the img ref (should
# be a noop).
docker build -f .github/actions/remote/Dockerfile .
docker build -qf .github/actions/remote/Dockerfile . >image.ref
# Use the previously built image to run tests.
- name: Test (Origin)
if: '!github.event.pull_request.head.repo.fork'
env:
DOCKER_HOST: "ssh://linkerd-docker"
run: docker run --rm $(cat image.ref) test-integration

# Try to delete the build image.
- name: Cleanup (Origin)
if: always() && !github.event.pull_request.head.repo.fork
env:
DOCKER_HOST: "ssh://linkerd-docker"
run: |
if [ -f image.ref ]; then docker rmi -f $(cat image.ref)
else echo "skipped" >&2
fi

0 comments on commit 7626c2e

Please sign in to comment.