diff --git a/.github/workflows/basic-ci.yml b/.github/workflows/basic-ci.yml new file mode 100644 index 0000000..b65ef1d --- /dev/null +++ b/.github/workflows/basic-ci.yml @@ -0,0 +1,55 @@ +name: Basic CI + +on: + workflow_call: + inputs: + module: + type: string + required: true + description: 'The name of sample project.' + language: + type: string + required: true + description: 'The programming language used by the sample project.' + with_oceanbase_container: + type: boolean + required: false + description: 'Whether to use a pre-deployed OceanBase container in CI workflow.' + default: true + +concurrency: + group: basic-ci-${{ github.event.pull_request.number || github.ref }}-${{ inputs.module }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Set Go env + if: ${{ inputs.language == 'golang' }} + uses: actions/setup-go@v4 + with: + go-version: '1.20' + - name: Setup Java env + if: ${{ inputs.language == 'java' }} + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'zulu' + cache: 'maven' + - name: Setup Python env + if: ${{ inputs.language == 'python' }} + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Start OceanBase container + if: ${{ inputs.with_oceanbase_container }} + uses: oceanbase/setup-oceanbase-ce@v1.0 + with: + network: 'host' + - name: Run sample for ${{ inputs.module }} + run: | + cd ${{ inputs.language }}/${{ inputs.module }} + sh run.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d256933..1079da3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,66 +10,26 @@ on: - 'docs/**' - '**.md' - '.*' -concurrency: - group: ${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true jobs: - golang: - runs-on: ubuntu-latest + basic: strategy: matrix: - module: [ "go-sql-driver" ] - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Set Go env - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - name: Start docker container - uses: oceanbase/setup-oceanbase-ce@v1.0 - - name: Run example for ${{ matrix.module }} - run: | - cd golang/${{ matrix.module }} - sh run.sh - - java: - runs-on: ubuntu-latest - strategy: - matrix: - module: [ "mysql-connector-java", "oceanbase-client" ] - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Set JDK - uses: actions/setup-java@v4 - with: - java-version: '8' - distribution: 'zulu' - cache: 'maven' - - name: Start docker container - uses: oceanbase/setup-oceanbase-ce@v1.0 - - name: Run example for ${{ matrix.module }} - run: | - cd java/${{ matrix.module }} - sh run.sh - - python: - runs-on: ubuntu-latest - strategy: - matrix: - module: [ "pymysql" ] - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - name: Start docker container - uses: oceanbase/setup-oceanbase-ce@v1.0 - - name: Run example for ${{ matrix.module }} - run: | - cd python/${{ matrix.module }} - sh run.sh + module: + - name: 'go-sql-driver' + language: 'golang' + with_oceanbase_container: true + - name: 'mysql-connector-java' + language: 'java' + with_oceanbase_container: true + - name: 'oceanbase-client' + language: 'java' + with_oceanbase_container: true + - name: 'pymysql' + language: 'python' + with_oceanbase_container: true + uses: ./.github/workflows/basic-ci.yml + with: + module: ${{ matrix.module.name }} + language: ${{ matrix.module.language }} + with_oceanbase_container: ${{ matrix.module.with_oceanbase_container }}