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

Optimize build and release pipelines #557

Merged
merged 81 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
720cfc2
split docker build in stages to minimize size
Jan 30, 2024
9dcf921
add builder tag
Jan 30, 2024
8a2d90a
use redis image instead of redis-stack
Jan 30, 2024
3262ce4
single line apt-get
Jan 30, 2024
24bd4a3
WIP - restructuring build pipeline
Jan 31, 2024
b4481d1
fix build image
Jan 31, 2024
9a7b88a
trying fix for image name
Jan 31, 2024
90a8ccf
remove copy bin
Jan 31, 2024
7312669
trying save cache after build
Jan 31, 2024
7527f17
change image artifact upload method
Jan 31, 2024
9d45b8d
re-add caching
Jan 31, 2024
68199ea
temp - remove arm arch
Jan 31, 2024
8b9375b
rm non-required digests
Jan 31, 2024
48e7bb5
rm digest
Jan 31, 2024
d017d03
fix cache and path
Jan 31, 2024
978d789
checkout repo
Jan 31, 2024
c529773
deps
Jan 31, 2024
659578b
trying to split compiler image for caching purposes
Jan 31, 2024
47fb5cc
trying fix compiler image
Jan 31, 2024
191a71f
trying fix compiler image
Jan 31, 2024
eefe533
change base image name
Jan 31, 2024
053fa7b
trying remove buildx
Jan 31, 2024
daad110
trying to get docker to use local image
Jan 31, 2024
beed0d2
remove args
Jan 31, 2024
e7db9d5
add service port
Jan 31, 2024
a4804fc
fix image name
Jan 31, 2024
1f4e861
fix cache image
Feb 1, 2024
2c31ab7
run tests using compiler image
Feb 1, 2024
b71fc6c
remove image type
Feb 1, 2024
24cb827
load compiler image
Feb 1, 2024
4af1e8f
tag compiler image
Feb 1, 2024
90161c9
testing image save
Feb 1, 2024
ddeed97
trying oci format
Feb 1, 2024
67380ff
type=docker
Feb 1, 2024
13885a1
trying builx save
Feb 1, 2024
9d54cb0
remove cache
Feb 1, 2024
e017340
test remove save
Feb 1, 2024
a79f88e
export compiler image
Feb 1, 2024
6acf97a
trying pull image first
Feb 1, 2024
1f5a57c
re-tag image
Feb 1, 2024
23a407c
tag test image
Feb 1, 2024
2d82bf2
list images
Feb 1, 2024
74c8723
try set base image name
Feb 1, 2024
0a80c82
add registry
Feb 1, 2024
eb1384c
trying pull image
Feb 1, 2024
2e91e59
push image
Feb 1, 2024
be0b2ed
fix test dir
Feb 1, 2024
683e4b0
add arm64
Feb 1, 2024
9c1a7ae
create release image flow
Feb 1, 2024
aae8b65
fix branch
Feb 1, 2024
1331118
fix file name
Feb 1, 2024
e19ae70
fix push
Feb 1, 2024
2bd7a46
fix digest folder
Feb 1, 2024
66ba934
tag image
Feb 1, 2024
1b81535
list images
Feb 1, 2024
74b6fd9
image name based on architecture
Feb 1, 2024
118bef1
move around steps
Feb 2, 2024
099f777
remove cache skip
Feb 2, 2024
12a8ad9
fix tar name
Feb 2, 2024
9b614c9
fix bool value
Feb 2, 2024
07b09a2
Merge branch 'master' into optimize-docker-image
dudizimber Feb 3, 2024
83388b8
- arg order
Feb 3, 2024
820301f
release on push to master and release
Feb 4, 2024
472ae7f
fix target platform argument
Feb 4, 2024
cda49af
fix image ref
Feb 4, 2024
b8ae20d
add push to master
Feb 4, 2024
55a6368
add base image arg
Feb 4, 2024
22fadda
add target platform for test
Feb 4, 2024
83f378b
test in both architectures
Feb 4, 2024
275e3b0
tests after build
Feb 4, 2024
97f0c9b
remove test folder requirement as it uses the compiler image
Feb 4, 2024
b0054b4
fix file
Feb 4, 2024
742152f
test with image platform
Feb 4, 2024
0c15daf
add platform to test image
Feb 4, 2024
f13527d
setup qemu for tests in arm
Feb 4, 2024
dc40987
- change trigger to pull request
Feb 7, 2024
49f6d21
test caching compiler image
Feb 7, 2024
bb50d9c
remove lib caching
Feb 7, 2024
2c49ec7
Revert "remove lib caching"
Feb 7, 2024
c6f113b
Revert "test caching compiler image"
Feb 7, 2024
25fc200
Merge branch 'master' into optimize-docker-image
AviAvni Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
318 changes: 190 additions & 128 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,169 +1,231 @@
name: Build on ubuntu

on:
push:
workflow_dispatch:
release:
types: [published]
pull_request_review:
dudizimber marked this conversation as resolved.
Show resolved Hide resolved
types: [submitted]
dudizimber marked this conversation as resolved.
Show resolved Hide resolved
push:
branches:
- master

jobs:
build:
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.base.ref == 'master' && github.event.review.state == 'approved')
dudizimber marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
container: falkordb/falkordb-build:latest
services:
registry:
image: registry:2
ports:
- 5000:5000
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Safe dir
run: git config --global --add safe.directory '*'

- name: Safe dir
run: git config --global --add safe.directory '*'

- uses: actions/checkout@v3
with:
set-safe-directory: '*'
submodules: recursive

- name: Cache GraphBLAS ${{ matrix.platform }}
if: github.event_name == 'push'
id: cache_graphblas
uses: actions/cache@v3
with:
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/GraphBLAS
key: graphblas-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/GraphBLAS/Include/GraphBLAS.h') }}

- name: Cache parser ${{ matrix.platform }}
if: github.event_name == 'push'
id: cache_parser
uses: actions/cache@v3
with:
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/libcypher-parser
key: parser-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/libcypher-parser/lib/src/parser.c') }}

- name: Cache search ${{ matrix.platform }}
if: github.event_name == 'push'
id: cache_search
uses: actions/cache@v3
with:
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/search-static
key: search-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/RediSearch/src/version.h') }}

# Make sure the working directory is static between runs
# and always the same for the CMake cache
- name: Relocate source
run: |
mkdir -p /FalkorDB
mv $GITHUB_WORKSPACE/* /FalkorDB

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: /FalkorDB
file: /FalkorDB/build/docker/Dockerfile
platforms: ${{ matrix.platform }}
outputs: type=image,name=falkordb/falkordb,push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Copy bin from docker on PUSH
if: github.event_name == 'push'
working-directory: /FalkorDB
run: |
id=$(docker create --platform=${{ matrix.platform }} falkordb/falkordb@${{ steps.build.outputs.digest }})
docker cp $id:/FalkorDB/bin .
docker rm -v $id

merge:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download digests
uses: actions/download-artifact@v3
- uses: actions/checkout@v3
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
set-safe-directory: "*"
submodules: recursive

- name: Cache GraphBLAS ${{ matrix.platform }}
id: cache_graphblas
uses: actions/cache@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create manifest list and push on PUSH
if: github.event_name == 'push'
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t falkordb/falkordb:${{ github.ref_name == 'master' && 'master -t falkordb/falkordb:edge' || github.ref_name }} \
$(printf 'falkordb/falkordb@sha256:%s ' *)
- name: Create manifest list and push on RELEASE
if: github.event_name == 'release'
working-directory: /tmp/digests
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/GraphBLAS
key: graphblas-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/GraphBLAS/Include/GraphBLAS.h') }}

- name: Cache parser ${{ matrix.platform }}
id: cache_parser
uses: actions/cache@v3
with:
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/libcypher-parser
key: parser-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/libcypher-parser/lib/src/parser.c') }}

- name: Cache search ${{ matrix.platform }}
id: cache_search
uses: actions/cache@v3
with:
path: /FalkorDB/bin/linux-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-release/search-static
key: search-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8' }}-${{ hashFiles('./deps/RediSearch/src/version.h') }}

# Make sure the working directory is static between runs
# and always the same for the CMake cache
- name: Relocate source
run: |
docker buildx imagetools create -t falkordb/falkordb:${{ github.event.release.tag_name }} -t falkordb/falkordb:latest \
$(printf 'falkordb/falkordb@sha256:%s ' *)
- name: Inspect image
mkdir -p /FalkorDB
mv $GITHUB_WORKSPACE/* /FalkorDB

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
# network=host driver-opt needed to push to local registry
driver-opts: network=host

- name: Build compiler image
id: build_compiler
uses: docker/build-push-action@v5
with:
context: /FalkorDB
file: /FalkorDB/build/docker/Dockerfile.compiler
platforms: ${{ matrix.platform }}
tags: localhost:5000/falkordb/falkordb-compiler
# outputs: type=docker,dest=/tmp/falkordb-compiler.tar
push: true
build-args: |
TARGETPLATFORM=${{ matrix.platform }}
dudizimber marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +78 to +89
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build process for the compiler image is correctly configured. However, consider the previous comment about caching build files instead of the build itself for potentially better efficiency.


- name: Copy bin from docker for caching
working-directory: /FalkorDB
if: steps.cache_graphblas.outputs.cache-hit == false || steps.cache_parser.outputs.cache-hit == false || steps.cache_search.outputs.cache-hit == false
run: |
docker buildx imagetools inspect falkordb/falkordb:latest
id=$(docker create --platform=${{ matrix.platform }} localhost:5000/falkordb/falkordb-compiler)
docker cp $id:/FalkorDB/bin /FalkorDB/bin
docker rm -v $id
ls -l -R /FalkorDB/bin

- name: Build tests image
uses: docker/build-push-action@v5
with:
context: .
file: /FalkorDB/tests/Dockerfile
outputs: type=docker,dest=/tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar
dudizimber marked this conversation as resolved.
Show resolved Hide resolved
tags: falkordb/falkordb-tests
build-args: |
BASE_IMAGE=localhost:5000/falkordb/falkordb-compiler
TARGETPLATFORM=${{ matrix.platform }}

- name: Upload tests image
uses: actions/upload-artifact@v3
with:
name: falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar
if-no-files-found: error

- name: Build base image
id: build
uses: docker/build-push-action@v5
with:
context: /FalkorDB
file: /FalkorDB/build/docker/Dockerfile
platforms: ${{ matrix.platform }}
outputs: type=docker,dest=/tmp/falkordb-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar
tags: falkordb/falkordb-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
build-args: |
BASE_IMAGE=localhost:5000/falkordb/falkordb-compiler
TARGETPLATFORM=${{ matrix.platform }}

- name: Upload image
uses: actions/upload-artifact@v3
with:
name: falkordb-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp/falkordb-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar
if-no-files-found: error

unit-tests:
needs: build
runs-on: ubuntu-latest
container: falkordb/falkordb:${{ github.ref_name }}
needs: merge
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp

- name: Load image
id: load_image
run: |
docker load --input /tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar

- name: Unit tests
working-directory: /FalkorDB
run: make unit-tests CLEAR_LOGS=0
run: |
docker run --platform ${{ matrix.platform }} --rm falkordb/falkordb-tests make CLEAR_LOGS=0 unit-tests

flow-tests:
needs: build
runs-on: ubuntu-latest
container: falkordb/falkordb:${{ github.ref_name }}
needs: merge
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp

- name: Load image
id: load_image
run: |
docker load --input /tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar

- name: Flow tests
working-directory: /FalkorDB
run: make CLEAR_LOGS=0 PARALLEL=4 flow-tests
run: |
docker run --platform ${{ matrix.platform }} --rm falkordb/falkordb-tests make CLEAR_LOGS=0 PARALLEL=4 flow-tests

tck-tests:
needs: build
runs-on: ubuntu-latest
container: falkordb/falkordb:${{ github.ref_name }}
needs: merge
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp

- name: Load image
id: load_image
run: |
docker load --input /tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar

- name: TCK tests
working-directory: /FalkorDB
run: make CLEAR_LOGS=0 tck-tests
run: |
docker run --platform ${{ matrix.platform }} --rm falkordb/falkordb-tests make CLEAR_LOGS=0 tck-tests

fuzz-tests:
needs: build
runs-on: ubuntu-latest
container: falkordb/falkordb:${{ github.ref_name }}
needs: merge
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}
path: /tmp

- name: Load image
id: load_image
run: |
docker load --input /tmp/falkordb-tests-${{ matrix.platform == 'linux/amd64' && 'x64' || 'arm64v8'}}.tar

- name: Fuzz tests
working-directory: /FalkorDB
run: make fuzz TIMEOUT=180
run: |
docker run --platform ${{ matrix.platform }} --rm falkordb/falkordb-tests make fuzz TIMEOUT=180