Skip to content

Commit

Permalink
Split pr and normal build (#10884)
Browse files Browse the repository at this point in the history
Motivation:

We should better use seperate workflows for PR and normal builds

Modifications:

- Split workflows
- Better cache reuse

Result:

Cleanup
  • Loading branch information
normanmaurer committed Dec 23, 2020
1 parent 33833de commit 9da336f
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 88 deletions.
15 changes: 15 additions & 0 deletions .github/scripts/check_leak.sh
@@ -0,0 +1,15 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Expected build log as argument"
exit 1
fi

if grep -q 'LEAK:' $1 ; then
echo "Leak detected, please inspect build log"
exit 1
else
echo "No Leak detected"
exit 0
fi

97 changes: 19 additions & 78 deletions .github/workflows/ci-build.yml
Expand Up @@ -3,8 +3,6 @@ name: Build project
on:
push:
branches: [ "4.1"]
pull_request:
branches: [ "4.1"]

schedule:
- cron: '30 1 * * 1' # At 01:30 on Monday, every Monday.
Expand All @@ -13,38 +11,22 @@ on:
workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
# Cache .m2/repository
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: verify-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
verify-${{ runner.os }}-maven-
- name: Verify with Maven
run: mvn verify -B --file pom.xml -DskipTests=true


build-linux-x86_64-java8:
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v2

# Cache .m2/repository
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: build-linux-x86_64-java8-cache-m2-repository
with:
path: ~/.m2/repository
key: build-linux-x86_64-java8-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
build-linux-x86_64-java8-${{ runner.os }}-maven-
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.8
Expand All @@ -58,23 +40,8 @@ jobs:
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.18.yaml build

- name: Build project without leak detection
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/4.1' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.18.yaml run build

- name: Build project with leak detection
if: ${{ github.event_name == 'pull_request' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.18.yaml run build-leak | tee build-leak.output

- name: Checking for detected leak
if: ${{ github.event_name == 'pull_request' }}
run: |
if grep -q 'LEAK:' build-leak.output ; then
echo "Leak detected, please inspect build log"
exit 1
else
echo "No Leak detected"
fi
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
Expand All @@ -83,17 +50,19 @@ jobs:

build-linux-x86_64-java11:
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v2

# Cache .m2/repository
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: build-linux-x86_64-java11-cache-m2-repository
with:
path: ~/.m2/repository
key: build-linux-x86_64-java11-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
build-linux-x86_64-java11-${{ runner.os }}-maven-
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.8
Expand All @@ -107,23 +76,8 @@ jobs:
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build

- name: Build project without leak detection
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/4.1' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build

- name: Build project with leak detection
if: ${{ github.event_name == 'pull_request' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build-leak | tee build-leak.output

- name: Checking for detected leak
if: ${{ github.event_name == 'pull_request' }}
run: |
if grep -q 'LEAK:' build-leak.output ; then
echo "Leak detected, please inspect build log"
exit 1
else
echo "No Leak detected"
fi
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
Expand All @@ -132,17 +86,19 @@ jobs:

build-linux-x86_64-java15:
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v2

# Cache .m2/repository
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: build-linux-x86_64-java15-cache-m2-repository
with:
path: ~/.m2/repository
key: build-linux-x86_64-java15-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
build-linux-x86_64-java15-${{ runner.os }}-maven-
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.8
Expand All @@ -156,23 +112,8 @@ jobs:
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.115.yaml build

- name: Build project without leak detection
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/4.1' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.115.yaml run build

- name: Build project with leak detection
if: ${{ github.event_name == 'pull_request' }}
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.115.yaml run build-leak | tee build-leak.output

- name: Checking for detected leak
if: ${{ github.event_name == 'pull_request' }}
run: |
if grep -q 'LEAK:' build-leak.output ; then
echo "Leak detected, please inspect build log"
exit 1
else
echo "No Leak detected"
fi
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/ci-deploy.yml
Expand Up @@ -26,20 +26,25 @@ jobs:
- uses: actions/checkout@v2

# Cache .m2/repository
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: deploy-linux-x86_64-cache-m2-repository
with:
path: ~/.m2/repository
key: deploy-linux-x86_64-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-deploy-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
deploy-linux-x86_64-${{ runner.os }}-maven-
${{ runner.os }}-deploy-${{ env.cache-name }}-
${{ runner.os }}-deploy-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.8
env:
docker-cache-name: deploy-linux-x86_64-cache-docker
continue-on-error: true
with:
key: deploy-linux-x86_64-docker-cache-{hash}
key: ${{ runner.os }}-deploy-${{ env.docker-cache-name }}-{hash}
restore-keys: |
deploy-linux-x86_64-docker-cache-
${{ runner.os }}-deploy-${{ env.docker-cache-name }}-
- name: Build docker image
run: docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.centos-6.18.yaml build
Expand All @@ -64,20 +69,25 @@ jobs:
- uses: actions/checkout@v2

# Cache .m2/repository
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: deploy-linux-aarch64-cache-m2-repository
with:
path: ~/.m2/repository
key: deploy-linux-aarch64-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-deploy-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
deploy-linux-aarch64-${{ runner.os }}-maven-
${{ runner.os }}-deploy-${{ env.cache-name }}-
${{ runner.os }}-deploy-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.8
env:
docker-cache-name: deploy-linux-aarch64-cache-docker
continue-on-error: true
with:
key: deploy-linux-aarch64-docker-cache-{hash}
key: ${{ runner.os }}-deploy-${{ env.docker-cache-name }}-{hash}
restore-keys: |
deploy-linux-aarch64-docker-cache-
${{ runner.os }}-deploy-${{ env.docker-cache-name }}-
- name: Build docker image
run: docker-compose -f docker/docker-compose.centos-7.yaml build
Expand Down

0 comments on commit 9da336f

Please sign in to comment.