enhance: [skip e2e]extract cache stuff into a independent composite action (#29499)

fix: #29510

Signed-off-by: Sammy Huang <sammy.huang@zilliz.com>
pull/29496/head
sammy.huang 2023-12-27 11:56:57 +08:00 committed by GitHub
parent f6cff25712
commit d750dd95e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 87 deletions

49
.github/actions/cache/action.yaml vendored Normal file
View File

@ -0,0 +1,49 @@
name: 'Milvus Cache'
description: ''
inputs:
os:
description: 'OS name'
required: true
default: 'ubuntu20.04'
kind:
description: 'Cache kind'
required: false
default: 'all'
runs:
using: "composite"
steps:
- name: Generate CCache Hash
env:
CORE_HASH: ${{ hashFiles( 'internal/core/**/*.cpp', 'internal/core/**/*.cc', 'internal/core/**/*.c', 'internal/core/**/*.h', 'internal/core/**/*.hpp', 'internal/core/**/CMakeLists.txt') }}
run: |
echo "corehash=${CORE_HASH}" >> $GITHUB_ENV
echo "Set CCache hash to ${CORE_HASH}"
shell: bash
- name: Cache CCache Volumes
if: ${{ inputs.kind == 'all' || inputs.kind == 'cpp' }}
uses: actions/cache@v3
with:
path: .docker/amd64-${{ inputs.os }}-ccache
key: ${{ inputs.os }}-ccache-${{ env.corehash }}
restore-keys: ${{ inputs.os }}-ccache-
- name: Cache Conan Packages
if: ${{ inputs.kind == 'all' || inputs.kind == 'cpp' }}
uses: actions/cache@v3
with:
path: .docker/amd64-${{ inputs.os }}-conan
key: ${{ inputs.os }}-conan-${{ hashFiles('internal/core/conanfile.*') }}
restore-keys: ${{ inputs.os }}-conan-
- name: Cache Third Party
if: ${{ inputs.kind == 'all' || inputs.kind == 'thirdparty' }}
uses: actions/cache@v3
with:
path: .docker/thirdparty
key: ${{ inputs.os }}-thirdparty-${{ hashFiles('internal/core/thirdparty/**') }}
restore-keys: ${{ inputs.os }}-thirdparty-
- name: Cache Go Mod Volumes
if: ${{ inputs.kind == 'all' || inputs.kind == 'go' }}
uses: actions/cache@v3
with:
path: .docker/amd64-${{ inputs.os }}-go-mod
key: ${{ inputs.os }}-go-mod-${{ hashFiles('go.sum, */go.sum') }}
restore-keys: ${{ inputs.os }}-go-mod-

View File

@ -50,37 +50,16 @@ jobs:
remove-haskell: 'true'
- name: Checkout
uses: actions/checkout@v2
- name: 'Generate CCache Hash'
env:
CORE_HASH: ${{ hashFiles( 'internal/core/**/*.cpp', 'internal/core/**/*.cc', 'internal/core/**/*.c', 'internal/core/**/*.h', 'internal/core/**/*.hpp', 'internal/core/**/CMakeLists.txt') }}
run: |
echo "corehash=${CORE_HASH}" >> $GITHUB_ENV
echo "Set CCache hash to ${CORE_HASH}"
- name: Cache CCache Volumes
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-ubuntu20.04-ccache
key: ubuntu20.04-ccache-${{ env.corehash }}
restore-keys: ubuntu20.04-ccache-
- name: Cache Go Mod Volumes
uses: actions/cache@v3
with:
path: .docker/amd64-ubuntu20.04-go-mod
key: ubuntu20.04-go-mod-${{ hashFiles('go.sum, */go.sum') }}
restore-keys: ubuntu20.04-go-mod-
- name: Cache Conan Packages
uses: actions/cache@v3
with:
path: .docker/amd64-ubuntu20.04-conan
key: ubuntu20.04-conan-${{ hashFiles('internal/core/conanfile.*') }}
restore-keys: ubuntu20.04-conan-
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
os: 'ubuntu20.04'
- name: Code Check
env:
OS_NAME: 'ubuntu20.04'
run: |
./build/builder.sh /bin/bash -c "make check-proto-product && make verifiers"
amazonlinux:
name: Code Checker Amazonlinux 2023
# Run in amazonlinux docker
@ -98,36 +77,10 @@ jobs:
remove-haskell: 'true'
- name: Checkout
uses: actions/checkout@v2
- name: 'Generate CCache Hash'
env:
CORE_HASH: ${{ hashFiles( 'internal/core/**/*.cpp', 'internal/core/**/*.cc', 'internal/core/**/*.c', 'internal/core/**/*.h', 'internal/core/**/*.hpp', 'internal/core/**/CMakeLists.txt') }}
run: |
echo "corehash=${CORE_HASH}" >> $GITHUB_ENV
echo "Set CCache hash to ${CORE_HASH}"
- name: Cache CCache Volumes
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-amazonlinux2023-ccache
key: amazonlinux2023-ccache-${{ env.corehash }}
restore-keys: amazonlinux2023-ccache-
- name: Cache Third Party
uses: actions/cache@v3
with:
path: .docker/thirdparty
key: amazonlinux2023-thirdparty-${{ hashFiles('internal/core/thirdparty/**') }}
restore-keys: amazonlinux2023-thirdparty-
- name: Cache Go Mod Volumes
uses: actions/cache@v3
with:
path: .docker/amd64-amazonlinux2023-go-mod
key: amazonlinux2023-go-mod-${{ hashFiles('go.sum, */go.sum') }}
restore-keys: amazonlinux2023-go-mod-
- name: Cache Conan Packages
uses: actions/cache@v3
with:
path: .docker/amd64-amazonlinux2023-conan
key: amazonlinux2023-conan-${{ hashFiles('internal/core/conanfile.*') }}
restore-keys: amazonlinux2023-conan-
os: 'amazonlinux2023'
- name: Code Check
run: |
sed -i 's/ubuntu20.04/amazonlinux2023/g' .env

View File

@ -85,25 +85,11 @@ jobs:
run: |
echo "useasan=ON" >> $GITHUB_ENV
echo "Setup USE_ASAN to true since cpp file(s) changed"
- name: 'Generate CCache Hash'
env:
CORE_HASH: ${{ hashFiles( 'internal/core/**/*.cpp', 'internal/core/**/*.cc', 'internal/core/**/*.c', 'internal/core/**/*.h', 'internal/core/**/*.hpp', 'internal/core/**/CMakeLists.txt', 'internal/core/conanfile.py') }}
run: |
echo "corehash=${CORE_HASH}" >> $GITHUB_ENV
echo "Set CCache hash to ${CORE_HASH}"
- name: Cache CCache Volumes
# uses: actions/cache@v3
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-ubuntu${{ matrix.ubuntu }}-ccache
key: ubuntu${{ matrix.ubuntu }}-ccache-${{ env.corehash }}
restore-keys: ubuntu${{ matrix.ubuntu }}-ccache-
- name: Cache Conan Packages
uses: actions/cache@v3
with:
path: .docker/amd64-ubuntu${{ matrix.ubuntu }}-conan
key: ubuntu${{ matrix.ubuntu }}-conan-${{ hashFiles('internal/core/conanfile.*') }}
restore-keys: ubuntu${{ matrix.ubuntu }}-conan-
os: 'ubuntu20.04'
kind: 'cpp'
- name: Build
run: |
./build/builder.sh /bin/bash -c "make USE_ASAN=${{env.useasan}} build-cpp-with-coverage"
@ -133,12 +119,11 @@ jobs:
- run: |
unzip code.zip
rm code.zip
- name: Cache Conan Packages
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-ubuntu${{ matrix.ubuntu }}-conan
key: ubuntu${{ matrix.ubuntu }}-conan-${{ hashFiles('internal/core/conanfile.*') }}
restore-keys: ubuntu${{ matrix.ubuntu }}-conan-
os: 'ubuntu20.04'
kind: 'cpp'
- name: Start Service
shell: bash
run: |
@ -177,12 +162,11 @@ jobs:
- run: |
unzip code.zip
rm code.zip
- name: Cache Go Mod Volumes
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-ubuntu${{ matrix.ubuntu }}-go-mod
key: ubuntu${{ matrix.ubuntu }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ubuntu${{ matrix.ubuntu }}-go-mod-
os: 'ubuntu20.04'
kind: 'go'
- name: Start Service
shell: bash
run: |
@ -221,12 +205,11 @@ jobs:
- run: |
unzip code.zip
rm code.zip
- name: Cache Go Mod Volumes
uses: actions/cache@v3
- name: Download Caches
uses: ./.github/actions/cache
with:
path: .docker/amd64-ubuntu${{ matrix.ubuntu }}-go-mod
key: ubuntu${{ matrix.ubuntu }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ubuntu${{ matrix.ubuntu }}-go-mod-
os: 'ubuntu20.04'
kind: 'go'
- name: Start Service
shell: bash
run: |