From 2eb0227c41f680575c6c51517baa5c523379dc0f Mon Sep 17 00:00:00 2001 From: ChaudharyRaman Date: Mon, 25 Mar 2024 23:30:01 +0530 Subject: [PATCH] feat: reuseable workflow Signed-off-by: ChaudharyRaman change build_xline workflow Signed-off-by: ChaudharyRaman fix: trailing space Signed-off-by: ChaudharyRaman feat: bump script version Signed-off-by: ChaudharyRaman --- .github/workflows/benchmark.yml | 33 +++++-------- .github/workflows/build_xline.yml | 80 +++++++++++++++++++++++++++++++ .github/workflows/validation.yml | 41 +++++++--------- 3 files changed, 109 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/build_xline.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 3a7f29e63..682a4a0e4 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -24,23 +24,16 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Build xline - run: | - docker run -q --rm -v $(pwd):/xline \ - -e SCCACHE_GHA_ENABLED=on \ - -e ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL} \ - -e ACTIONS_RUNTIME_TOKEN=${ACTIONS_RUNTIME_TOKEN} \ - ghcr.io/xline-kv/build-env:latest \ - cargo build --release --bin xline --bin benchmark - - - run: | - cd scripts - cp ../target/release/{xline,benchmark} . - docker build . -t ghcr.io/xline-kv/xline:latest - docker pull datenlord/etcd:v3.5.5 - bash ./benchmark.sh - - - uses: actions/upload-artifact@v4 - with: - name: benchmark-output - path: scripts/out + call_build_xline: + name: Build and Upload Artifacts + uses: ./.github/workflows/build_xline.yml + with: + docker_xline_image: "ghcr.io/xline-kv/build-env:latest" + release_bin: "--bin xline --bin benchmark" + binaries: "xline,benchmark" + additional_setup_commands: | + docker build . -t ghcr.io/xline-kv/xline:latest + docker pull datenlord/etcd:v3.5.5 + script_name: "benchmark.sh" + uploadLogs: false + uploadBenchmark: true diff --git a/.github/workflows/build_xline.yml b/.github/workflows/build_xline.yml new file mode 100644 index 000000000..8de0cb6a9 --- /dev/null +++ b/.github/workflows/build_xline.yml @@ -0,0 +1,80 @@ +name: Build Xline +env: + CI_RUST_TOOLCHAIN: 1.71.0 +on: + workflow_call: + inputs: + release_bin: + description: "list of binaries to build" + required: true + type: string + additional_setup_commands: + description: "Additional commands to run after initial setup, before running the script" + required: false + default: "" + type: string + docker_xline_image: + description: "Docker image to use for building" + required: true + type: string + binaries: + description: "Comma-separated list of binaries to copy" + required: true + type: string + script_name: + description: "Name of the script to run" + required: true + type: string + uploadLogs: + description: "Boolean to decide if logs should be uploaded" + required: false + default: false + type: boolean + uploadBenchmark: + description: "Boolean to decide if benchmark output should be uploaded" + required: false + default: false + type: boolean +jobs: + build_and_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure sccache + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Build xline + run: | + docker run -q --rm -v $(pwd):/xline \ + -e SCCACHE_GHA_ENABLED=on \ + -e ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL} \ + -e ACTIONS_RUNTIME_TOKEN=${ACTIONS_RUNTIME_TOKEN} \ + ${{ inputs.docker_xline_image }} \ + cargo build --release ${{ inputs.release_bin }} + + - run: | + cd scripts + cp ../target/release/{${{ inputs.binaries }}} . + ${{ inputs.additional_setup_commands }} + bash ./${{ inputs.script_name }} + + - name: Upload logs + if: ${{ inputs.uploadLogs }} && (failure() || cancelled()) + uses: actions/upload-artifact@v4 + with: + name: Xline logs + path: scripts/logs + + - name: Upload benchmark output + if: ${{ inputs.uploadBenchmark }} + uses: actions/upload-artifact@v4 + with: + name: benchmark-output + path: scripts/out diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index e1ddb0d26..0e87565ce 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -23,28 +23,19 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Build xline - run: | - docker run -q --rm -v $(pwd):/xline \ - -e SCCACHE_GHA_ENABLED=on \ - -e ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL} \ - -e ACTIONS_RUNTIME_TOKEN=${ACTIONS_RUNTIME_TOKEN} \ - ghcr.io/xline-kv/build-env:latest \ - cargo build --release --bin xline --bin benchmark --bin validation_lock_client - - - run: | - sudo apt-get install -y --force-yes expect - cd scripts - cp ../target/release/{xline,benchmark,validation_lock_client} . - ldd ./xline - ldd ./benchmark - cp ../fixtures/{private,public}.pem . - docker build . -t ghcr.io/xline-kv/xline:latest - docker pull gcr.io/etcd-development/etcd:v3.5.5 - bash ./validation_test.sh - - name: upload logs - if: failure() || cancelled() - uses: actions/upload-artifact@v4 - with: - name: Xline logs - path: scripts/logs + call_build_xline: + name: Build and Upload Artifacts + uses: ./.github/workflows/build_xline.yml + with: + release_bin: '--bin xline --bin benchmark --bin validation_lock_client' + docker_xline_image: 'ghcr.io/xline-kv/build-env:latest' + additional_setup_commands: | + sudo apt-get install -y --force-yes expect + ldd ./xline + ldd ./benchmark + cp ../fixtures/{private,public}.pem . + docker build . -t ghcr.io/xline-kv/xline:latest + docker pull gcr.io/etcd-development/etcd:v3.5.5 + binaries: 'xline,benchmark,validation_lock_client' + script_name: 'validation_test.sh' + uploadLogs: true