Skip to content

Commit

Permalink
modify workflows structure
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Aug 21, 2024
1 parent 1e8e0d3 commit c679250
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 100 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/reusable-build-and-test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: test and release oceanbase-ce image

on:
workflow_call:
inputs:
cache_key:
required: true
type: string
image_name:
required: true
type: string
version:
required: true
type: string

jobs:
build:
uses: ./.github/workflows/reusable-build-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
version: ${{ inputs.version }}

test-slim:
needs: build
uses: ./.github/workflows/reusable-test-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
image_file: ${{ inputs.image_name }}-amd64.tar
mode: slim
port: 1234
test_password: 123456
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"

test-mini:
needs: build
uses: ./.github/workflows/reusable-test-oceanbase-ce.yml
with:
cache_key: ${{ inputs.cache_key }}
image_name: ${{ inputs.image_name }}
image_file: ${{ inputs.image_name }}-amd64.tar
cluster_name: github-action
mode: mini
port: 1234
sys_password: 1234567
test_tenant: mini
test_password: 7654321
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"
56 changes: 56 additions & 0 deletions .github/workflows/reusable-build-oblogproxy-ce.yml
Original file line number Diff line number Diff line change
@@ -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 }} oblogproxy-ce

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cache_key }}
path: ${{ inputs.image_file }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
cache_key:
required: true
type: string
image_file:
image_name:
required: true
type: string
version:
required: true
type: string

jobs:
build-oceanbase-ce:
build-oceanbase-ce-image:
runs-on: ubuntu-latest
steps:
- name: Free disk space on Ubuntu runner
Expand Down Expand Up @@ -57,22 +57,13 @@ jobs:
docker run -v ./oceanbase-ce/share:/root/share oceanbase-ce-pre
- name: Build observer image
uses: docker/build-push-action@v6
with:
context: ./oceanbase-ce
platforms: linux/amd64
file: ./oceanbase-ce/Dockerfile
push: false
load: true
tags: oceanbase-ce
build-args: |
VERSION=${{ inputs.version }}
- name: Export Docker image
run: docker save -o ${{ inputs.image_file }} oceanbase-ce
run: |
cd oceanbase-ce
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/amd64 -t ${{ inputs.image_name }}:${{ inputs.version }} --load --output type=docker,dest=./${{ inputs.image_name }}-amd64.tar .
docker buildx build --build-arg VERSION=${{ inputs.version }} --platform linux/arm64 -t ${{ inputs.image_name }}:${{ inputs.version }} --load --output type=docker,dest=./${{ inputs.image_name }}-arm64.tar .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cache_key }}
path: ${{ inputs.image_file }}
path: ${{ inputs.image_name }}-**.tar
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: java test oceanbase-ce
name: test oceanbase-ce container

on:
workflow_call:
inputs:
cache_key:
required: true
type: string
image_name:
required: true
type: string
image_file:
required: true
type: string
Expand Down Expand Up @@ -37,7 +40,7 @@ on:
default: ''

jobs:
test-oceanbase-ce:
test-oceanbase-ce-container:
runs-on: ubuntu-latest
steps:
- name: Free disk space on Ubuntu runner
Expand All @@ -62,7 +65,7 @@ jobs:
- name: Start Docker container
uses: oceanbase/setup-oceanbase-ce@v1
with:
image_name: oceanbase-ce
image_name: ${{ inputs.image_name }}
container_name: oceanbase-ce
mode: ${{ inputs.mode }}
cluster_name: ${{ inputs.cluster_name }}
Expand Down
55 changes: 10 additions & 45 deletions .github/workflows/test-oblogproxy-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ 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/*oblogproxy-ce*.yml'
- 'oblogproxy-ce/**'
- 'test/**/LogProxyCETest.java'

concurrency:
Expand All @@ -18,48 +14,17 @@ concurrency:

jobs:
build-oceanbase-ce:
uses: ./.github/workflows/build-oceanbase-ce.yml
uses: ./.github/workflows/reusable-build-oceanbase-ce.yml
with:
cache_key: test-oblogproxy-ce_oceanbase-ce
image_file: oceanbase-ce.tar
image_name: oceanbase-ce
version: 4.2.1.8-108000022024072217

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.yml
with:
cache_key: test-oblogproxy-ce_oblogproxy-ce
image_file: oblogproxy-ce.tar

test-oblogproxy-ce:
runs-on: ubuntu-latest
Expand All @@ -76,7 +41,7 @@ jobs:

- name: Load Docker image
run: |
docker load -i /tmp/test-oblogproxy-ce_oceanbase-ce/oceanbase-ce.tar
docker load -i /tmp/test-oblogproxy-ce_oceanbase-ce/oceanbase-ce-amd64.tar
docker load -i /tmp/test-oblogproxy-ce_oblogproxy-ce/oblogproxy-ce.tar
sudo rm -rf /tmp/*
Expand Down
41 changes: 5 additions & 36 deletions .github/workflows/test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,18 @@ name: test oceanbase-ce
on:
pull_request:
paths:
- '.github/workflows/**-oceanbase-ce.yml'
- 'oceanbase-ce/Dockerfile'
- 'oceanbase-ce/**.sh'
- 'oceanbase-ce/**.yaml'
- '.github/workflows/*oceanbase-ce*.yml'
- 'oceanbase-ce/**'
- 'test/**/OceanBaseCETest.java'

concurrency:
group: test-oceanbase-ce-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/build-oceanbase-ce.yml
build-and-test:
uses: ./.github/workflows/reusable-build-and-test-oceanbase-ce.yml
with:
cache_key: test-oceanbase-ce
image_file: oceanbase-ce.tar
image_name: oceanbase-ce
version: 4.3.2.0-100000092024072912

test-slim:
needs: build
uses: ./.github/workflows/java-test-oceanbase-ce.yml
with:
cache_key: test-oceanbase-ce
image_file: oceanbase-ce.tar
mode: slim
port: 1234
test_password: 123456
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"

test-mini:
needs: build
uses: ./.github/workflows/java-test-oceanbase-ce.yml
with:
cache_key: test-oceanbase-ce
image_file: oceanbase-ce.tar
cluster_name: github-action
mode: mini
port: 1234
sys_password: 1234567
test_tenant: mini
test_password: 7654321
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"

0 comments on commit c679250

Please sign in to comment.