Skip to content

Commit

Permalink
build(ci): add reusable workflow for basic ci (#31)
Browse files Browse the repository at this point in the history
* build(ci): add reusable workflow for basic ci

* modify group

* modify job name
  • Loading branch information
whhe authored Apr 19, 2024
1 parent 4c16f59 commit a82e43a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 59 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/basic-ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
network: 'host'
- name: Run sample for ${{ inputs.module }}
run: |
cd ${{ inputs.language }}/${{ inputs.module }}
sh run.sh
78 changes: 19 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- 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/[email protected]
- 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/[email protected]
- 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 }}

0 comments on commit a82e43a

Please sign in to comment.