From 14d12e6c847f6e2dc4b94c4641758bbfcc90c72d Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 30 Aug 2024 13:20:29 +1000 Subject: [PATCH] chore(ci): build docker images in merge queue (#2562) --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ .github/workflows/release.yml | 8 +++++--- Justfile | 7 +++++-- scripts/go-test-annotate | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94cd59207..a96e06334 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,6 +198,33 @@ jobs: - uses: actions/checkout@v4 - uses: cashapp/activate-hermit@v1 - run: go-arch-lint check || true + docker-build-controller: + name: Build Controller Docker Image + if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cashapp/activate-hermit@v1 + - uses: ./.github/actions/build-cache + - run: just build-docker controller + docker-build-runner: + name: Build Runner Docker Image + if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cashapp/activate-hermit@v1 + - uses: ./.github/actions/build-cache + - run: just build-docker runner + docker-build-box: + name: Build Box Docker Image + if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cashapp/activate-hermit@v1 + - uses: ./.github/actions/build-cache + - run: just build-docker box console-e2e: name: Console e2e if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1700d9270..1b18bc122 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: uses: cashapp/activate-hermit@v1 - name: Build run: | - docker build -t ftl0/ftl-runner:"$GITHUB_SHA" -t ftl0/ftl-runner:latest -f Dockerfile.runner . + just build-docker runner mkdir -p artifacts/ftl-runner docker save -o artifacts/ftl-runner/ftl-runner.tar ftl0/ftl-runner:latest - name: Temporarily save Docker image @@ -34,7 +34,7 @@ jobs: uses: cashapp/activate-hermit@v1 - name: Build run: | - docker build -t ftl0/ftl-controller:"$GITHUB_SHA" -t ftl0/ftl-controller:latest -f Dockerfile.controller . + just build-docker controller mkdir -p artifacts/ftl-controller docker save -o artifacts/ftl-controller/ftl-controller.tar ftl0/ftl-controller:latest - name: Temporarily save Docker image @@ -53,7 +53,7 @@ jobs: uses: cashapp/activate-hermit@v1 - name: Build run: | - docker build -t ftl0/ftl-box:"$GITHUB_SHA" -t ftl0/ftl-box:latest -f Dockerfile.box . + just build-docker box mkdir -p artifacts/ftl-box docker save -o artifacts/ftl-box/ftl-box.tar ftl0/ftl-box:latest - name: Temporarily save Docker image @@ -163,6 +163,8 @@ jobs: git push origin main vscode-release: name: Release VSCode Extension + # Disabled for now as it's broken. + if: false runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/Justfile b/Justfile index d9898f82a..a33fbd397 100644 --- a/Justfile +++ b/Justfile @@ -201,8 +201,6 @@ debug *args: # `just otel-dev` with any args you would pass to `ftl dev`. To stop the otel stream, run # `just otel-stop` in a third terminal tab. otel-stream: - #!/bin/bash - docker run \ -p ${OTEL_GRPC_PORT}:${OTEL_GRPC_PORT} \ -p 55679:55679 \ @@ -218,6 +216,7 @@ otel-stop: # Run `ftl dev` with the given args after setting the necessary envar. otel-dev *args: #!/bin/bash + set -euo pipefail export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:${OTEL_GRPC_PORT}" export OTEL_METRIC_EXPORT_INTERVAL=${OTEL_METRIC_EXPORT_INTERVAL} @@ -240,3 +239,7 @@ grafana-stop: storybook: #!/bin/bash cd frontend && pnpm run storybook + +# Build an FTL Docker image. +build-docker name: + docker build --platform linux/amd64 -t ftl0/ftl-{{name}}:"${GITHUB_SHA:-$(git rev-parse HEAD)}" -t ftl0/ftl-{{name}}:latest -f Dockerfile.{{name}} . \ No newline at end of file diff --git a/scripts/go-test-annotate b/scripts/go-test-annotate index 60340b3c4..86959264f 100755 --- a/scripts/go-test-annotate +++ b/scripts/go-test-annotate @@ -7,7 +7,7 @@ set -euo pipefail # then match lines containing lines that look like error messages. fail=0 -if ! gotestsum --format-hide-empty-pkg --junitfile junit-go.xml --junitfile-hide-empty-pkg -- -race -fullpath "$@" ./...; then +if ! gotestsum --format-hide-empty-pkg --junitfile junit-go.xml --junitfile-hide-empty-pkg -- -timeout 10m -race -fullpath "$@" ./...; then fail=1 fi