Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move to reusable docker workflows #3597

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/actions/load-docker-images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Load Docker Images
description: Loads all docker images built in previous steps
runs:
using: "composite"
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: docker-*-artifact
- name: Load Docker images
shell: bash
run: |
for tar in artifacts/docker-*/ftl-*.tar; do
docker load -i "$tar"
done
21 changes: 21 additions & 0 deletions .github/actions/save-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Save Docker Images
description: Builds all docker images and saves them as artifacts
inputs:
service:
description: The service to build
required: true
runs:
using: "composite"
steps:
- name: Build Docker Image
shell: bash
run: |
just build-docker ${{ inputs.service }}
mkdir -p artifacts/ftl-${{ inputs.service }}
docker save -o artifacts/ftl-${{ inputs.service }}/ftl-${{ inputs.service }}.tar ftl0/ftl-${{ inputs.service }}:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
with:
name: docker-${{ inputs.service }}-artifact
path: artifacts/ftl-${{ inputs.service }}
retention-days: 1
12 changes: 12 additions & 0 deletions .github/actions/shard-docker-builds/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Shard Docker Builds
description: Outputs a matrix of all services to build
outputs:
matrix:
description: A matrix of all services to build
value: ${{ steps.set-matrix.outputs.matrix }}
runs:
using: "composite"
steps:
- id: set-matrix
shell: bash
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
45 changes: 28 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,27 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
- uses: cashapp/[email protected]
- id: set-matrix
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
docker-build:
name: Shard Docker Builds
uses: ./.github/actions/shard-docker-builds
build-docker-images:
name: Build ${{ matrix.service }} Docker Image
needs: docker-shard
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.docker-shard.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
- uses: cashapp/[email protected]
- uses: ./.github/actions/build-cache
- name: Build Docker Image
run: just build-docker ${{ matrix.service }}
- name: Build Image and Save
uses: ./.github/actions/save-docker-image
with:
service: ${{ matrix.service }}
console-e2e:
name: Console e2e
# if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all')
Expand Down Expand Up @@ -332,7 +335,9 @@ jobs:
infrastructure-run:
name: Infrastructure Test
#if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all')
needs: infrastructure-shard
needs:
- infrastructure-shard
- build-docker-images
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -348,16 +353,22 @@ jobs:
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/[email protected]
- name: Load Docker Images
uses: ./.github/actions/load-docker-images
- name: Start Cluster
run: just k8s setup-istio-cluster
- name: Tag and Push Docker Images
run: |
for image in $(just list-docker-images); do
docker tag "ftl0/ftl-${image}:latest" "localhost:5000/ftl-${image}:latest"
docker push "localhost:5000/ftl-${image}:latest"
done
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Docker Compose
run: just compose-up
- name: Create DB
run: just init-db
- name: Download Go Modules
run: go mod download
- name: Build Test Images
run: just k8s full-deploy
- name: Start FTL
run: just k8s apply
- name: Build Language Plugins
run: just build-language-plugins
- name: Run ${{ matrix.test }}
Expand Down Expand Up @@ -394,13 +405,13 @@ jobs:
fi
docker-success:
name: Docker Success
needs: [docker-build]
needs: [build-docker-images]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check docker builds result
run: |
if [[ "${{ needs.docker-build.result }}" == "failure" ]]; then
if [[ "${{ needs.build-docker-images.result }}" == "failure" ]]; then
echo "Docker builds failed"
exit 1
else
Expand Down
32 changes: 9 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cashapp/[email protected]
- name: Checkout code
uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
name: Shard Docker Builds
uses: ./.github/actions/shard-docker-builds
build-docker-images:
name: Build ${{ matrix.service }} Docker Image
needs: docker-shard
Expand All @@ -26,17 +27,10 @@ jobs:
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/[email protected]
- name: Build Docker Image
run: |
just build-docker ${{ matrix.service }}
mkdir -p artifacts/ftl-${{ matrix.service }}
docker save -o artifacts/ftl-${{ matrix.service }}/ftl-${{ matrix.service }}.tar ftl0/ftl-${{ matrix.service }}:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
- name: Build Image and Save
uses: ./.github/actions/save-docker-image
with:
name: docker-${{ matrix.service }}-artifact
path: artifacts/ftl-${{ matrix.service }}
retention-days: 1
service: ${{ matrix.service }}
release-docker:
name: Release Docker Images
runs-on: ubuntu-latest
Expand All @@ -51,16 +45,8 @@ jobs:
fetch-depth: 0
- name: Init Hermit
uses: cashapp/[email protected]
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: docker-*-artifact
- name: Load Docker images
run: |
for tar in artifacts/docker-*/ftl-*.tar; do
docker load -i "$tar"
done
- name: Load Docker Images
uses: ./.github/actions/load-docker-images
- name: Log in to Container registry
uses: docker/login-action@v3
with:
Expand Down
Loading