From 01d442f2473166fe200dcbe5096344221d529102 Mon Sep 17 00:00:00 2001 From: He Wang Date: Wed, 21 Aug 2024 11:34:25 +0800 Subject: [PATCH] modify workflows structure --- .../reusable/build-oblogproxy-ce-image.yml | 56 +++++++++++++++++++ .../build-oceanbase-ce-image.yml} | 0 .../test-oceanbase-ce-container.yml} | 2 +- .github/workflows/test-oblogproxy-ce.yml | 51 +++-------------- .github/workflows/test-oceanbase-ce.yml | 14 ++--- 5 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/reusable/build-oblogproxy-ce-image.yml rename .github/workflows/{build-oceanbase-ce.yml => reusable/build-oceanbase-ce-image.yml} (100%) rename .github/workflows/{java-test-oceanbase-ce.yml => reusable/test-oceanbase-ce-container.yml} (98%) diff --git a/.github/workflows/reusable/build-oblogproxy-ce-image.yml b/.github/workflows/reusable/build-oblogproxy-ce-image.yml new file mode 100644 index 0000000..679a2da --- /dev/null +++ b/.github/workflows/reusable/build-oblogproxy-ce-image.yml @@ -0,0 +1,56 @@ +name: build oblogproxy-ce image + +on: + workflow_call: + inputs: + cache_key: + required: true + type: string + image_file: + required: true + type: string + +jobs: + build-oblogproxy-ce: + runs-on: ubuntu-latest + steps: + - name: Free disk space on Ubuntu runner + uses: kfir4444/free-disk-space@main + with: + tool-cache: false + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + + - name: Print environment variables + run: printenv + + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build oblogproxy-ce image + uses: docker/build-push-action@v6 + with: + context: ./oblogproxy-ce + platforms: linux/amd64 + file: ./oblogproxy-ce/Dockerfile + push: false + load: true + tags: oblogproxy-ce + + - name: Export Docker image + run: docker save -o ${{ inputs.image_file }} oceanbase-ce + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.cache_key }} + path: ${{ inputs.image_file }} diff --git a/.github/workflows/build-oceanbase-ce.yml b/.github/workflows/reusable/build-oceanbase-ce-image.yml similarity index 100% rename from .github/workflows/build-oceanbase-ce.yml rename to .github/workflows/reusable/build-oceanbase-ce-image.yml diff --git a/.github/workflows/java-test-oceanbase-ce.yml b/.github/workflows/reusable/test-oceanbase-ce-container.yml similarity index 98% rename from .github/workflows/java-test-oceanbase-ce.yml rename to .github/workflows/reusable/test-oceanbase-ce-container.yml index c5202fe..473c480 100644 --- a/.github/workflows/java-test-oceanbase-ce.yml +++ b/.github/workflows/reusable/test-oceanbase-ce-container.yml @@ -1,4 +1,4 @@ -name: java test oceanbase-ce +name: test oceanbase-ce container on: workflow_call: diff --git a/.github/workflows/test-oblogproxy-ce.yml b/.github/workflows/test-oblogproxy-ce.yml index fb458ff..501447f 100644 --- a/.github/workflows/test-oblogproxy-ce.yml +++ b/.github/workflows/test-oblogproxy-ce.yml @@ -3,13 +3,10 @@ name: test oblogproxy-ce on: pull_request: paths: - - '.github/workflows/**-oblogproxy-ce.yml' - - '.github/workflows/build-oceanbase-ce.yml' - - 'oblogproxy-ce/Dockerfile' - - 'oblogproxy-ce/**.sh' - - 'oceanbase-ce/Dockerfile' - - 'oceanbase-ce/**.sh' - - 'oceanbase-ce/**.yaml' + - '.github/workflows/reusable/build-oceanbase-ce-image.yml' + - '.github/workflows/reusable/build-oblogproxy-ce-image.yml' + - '.github/workflows/test-oblogproxy-ce.yml' + - 'oblogproxy-ce/**' - 'test/**/LogProxyCETest.java' concurrency: @@ -18,7 +15,7 @@ concurrency: jobs: build-oceanbase-ce: - uses: ./.github/workflows/build-oceanbase-ce.yml + uses: ./.github/workflows/reusable/build-oceanbase-ce-image.yml with: cache_key: test-oblogproxy-ce_oceanbase-ce image_file: oceanbase-ce.tar @@ -26,40 +23,10 @@ jobs: build-oblogproxy-ce: runs-on: ubuntu-latest - steps: - - name: Clean tool cache - run: sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - - name: Print environment variables - run: printenv - - - name: Check out repository code - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build oblogproxy-ce image - uses: docker/build-push-action@v6 - with: - context: ./oblogproxy-ce - platforms: linux/amd64 - file: ./oblogproxy-ce/Dockerfile - push: false - load: true - tags: oblogproxy-ce - - - name: Export Docker image - run: docker save -o oblogproxy-ce.tar oblogproxy-ce - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: test-oblogproxy-ce_oblogproxy-ce - path: oblogproxy-ce.tar + uses: ./.github/workflows/reusable/build-oblogproxy-ce-image.yml + with: + cache_key: test-oblogproxy-ce_oblogproxy-ce + image_file: oblogproxy-ce.tar test-oblogproxy-ce: runs-on: ubuntu-latest diff --git a/.github/workflows/test-oceanbase-ce.yml b/.github/workflows/test-oceanbase-ce.yml index 42bae9c..2caeb07 100644 --- a/.github/workflows/test-oceanbase-ce.yml +++ b/.github/workflows/test-oceanbase-ce.yml @@ -3,10 +3,10 @@ name: test oceanbase-ce on: pull_request: paths: - - '.github/workflows/**-oceanbase-ce.yml' - - 'oceanbase-ce/Dockerfile' - - 'oceanbase-ce/**.sh' - - 'oceanbase-ce/**.yaml' + - '.github/workflows/reusable/build-oceanbase-ce-image.yml' + - '.github/workflows/reusable/test-oceanbase-ce-container.yml' + - '.github/workflows/test-oceanbase-ce.yml' + - 'oceanbase-ce/**' - 'test/**/OceanBaseCETest.java' concurrency: @@ -15,7 +15,7 @@ concurrency: jobs: build: - uses: ./.github/workflows/build-oceanbase-ce.yml + uses: ./.github/workflows/reusable/build-oceanbase-ce-image.yml with: cache_key: test-oceanbase-ce image_file: oceanbase-ce.tar @@ -23,7 +23,7 @@ jobs: test-slim: needs: build - uses: ./.github/workflows/java-test-oceanbase-ce.yml + uses: ./.github/workflows/reusable/test-oceanbase-ce-container.yml with: cache_key: test-oceanbase-ce image_file: oceanbase-ce.tar @@ -36,7 +36,7 @@ jobs: test-mini: needs: build - uses: ./.github/workflows/java-test-oceanbase-ce.yml + uses: ./.github/workflows/reusable/test-oceanbase-ce-container.yml with: cache_key: test-oceanbase-ce image_file: oceanbase-ce.tar