Skip to content

Commit

Permalink
build(ci): split ci jobs to different workflow (oceanbase#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe authored May 30, 2024
1 parent 243e0fa commit 7433ff6
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 133 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Application CI

on:
push:
paths:
- '.github/workflows/application.yml'
- 'applications/**'
pull_request:
paths:
- '.github/workflows/application.yml'
- 'applications/**'

jobs:
hertzbeat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Java Env
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
cache: 'maven'
- name: Start OceanBase container
uses: oceanbase/setup-oceanbase-ce@v1
with:
network: 'host'
- name: Build and Test
run: |
cd applications/hertzbeat
mvn clean test
sveltekit:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Node.js env
uses: actions/setup-node@v4
with:
node-version: 21
cache: 'npm'
cache-dependency-path: applications/sveltekit
- uses: pnpm/action-setup@v4
name: Setup pnpm
with:
version: 8
run_install: false
- name: Build and run sample
run: |
cd applications/sveltekit
pnpm install
mydata:
runs-on: ubuntu-latest
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: Build and run sample
run: |
cd applications/mydata
make && ./dist/mydata exp -h
2 changes: 1 addition & 1 deletion .github/workflows/basic-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ jobs:
network: 'host'
- name: Run sample for ${{ inputs.module }}
run: |
cd ${{ inputs.language }}/${{ inputs.module }}
cd ${{ inputs.language }}/${{ inputs.module }} || exit
sh run.sh
122 changes: 0 additions & 122 deletions .github/workflows/ci.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Golang CI

on:
push:
paths:
- '.github/workflows/golang.yml'
- 'golang/**'
pull_request:
paths:
- '.github/workflows/golang.yml'
- 'golang/**'

jobs:
ci:
strategy:
matrix:
module:
- name: 'go-sql-driver'
with_oceanbase_container: true
- name: 'gorm'
with_oceanbase_container: true
uses: ./.github/workflows/basic-workflow.yml
with:
language: 'golang'
module: ${{ matrix.module.name }}
with_oceanbase_container: ${{ matrix.module.with_oceanbase_container }}
36 changes: 36 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Java CI

on:
push:
paths:
- '.github/workflows/java.yml'
- 'java/**'
pull_request:
paths:
- '.github/workflows/java.yml'
- 'java/**'

jobs:
ci:
strategy:
matrix:
module:
- name: 'mybatis'
with_oceanbase_container: true
- name: 'mybatis-plus'
with_oceanbase_container: false
- name: 'mysql-connector-java'
with_oceanbase_container: true
- name: 'oceanbase-client'
with_oceanbase_container: true
- name: 'spring-jdbc'
with_oceanbase_container: true
- name: 'springboot'
with_oceanbase_container: true
- name: 'testcontainers-java'
with_oceanbase_container: false
uses: ./.github/workflows/basic-workflow.yml
with:
language: 'java'
module: ${{ matrix.module.name }}
with_oceanbase_container: ${{ matrix.module.with_oceanbase_container }}
28 changes: 28 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Python CI

on:
push:
paths:
- '.github/workflows/python.yml'
- 'python/**'
pull_request:
paths:
- '.github/workflows/python.yml'
- 'python/**'

jobs:
ci:
strategy:
matrix:
module:
- name: 'mysql-connector-python'
with_oceanbase_container: true
- name: 'pymysql'
with_oceanbase_container: true
- name: 'sqlalchemy'
with_oceanbase_container: true
uses: ./.github/workflows/basic-workflow.yml
with:
language: 'python'
module: ${{ matrix.module.name }}
with_oceanbase_container: ${{ matrix.module.with_oceanbase_container }}
28 changes: 28 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ruby CI

on:
push:
paths:
- '.github/workflows/ruby.yml'
- 'ruby/**'
pull_request:
paths:
- '.github/workflows/ruby.yml'
- 'ruby/**'

jobs:
ci:
strategy:
matrix:
module:
- name: 'activerecord'
with_oceanbase_container: true
- name: 'mysql2'
with_oceanbase_container: true
- name: 'sequel'
with_oceanbase_container: true
uses: ./.github/workflows/basic-workflow.yml
with:
language: 'ruby'
module: ${{ matrix.module.name }}
with_oceanbase_container: ${{ matrix.module.with_oceanbase_container }}
11 changes: 6 additions & 5 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

如下是本仓库已经添加或计划在近期添加的示例:

- application
- `hertzbeat` `sveltekit`
- applications
- `hertzbeat` `mydata` `sveltekit`
- TODO: `seatunnel`
- c
- TODO: `obconnector-c`
Expand All @@ -40,6 +40,8 @@
- python
- `mysql-connector-python` `pymysql` `sqlalchemy`
- TODO: `mysqlclient`
- ruby
- `activerecord` `mysql2` `sequel`
- rust
- TODO: `sqlx` `rust-mysql-simple` `obkv-table-client-rust`

Expand All @@ -59,15 +61,14 @@

如果您不能提供英文的文档,您可以在文档中使用您的母语,我们会在之后对其进行改进。

为了确保示例能够在 GitHub Action 中运行,您的模块添加到 GitHub CI 工作流程。本项目对简单示例提供了一套标准化的运行流程,详情请参阅 [basic-workflow.yml](./.github/workflows/basic-workflow.yml)您只需要添加以下内容,将您贡献的模块增加到 [ci.yml](./.github/workflows/ci.yml) 中的 basic job 中即可:
为了确保示例能够在 GitHub Action 中运行,您的模块添加到 GitHub CI 工作流程。本项目对简单示例提供了一套标准化的运行流程,详情请参阅 [basic-workflow.yml](./.github/workflows/basic-workflow.yml)您只需要添加以下内容到 [.github/workflows](./.github/workflows) 目录下对应语言的 yml 中即可:

- `module.name`:新模块的名称,应与模块目录名称相同。
- `module.language`:编程语言,应与项目根目录下的目录名称相同。
- `module.with_oceanbase_container`:是否使用预先部署的 OceanBase 容器,可选,默认设置为 true。如果它是 true,您可以在 localhost 上使用用户名 `root@sys``root@test` 以及空密码连接到它。

#### 复杂示例

对于需要放到 applications 目录下的复杂示例,其目录内同样需要包含 `README.md` 文档,除此之外,其项目文件、ci 流程等由贡献者自行判断添加
对于需要放到 applications 目录下的复杂示例,其目录内同样需要包含项目文件和 `README.md` 文档,除此之外,您需要添加 ci 流程到 [application.yml](./.github/workflows/application.yml)

## 参考信息

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ We have created some issues on GitHub for some samples which are simple and good

The following are samples that have been added or planned to be added in the near future:

- application
- `hertzbeat` `sveltekit`
- applications
- `hertzbeat` `mydata` `sveltekit`
- TODO: `seatunnel`
- c
- TODO: `obconnector-c`
Expand All @@ -40,6 +40,8 @@ The following are samples that have been added or planned to be added in the nea
- python
- `mysql-connector-python` `pymysql` `sqlalchemy`
- TODO: `mysqlclient`
- ruby
- `activerecord` `mysql2` `sequel`
- rust
- TODO: `sqlx` `rust-mysql-simple` `obkv-table-client-rust`

Expand All @@ -59,15 +61,14 @@ For a simple sample under the programming language category, the directory shoul

If it's hard to use English for you, you can use your native language in the documentation, and we can improve it later.

To ensure that the sample works, please add your module to the GitHub CI workflow. This project provides a standardized workflow for simple samples. For details, please refer to [basic-workflow.yml](./.github/workflows/basic-workflow.yml). You only need to add the following options to add your module to the `basic` job in [ci.yml](./.github/workflows/ci.yml):
To ensure that the sample works, please add your module to the GitHub CI workflow. This project provides a standardized workflow for simple samples. For details, please refer to [basic-workflow.yml](./.github/workflows/basic-workflow.yml). You only need to add the following options to the yml of the corresponding language in the [.github/workflows](./.github/workflows) directory:

- `module.name`: the name of new module, should be same with the module directory name.
- `module.language`: the programming language, should be same with the directory name under project root.
- `module.with_oceanbase_container`: whether to use a pre-deployed OceanBase container, optional, set 'true' by default. If it's 'true', you can connect to it using username 'root@sys' or 'root@test' with empty password at localhost.

#### Complex samples

For complex samples that need to be placed in the applications directory, the directory also needs to contain the `README.md` document. In addition, its project files, ci workflow, etc. will be added by yourself.
For complex samples that need to be placed in the applications directory, the directory also needs to contain project files and `README.md` document. In addition, you also need to add ci workflow to [application.yml](./.github/workflows/application.yml).

## References

Expand Down

0 comments on commit 7433ff6

Please sign in to comment.