From 65f363d32e7cad6701ba596254dcbbbb63b38ce8 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 00:43:19 +0800 Subject: [PATCH 01/37] Try workflow call Signed-off-by: Xuanwo --- .github/workflows/service_test_fs.yml | 27 ++++++------ .github/workflows/test.yml | 61 +++++++++++++++++++++++++++ scripts/workflow_planner.py | 31 ++++++++++++++ 3 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100755 scripts/workflow_planner.py diff --git a/.github/workflows/service_test_fs.yml b/.github/workflows/service_test_fs.yml index c06b9e81d02b..bcb22643f329 100644 --- a/.github/workflows/service_test_fs.yml +++ b/.github/workflows/service_test_fs.yml @@ -18,19 +18,20 @@ name: Service Test Fs on: - push: - branches: - - main - pull_request: - branches: - - main - paths: - - "core/src/**" - - "core/tests/**" - - "!core/src/docs/**" - - "!core/src/services/**" - - "core/src/services/fs/**" - - ".github/workflows/service_test_fs.yml" +# push: +# branches: +# - main +# pull_request: +# branches: +# - main +# paths: +# - "core/src/**" +# - "core/tests/**" +# - "!core/src/docs/**" +# - "!core/src/services/**" +# - "core/src/services/fs/**" +# - ".github/workflows/service_test_fs.yml" + workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..e2f630ae4744 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,61 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + plan: + runs-on: ubuntu-latest + outputs: + plan: ${{ steps.get-changes.outputs.plan }} + + steps: + - uses: actions/checkout@v4 + with: + # fetch depth set to 0 to make sure we have correct diff result. + fetch-depth: 0 + + - name: Get Changes + id: get-changes # ID is set so we can reference outputs in this step + run: | + git fetch origin main:main + FILES_CHANGED=$(git diff --name-only main ${{ github.event.pull_request.head.sha }}) + echo "Files changed:" + echo "$FILES_CHANGED" + + PLAN=$(./scripts/workflow_planner.py $FILES_CHANGED) + echo "Plan:" + echo "$PLAN" + + echo "::set-output name=plan::$PLAN" + + fs: + needs: [plan] + if: fromJson(needs.plan.outputs.plan).fs + uses: ./.github/workflows/service_test_fs.yml diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py new file mode 100755 index 000000000000..1c94e0020b23 --- /dev/null +++ b/scripts/workflow_planner.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import sys +import json + +def plan(changed_files): + jobs = { + "fs": True + } + return json.dumps(jobs) + +if __name__ == '__main__': + changed_files = sys.argv[1:] + result = plan(changed_files) + print(result) From 68feacf9d6abbfd190a7f5557703fdfa5e1deb4d Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 00:43:43 +0800 Subject: [PATCH 02/37] Add s3 as ignore example Signed-off-by: Xuanwo --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2f630ae4744..0ec9d783c7d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,3 +59,8 @@ jobs: needs: [plan] if: fromJson(needs.plan.outputs.plan).fs uses: ./.github/workflows/service_test_fs.yml + + s3: + needs: [plan] + if: fromJson(needs.plan.outputs.plan).s3 + uses: ./.github/workflows/service_test_s3.yml From a5212dcb5996459524775bd5253e46ffed9a26d3 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 00:47:24 +0800 Subject: [PATCH 03/37] Fix Signed-off-by: Xuanwo --- .github/workflows/service_test_s3.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/service_test_s3.yml b/.github/workflows/service_test_s3.yml index 9efd04f60aaf..996f0b4fa5a6 100644 --- a/.github/workflows/service_test_s3.yml +++ b/.github/workflows/service_test_s3.yml @@ -33,6 +33,7 @@ on: - "bindings/java/**" - ".github/workflows/service_test_s3.yml" - "fixtures/s3/**" + workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} From 825fa88a51cc5f23ddf1d766ab862ae07b5a5db6 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 00:55:20 +0800 Subject: [PATCH 04/37] Remove concurrency Signed-off-by: Xuanwo --- .github/workflows/service_test_fs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/service_test_fs.yml b/.github/workflows/service_test_fs.yml index bcb22643f329..79119833399f 100644 --- a/.github/workflows/service_test_fs.yml +++ b/.github/workflows/service_test_fs.yml @@ -33,9 +33,9 @@ on: # - ".github/workflows/service_test_fs.yml" workflow_call: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} - cancel-in-progress: true +#concurrency: +# group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} +# cancel-in-progress: true jobs: local_fs: From 6ab5ce1b4cce48573ff1d6beb6cdb73690b216d2 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 00:57:34 +0800 Subject: [PATCH 05/37] Use output file Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ec9d783c7d0..a2b1f9d5f93b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,7 @@ jobs: echo "Plan:" echo "$PLAN" - echo "::set-output name=plan::$PLAN" + echo "plan=$PLAN" >> $GITHUB_OUTPUT fs: needs: [plan] From d3aa46209603ac0352e0a26af90d63674c573279 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:19:28 +0800 Subject: [PATCH 06/37] Let's go Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 46 ++++++++++++++++++++++++ .github/services/fs/local-fs/action.yaml | 28 +++++++++++++++ .github/workflows/test.yml | 17 +++++---- .github/workflows/test_core.yml | 41 +++++++++++++++++++++ scripts/workflow_planner.py | 19 +++++++++- 5 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 .github/actions/test-core/action.yaml create mode 100644 .github/services/fs/local-fs/action.yaml create mode 100644 .github/workflows/test_core.yml diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml new file mode 100644 index 000000000000..2a2cbc4fb352 --- /dev/null +++ b/.github/actions/test-core/action.yaml @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Test Core +description: 'Test Core with given setup and service' +inputs: + setup: + description: "The setup action for test" + service: + description: "The service to test" + +runs: + using: "composite" + steps: + - name: Setup + shell: bash + run: | + mkdir -p ./dynamic_test_core && + cat <./dynamic_test_core/action.yml + runs: + using: composite + steps: + - name: Setup Test Core + uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} + - name: Run Test Core + shell: bash + working-directory: core + run: cargo test services_${{ inputs.service }} + EOF + - name: Run + id: run + uses: ./dynamic_test_core diff --git a/.github/services/fs/local-fs/action.yaml b/.github/services/fs/local-fs/action.yaml new file mode 100644 index 000000000000..4175de1eb822 --- /dev/null +++ b/.github/services/fs/local-fs/action.yaml @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: local_fs +description: "Setup local fs" + +runs: + using: "composite" + steps: + - name: Setup + shell: bash + run: | + echo "OPENDAL_FS_TEST=on" >> $GITHUB_ENV + echo "OPENDAL_FS_ROOT=${{ runner.temp }}/" >> $GITHUB_ENV diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a2b1f9d5f93b..42e9a36f8c68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,12 +55,15 @@ jobs: echo "plan=$PLAN" >> $GITHUB_OUTPUT - fs: - needs: [plan] - if: fromJson(needs.plan.outputs.plan).fs - uses: ./.github/workflows/service_test_fs.yml +# build_core: +# needs: [plan] +# if: fromJson(needs.plan.outputs.plan).components.core +# uses: ./.github/workflows/service_test_fs.yml - s3: + test_core: needs: [plan] - if: fromJson(needs.plan.outputs.plan).s3 - uses: ./.github/workflows/service_test_s3.yml + if: fromJson(needs.plan.outputs.plan).components.core + secrets: inherit + uses: ./.github/workflows/test_core.yml + with: + plan: needs.plan.outputs.plan diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml new file mode 100644 index 000000000000..dc1d51885366 --- /dev/null +++ b/.github/workflows/test_core.yml @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Test Core + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +jobs: + test_core: + runs-on: ${{ matrix.cases.os }} + strategy: + matrix: + cases: ${{ fromJson(inputs.plan).cases }} + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: ./.github/actions/setup + - name: Test Core + uses: ./.github/actions/test_core + with: + setup: ${{ matrix.cases.setup }} + service: ${{ matrix.cases.service }} diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 1c94e0020b23..4db742767080 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -21,7 +21,24 @@ def plan(changed_files): jobs = { - "fs": True + "components": { + "core": True + }, + "services": { + "fs": True, + }, + "cases": [ + { + "os": "ubuntu-latest", + "setup": "local-fs", + "service": "fs" + }, + { + "os": "windows-latest", + "setup": "local-fs", + "service": "fs" + } + ] } return json.dumps(jobs) From 66d71db39cae8dfe8808689c0b8401e08ce16746 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:24:24 +0800 Subject: [PATCH 07/37] wrap Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42e9a36f8c68..99489c7e2b93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,4 +66,4 @@ jobs: secrets: inherit uses: ./.github/workflows/test_core.yml with: - plan: needs.plan.outputs.plan + plan: ${{ needs.plan.outputs.plan }} From 7ae4245f729e0b2d0b47c350caa26c59a5a0a93e Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:26:01 +0800 Subject: [PATCH 08/37] Fix typo Signed-off-by: Xuanwo --- .github/workflows/test_core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index dc1d51885366..e480d37a1b91 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -35,7 +35,7 @@ jobs: - name: Setup Rust toolchain uses: ./.github/actions/setup - name: Test Core - uses: ./.github/actions/test_core + uses: ./.github/actions/test-core with: setup: ${{ matrix.cases.setup }} service: ${{ matrix.cases.service }} From 42e86d2a598dda4628e54f2362fe734a2b5430ec Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:34:52 +0800 Subject: [PATCH 09/37] test Signed-off-by: Xuanwo --- .github/workflows/service_test_s3.yml | 30 +++++++++++++-------------- .github/workflows/test_core.yml | 5 +++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/service_test_s3.yml b/.github/workflows/service_test_s3.yml index 996f0b4fa5a6..efc82da64ccc 100644 --- a/.github/workflows/service_test_s3.yml +++ b/.github/workflows/service_test_s3.yml @@ -18,21 +18,21 @@ name: Service Test S3 on: - push: - branches: - - main - pull_request: - branches: - - main - paths: - - "core/src/**" - - "core/tests/**" - - "!core/src/docs/**" - - "!core/src/services/**" - - "core/src/services/s3/**" - - "bindings/java/**" - - ".github/workflows/service_test_s3.yml" - - "fixtures/s3/**" +# push: +# branches: +# - main +# pull_request: +# branches: +# - main +# paths: +# - "core/src/**" +# - "core/tests/**" +# - "!core/src/docs/**" +# - "!core/src/services/**" +# - "core/src/services/s3/**" +# - "bindings/java/**" +# - ".github/workflows/service_test_s3.yml" +# - "fixtures/s3/**" workflow_call: concurrency: diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index e480d37a1b91..59f6a0e5b34e 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -name: Test Core +name: Core on: workflow_call: @@ -25,7 +25,8 @@ on: type: string jobs: - test_core: + core: + name: ${{ matrix.cases.service }} on ${{ matrix.cases.setup }} runs-on: ${{ matrix.cases.os }} strategy: matrix: From 0134f32b3643b2105205d491b8df2831d0d68974 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:36:21 +0800 Subject: [PATCH 10/37] Polish naming Signed-off-by: Xuanwo --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99489c7e2b93..b5f72415db51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,6 +61,7 @@ jobs: # uses: ./.github/workflows/service_test_fs.yml test_core: + name: Core needs: [plan] if: fromJson(needs.plan.outputs.plan).components.core secrets: inherit From 7b3917e05950dbb12f61b70a4ac381f3d0eb545a Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:36:51 +0800 Subject: [PATCH 11/37] polish naming Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5f72415db51..8c66329ed233 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: # uses: ./.github/workflows/service_test_fs.yml test_core: - name: Core + name: core needs: [plan] if: fromJson(needs.plan.outputs.plan).components.core secrets: inherit From 00ed34e79d10c9b9ab85819802e7c6fb516ca6cf Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 10:38:35 +0800 Subject: [PATCH 12/37] Can we use / ? Signed-off-by: Xuanwo --- .github/workflows/test_core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index 59f6a0e5b34e..8c69a5655c2a 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -26,7 +26,7 @@ on: jobs: core: - name: ${{ matrix.cases.service }} on ${{ matrix.cases.setup }} + name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} runs-on: ${{ matrix.cases.os }} strategy: matrix: From 3501ac7d4bf5096eff2bcb1981089db06c5bb811 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 19:31:05 +0800 Subject: [PATCH 13/37] Try Signed-off-by: Xuanwo --- .github/actions/setup/action.yaml | 20 ++++--- .github/actions/test-core/action.yaml | 2 +- .github/workflows/core.build.yml | 57 +++++++++++++++++++ .../{test_core.yml => core.test.yml} | 10 ++++ .github/workflows/test.yml | 19 ++++--- scripts/workflow_planner.py | 5 ++ 6 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/core.build.yml rename .github/workflows/{test_core.yml => core.test.yml} (86%) diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 5c5dc5dc84c7..2adc5d67a2ca 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -49,24 +49,26 @@ runs: shell: bash run: sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev - - name: Setup protoc on linux - if: inputs.need-protoc == 'true' && runner.os == 'Linux' - shell: bash - run: sudo apt install -y protobuf-compiler + - name: Setup Protoc + if: inputs.need-protoc == 'true' + uses: arduino/setup-protoc@v2 + with: + version: "23.4" - name: Cache nextest on linux id: cache-nextest uses: actions/cache@v3 - if: inputs.need-nextest == 'true' && runner.os == 'Linux' + if: inputs.need-nextest == 'true' with: - path: ~/.cargo/bin/cargo-nextest - # TODO: remove the runner.os while bumping version - key: r0-${{runner.os}}-nextest-0.9.53 + path: | + ~/.cargo/bin/cargo-nextest + ~/.cargo/bin/cargo-nextest.exe + key: r0-${{runner.os}}-nextest-0.9.59 - name: Build nextest if not cached if: steps.cache-nextest.outputs.cache-hit != 'true' && inputs.need-nextest == 'true' shell: bash - run: cargo install cargo-nextest@0.9.53 --locked + run: cargo install cargo-nextest@0.9.59 --locked - name: Setup rust on linux if: runner.os == 'Linux' && inputs.need-rocksdb == 'true' diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index 2a2cbc4fb352..9ea1e0d5adee 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -39,7 +39,7 @@ runs: - name: Run Test Core shell: bash working-directory: core - run: cargo test services_${{ inputs.service }} + run: cargo nextest run services_${{ inputs.service }} --archive-file=./target/core-test.tar.zst EOF - name: Run id: run diff --git a/.github/workflows/core.build.yml b/.github/workflows/core.build.yml new file mode 100644 index 000000000000..983c599589e5 --- /dev/null +++ b/.github/workflows/core.build.yml @@ -0,0 +1,57 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +jobs: + build: + name: ${{ matrix.os }} + runs-on: ubuntu-latest + strategy: + matrix: + os: ${{ fromJson(inputs.plan).os }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: ./.github/actions/setup + with: + need-nextest: true + need-protoc: true + + # Required by hdfs + - name: Setup java env + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: "11" + + - name: Build + shell: bash + run: | + cargo nextest archive --all-features --archive-file ./target/core-test.tar.zst + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: core-test + path: ./target/core-test.tar.zst diff --git a/.github/workflows/test_core.yml b/.github/workflows/core.test.yml similarity index 86% rename from .github/workflows/test_core.yml rename to .github/workflows/core.test.yml index 8c69a5655c2a..c5230556274c 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/core.test.yml @@ -35,6 +35,16 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup + with: + need-nextest: true + need-protoc: true + + - name: Download + uses: actions/download-artifact@v2 + with: + name: core-test + path: ./target/core-test.tar.zst + - name: Test Core uses: ./.github/actions/test-core with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c66329ed233..b77fdd292dac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: fetch-depth: 0 - name: Get Changes - id: get-changes # ID is set so we can reference outputs in this step + id: get-changes run: | git fetch origin main:main FILES_CHANGED=$(git diff --name-only main ${{ github.event.pull_request.head.sha }}) @@ -55,16 +55,19 @@ jobs: echo "plan=$PLAN" >> $GITHUB_OUTPUT -# build_core: -# needs: [plan] -# if: fromJson(needs.plan.outputs.plan).components.core -# uses: ./.github/workflows/service_test_fs.yml + core_build: + name: core build + needs: [plan] + if: fromJson(needs.plan.outputs.plan).components.core + uses: ./.github/workflows/core.build.yml + with: + plan: ${{ needs.plan.outputs.plan }} - test_core: + core_test: name: core - needs: [plan] + needs: [plan, build_core] if: fromJson(needs.plan.outputs.plan).components.core secrets: inherit - uses: ./.github/workflows/test_core.yml + uses: ./.github/workflows/core.test.yml with: plan: ${{ needs.plan.outputs.plan }} diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 4db742767080..6dd4dea203f0 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -27,6 +27,11 @@ def plan(changed_files): "services": { "fs": True, }, + "features": "", + "os": [ + "ubuntu-latest", + "windows-latest" + ], "cases": [ { "os": "ubuntu-latest", From 81e551c713828f3dae2427da83cf900ac57db9e1 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 19:31:52 +0800 Subject: [PATCH 14/37] Fix Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b77fdd292dac..b12e677d59e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,7 +65,7 @@ jobs: core_test: name: core - needs: [plan, build_core] + needs: [plan, core_build] if: fromJson(needs.plan.outputs.plan).components.core secrets: inherit uses: ./.github/workflows/core.test.yml From 5635eb2048453d00deda43ad838f093d8cf9b716 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 19:54:07 +0800 Subject: [PATCH 15/37] Fix build Signed-off-by: Xuanwo --- .github/workflows/core.build.yml | 2 +- .github/workflows/core.test.yml | 1 + scripts/workflow_planner.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/core.build.yml b/.github/workflows/core.build.yml index 983c599589e5..d5b3525df9d8 100644 --- a/.github/workflows/core.build.yml +++ b/.github/workflows/core.build.yml @@ -48,7 +48,7 @@ jobs: - name: Build shell: bash run: | - cargo nextest archive --all-features --archive-file ./target/core-test.tar.zst + cargo nextest archive --features ${{ fromJson(inputs.plan).features }} --archive-file ./target/core-test.tar.zst - name: Upload uses: actions/upload-artifact@v2 diff --git a/.github/workflows/core.test.yml b/.github/workflows/core.test.yml index c5230556274c..599f64c0c929 100644 --- a/.github/workflows/core.test.yml +++ b/.github/workflows/core.test.yml @@ -38,6 +38,7 @@ jobs: with: need-nextest: true need-protoc: true + need-rocksdb: true - name: Download uses: actions/download-artifact@v2 diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 6dd4dea203f0..297af570e134 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -27,7 +27,7 @@ def plan(changed_files): "services": { "fs": True, }, - "features": "", + "features": "services-fs,services-s3", "os": [ "ubuntu-latest", "windows-latest" From bb88a0b08796507de00648c431821b018cf3f7b6 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 20:58:18 +0800 Subject: [PATCH 16/37] polish matrix Signed-off-by: Xuanwo --- .github/workflows/core.build.yml | 7 ++++--- scripts/workflow_planner.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/core.build.yml b/.github/workflows/core.build.yml index d5b3525df9d8..71398a8fcbfe 100644 --- a/.github/workflows/core.build.yml +++ b/.github/workflows/core.build.yml @@ -25,10 +25,10 @@ on: jobs: build: name: ${{ matrix.os }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: - os: ${{ fromJson(inputs.plan).os }} + include: ${{ fromJson(inputs.plan).matrix }} steps: - uses: actions/checkout@v4 @@ -37,6 +37,7 @@ jobs: with: need-nextest: true need-protoc: true + need-rocksdb: true # Required by hdfs - name: Setup java env @@ -48,7 +49,7 @@ jobs: - name: Build shell: bash run: | - cargo nextest archive --features ${{ fromJson(inputs.plan).features }} --archive-file ./target/core-test.tar.zst + cargo nextest archive --features ${{ matrix.features }} --archive-file ./target/core-test.tar.zst - name: Upload uses: actions/upload-artifact@v2 diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 297af570e134..3f6b74ce51e5 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -27,10 +27,15 @@ def plan(changed_files): "services": { "fs": True, }, - "features": "services-fs,services-s3", - "os": [ - "ubuntu-latest", - "windows-latest" + "matrix": [ + { + "os": "ubuntu-latest", + "features": "services-fs,services-s3", + }, + { + "os": "windows-latest", + "features": "services-fs,services-s3", + } ], "cases": [ { From 8975ebe96647ead0e26c89318b7ede74cc0b29cd Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 21:00:19 +0800 Subject: [PATCH 17/37] Fix not found Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index 9ea1e0d5adee..37da573b8a80 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -39,7 +39,7 @@ runs: - name: Run Test Core shell: bash working-directory: core - run: cargo nextest run services_${{ inputs.service }} --archive-file=./target/core-test.tar.zst + run: cargo nextest run services_${{ inputs.service }} --archive-file=../target/core-test.tar.zst EOF - name: Run id: run From 947000d24f16e6cc904f6304125299b222106c9d Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 21:17:39 +0800 Subject: [PATCH 18/37] Fix path Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index 37da573b8a80..62fe94a0866c 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -38,8 +38,7 @@ runs: uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} - name: Run Test Core shell: bash - working-directory: core - run: cargo nextest run services_${{ inputs.service }} --archive-file=../target/core-test.tar.zst + run: cargo nextest run services_${{ inputs.service }} --archive-file=./target/core-test.tar.zst EOF - name: Run id: run From 3444ed1af3d4b293142bfc81e3f67819d56b72d3 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 21:19:11 +0800 Subject: [PATCH 19/37] FIx path Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 3 ++- .github/workflows/core.build.yml | 5 +++-- .github/workflows/core.test.yml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index 62fe94a0866c..c3c8a6c473fd 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -38,7 +38,8 @@ runs: uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} - name: Run Test Core shell: bash - run: cargo nextest run services_${{ inputs.service }} --archive-file=./target/core-test.tar.zst + working-directory: core + run: cargo nextest run services_${{ inputs.service }} --archive-file=./core-test.tar.zst EOF - name: Run id: run diff --git a/.github/workflows/core.build.yml b/.github/workflows/core.build.yml index 71398a8fcbfe..0e19c984b066 100644 --- a/.github/workflows/core.build.yml +++ b/.github/workflows/core.build.yml @@ -48,11 +48,12 @@ jobs: - name: Build shell: bash + working-directory: core run: | - cargo nextest archive --features ${{ matrix.features }} --archive-file ./target/core-test.tar.zst + cargo nextest archive --features ${{ matrix.features }} --archive-file ./core-test.tar.zst - name: Upload uses: actions/upload-artifact@v2 with: name: core-test - path: ./target/core-test.tar.zst + path: ./core/core-test.tar.zst diff --git a/.github/workflows/core.test.yml b/.github/workflows/core.test.yml index 599f64c0c929..14d39663be3d 100644 --- a/.github/workflows/core.test.yml +++ b/.github/workflows/core.test.yml @@ -44,7 +44,7 @@ jobs: uses: actions/download-artifact@v2 with: name: core-test - path: ./target/core-test.tar.zst + path: ./core/core-test.tar.zst - name: Test Core uses: ./.github/actions/test-core From 7e91e3f8919275fff30f8d37b574dcfa48f2ae29 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 22:37:36 +0800 Subject: [PATCH 20/37] try Signed-off-by: Xuanwo --- .github/workflows/core.test.yml | 53 ------------------- .../{core.build.yml => core_test.yml} | 51 ++++++++++++++---- .github/workflows/test.yml | 18 +++---- scripts/workflow_planner.py | 22 ++++---- 4 files changed, 58 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/core.test.yml rename .github/workflows/{core.build.yml => core_test.yml} (57%) diff --git a/.github/workflows/core.test.yml b/.github/workflows/core.test.yml deleted file mode 100644 index 14d39663be3d..000000000000 --- a/.github/workflows/core.test.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Core - -on: - workflow_call: - inputs: - plan: - required: true - type: string - -jobs: - core: - name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} - runs-on: ${{ matrix.cases.os }} - strategy: - matrix: - cases: ${{ fromJson(inputs.plan).cases }} - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - need-protoc: true - need-rocksdb: true - - - name: Download - uses: actions/download-artifact@v2 - with: - name: core-test - path: ./core/core-test.tar.zst - - - name: Test Core - uses: ./.github/actions/test-core - with: - setup: ${{ matrix.cases.setup }} - service: ${{ matrix.cases.service }} diff --git a/.github/workflows/core.build.yml b/.github/workflows/core_test.yml similarity index 57% rename from .github/workflows/core.build.yml rename to .github/workflows/core_test.yml index 0e19c984b066..df04e405eeb4 100644 --- a/.github/workflows/core.build.yml +++ b/.github/workflows/core_test.yml @@ -15,20 +15,25 @@ # specific language governing permissions and limitations # under the License. +name: Core + on: workflow_call: inputs: - plan: + os: + required: true + type: string + cases: + required: true + type: string + features: required: true type: string jobs: build: - name: ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: ${{ fromJson(inputs.plan).matrix }} + name: ${{ inputs.os }} + runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v4 @@ -50,10 +55,38 @@ jobs: shell: bash working-directory: core run: | - cargo nextest archive --features ${{ matrix.features }} --archive-file ./core-test.tar.zst + cargo nextest archive --features ${{ inputs.features }} --archive-file ./core-test.tar.zst - name: Upload - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.os }}-core-test + path: ./core/${{ inputs.os }}-core-test.tar.zst + + core: + name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} + needs: [build] + runs-on: ${{ inputs.os }} + strategy: + matrix: + cases: ${{ fromJson(inputs.cases) }} + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: ./.github/actions/setup with: - name: core-test + need-nextest: true + need-protoc: true + need-rocksdb: true + + - name: Download + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.os }}-core-test path: ./core/core-test.tar.zst + + - name: Test Core + uses: ./.github/actions/test-core + with: + setup: ${{ matrix.cases.setup }} + service: ${{ matrix.cases.service }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b12e677d59e1..dcf504712a3a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,19 +55,15 @@ jobs: echo "plan=$PLAN" >> $GITHUB_OUTPUT - core_build: - name: core build - needs: [plan] - if: fromJson(needs.plan.outputs.plan).components.core - uses: ./.github/workflows/core.build.yml - with: - plan: ${{ needs.plan.outputs.plan }} - core_test: name: core - needs: [plan, core_build] + needs: [plan] if: fromJson(needs.plan.outputs.plan).components.core - secrets: inherit + strategy: + matrix: + include: ${{ fromJson(needs.plan.outputs.plan).core }} uses: ./.github/workflows/core.test.yml with: - plan: ${{ needs.plan.outputs.plan }} + os: ${{ matrix.os }} + cases: ${{ matrix.cases }} + features: ${{ matrix.features }} diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 3f6b74ce51e5..9f73131caffb 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -27,26 +27,22 @@ def plan(changed_files): "services": { "fs": True, }, - "matrix": [ + "core": [ { "os": "ubuntu-latest", "features": "services-fs,services-s3", + "cases": [{ + "setup": "local-fs", + "service": "fs" + }] }, { "os": "windows-latest", "features": "services-fs,services-s3", - } - ], - "cases": [ - { - "os": "ubuntu-latest", - "setup": "local-fs", - "service": "fs" - }, - { - "os": "windows-latest", - "setup": "local-fs", - "service": "fs" + "cases": [{ + "setup": "local-fs", + "service": "fs" + }] } ] } From 6b356afb2acb8aa408997af521ed57e1939af4b1 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 22:39:43 +0800 Subject: [PATCH 21/37] Fix typo Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dcf504712a3a..984361a5e549 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,7 +62,7 @@ jobs: strategy: matrix: include: ${{ fromJson(needs.plan.outputs.plan).core }} - uses: ./.github/workflows/core.test.yml + uses: ./.github/workflows/core_test.yml with: os: ${{ matrix.os }} cases: ${{ matrix.cases }} From 77bed37b59a52e72173666786278b3140688c63c Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 22:42:58 +0800 Subject: [PATCH 22/37] toJson Signed-off-by: Xuanwo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 984361a5e549..45ee1d4ad70d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,5 +65,5 @@ jobs: uses: ./.github/workflows/core_test.yml with: os: ${{ matrix.os }} - cases: ${{ matrix.cases }} + cases: ${{ toJson(matrix.cases) }} features: ${{ matrix.features }} From e23d13938758a4d041ac3c828ef9967c42f9eb92 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 22:51:57 +0800 Subject: [PATCH 23/37] Fix typo Signed-off-by: Xuanwo --- .github/workflows/core_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/core_test.yml b/.github/workflows/core_test.yml index df04e405eeb4..521fcf29a374 100644 --- a/.github/workflows/core_test.yml +++ b/.github/workflows/core_test.yml @@ -61,7 +61,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ inputs.os }}-core-test - path: ./core/${{ inputs.os }}-core-test.tar.zst + path: ./core/core-test.tar.zst core: name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} From 7ad8fcd47cc74c183b1e0cdf4db0e0948a3e796a Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 22:54:57 +0800 Subject: [PATCH 24/37] polish naming Signed-off-by: Xuanwo --- .github/workflows/core_test.yml | 1 - .github/workflows/test.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/core_test.yml b/.github/workflows/core_test.yml index 521fcf29a374..b72efcaf9df0 100644 --- a/.github/workflows/core_test.yml +++ b/.github/workflows/core_test.yml @@ -32,7 +32,6 @@ on: jobs: build: - name: ${{ inputs.os }} runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45ee1d4ad70d..fbe841de0f58 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,7 +56,7 @@ jobs: echo "plan=$PLAN" >> $GITHUB_OUTPUT core_test: - name: core + name: core / ${{ matrix.os }} needs: [plan] if: fromJson(needs.plan.outputs.plan).components.core strategy: From d1039aae875e616fcdf05fc3a81b172c1067b8cc Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 12 Oct 2023 23:04:09 +0800 Subject: [PATCH 25/37] FIx build Signed-off-by: Xuanwo --- .github/workflows/core_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/core_test.yml b/.github/workflows/core_test.yml index b72efcaf9df0..ed66bfe44f7b 100644 --- a/.github/workflows/core_test.yml +++ b/.github/workflows/core_test.yml @@ -82,7 +82,7 @@ jobs: uses: actions/download-artifact@v3 with: name: ${{ inputs.os }}-core-test - path: ./core/core-test.tar.zst + path: ./core - name: Test Core uses: ./.github/actions/test-core From afbb79d639582e983fe32ab4584075f9088f6f12 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 00:29:02 +0800 Subject: [PATCH 26/37] Auto detect task Signed-off-by: Xuanwo --- .../fs/local-fs/{action.yaml => action.yml} | 0 .github/workflows/core_test.yml | 3 +- .../workflows/{test.yml => test_planner.yml} | 4 +- scripts/workflow_planner.py | 118 ++++++++++++++---- 4 files changed, 100 insertions(+), 25 deletions(-) rename .github/services/fs/local-fs/{action.yaml => action.yml} (100%) rename .github/workflows/{test.yml => test_planner.yml} (94%) diff --git a/.github/services/fs/local-fs/action.yaml b/.github/services/fs/local-fs/action.yml similarity index 100% rename from .github/services/fs/local-fs/action.yaml rename to .github/services/fs/local-fs/action.yml diff --git a/.github/workflows/core_test.yml b/.github/workflows/core_test.yml index ed66bfe44f7b..5cda79c758ee 100644 --- a/.github/workflows/core_test.yml +++ b/.github/workflows/core_test.yml @@ -32,6 +32,7 @@ on: jobs: build: + name: build runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v4 @@ -62,7 +63,7 @@ jobs: name: ${{ inputs.os }}-core-test path: ./core/core-test.tar.zst - core: + test: name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} needs: [build] runs-on: ${{ inputs.os }} diff --git a/.github/workflows/test.yml b/.github/workflows/test_planner.yml similarity index 94% rename from .github/workflows/test.yml rename to .github/workflows/test_planner.yml index fbe841de0f58..dba36b8d3d20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test_planner.yml @@ -49,7 +49,9 @@ jobs: echo "Files changed:" echo "$FILES_CHANGED" - PLAN=$(./scripts/workflow_planner.py $FILES_CHANGED) + GITHUB_CONTEXT=${{ toJson(github) }} + + PLAN=$(./scripts/workflow_planner.py $GITHUB_CONTEXT $FILES_CHANGED) echo "Plan:" echo "$PLAN" diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 9f73131caffb..d0fb4df468fd 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -18,37 +18,109 @@ import sys import json +import os +from pathlib import Path -def plan(changed_files): - jobs = { - "components": { - "core": True - }, - "services": { - "fs": True, - }, - "core": [ + +# Check if we can access secrets based on github context. +def check_secrets(github): + if ( + github["event_name"] == "push" + and github["repository"] == "apache/incubator-opendal" + ): + return True + if ( + github["event_name"] == "pull_request" + and github["event"]["pull_request"]["head"]["full_name"] + == "apache/incubator-opendal" + and not github["event"]["pull_request"]["head"]["repo"]["fork"] + ): + return True + return False + + +def get_provided_cases(github): + root_dir = ".github/services" + + cases = [ + { + "service": service, + "setup": setup, + "content": Path( + os.path.join(root_dir, service, setup, "action.yml") + ).read_text(), + } + for service in os.listdir(root_dir) + for setup in os.listdir(os.path.join(root_dir, service)) + ] + + # Check if this workflow needs to read secrets. + # + # We will check if pattern `secrets.XXX` exist in content. + if not check_secrets(github): + cases[:] = [v for v in cases if "secrets." in v["content"]] + + return cases + + +def calculate_core_cases(cases, changed_files): + # If any of the core workflow changed, we will run all cases. + for p in [ + ".github/workflows/core_test.yml", + ".github/workflows/test_planner.yml", + ".github/actions/test-core", + ]: + if p in changed_files: + return cases + + # If any of the core files changed, we will run all cases. + if any( + p.startswith("core/src/") and not p.startswith("core/src/services") + for p in changed_files + ): + return cases + if any(p.startswith("core/tests/") for p in changed_files): + return cases + + # Filter all cases that not shown un in changed files + cases = [v for v in cases if any(v["service"] in p for p in changed_files)] + return cases + + +# Context is the github context: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context +def plan(github, changed_files): + # TODO: add bindings/java, bindings/python in the future. + components = ["core"] + cases = get_provided_cases(github) + + core_cases = calculate_core_cases(cases, changed_files) + + jobs = {} + + if len(core_cases)> 0: + jobs["components"] = {"core": True} + jobs["core"] = [ { "os": "ubuntu-latest", - "features": "services-fs,services-s3", - "cases": [{ - "setup": "local-fs", - "service": "fs" - }] + "features": ",".join(set([f"services-{v['service']}" for v in core_cases])), + "cases": [{"setup": v["setup"], 'service': v['service']} for v in core_cases], }, + # fs is the only services need to run upon windows, let's hard code it here. { "os": "windows-latest", - "features": "services-fs,services-s3", - "cases": [{ - "setup": "local-fs", - "service": "fs" - }] + "features": "services-fs", + "cases": [{"setup": "local-fs", "service": "fs"}], } ] - } + return json.dumps(jobs) -if __name__ == '__main__': - changed_files = sys.argv[1:] - result = plan(changed_files) + +# For quick test: +# +# `./scripts/workflow_planner.py '{"event_name": "push", "repository": "apache/incubator-opendal"}' PATH` +if __name__ == "__main__": + github = json.loads(sys.argv[1]) + changed_files = sys.argv[2:] + result = plan(github, changed_files) print(result) From b28c97692476acd21c0aac5ff9de77070dad5a49 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 00:38:32 +0800 Subject: [PATCH 27/37] better Signed-off-by: Xuanwo --- .github/workflows/test_planner.yml | 21 ++++++++++++++++----- scripts/workflow_planner.py | 15 +++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_planner.yml b/.github/workflows/test_planner.yml index dba36b8d3d20..08d0cdcf4c05 100644 --- a/.github/workflows/test_planner.yml +++ b/.github/workflows/test_planner.yml @@ -33,7 +33,7 @@ jobs: plan: runs-on: ubuntu-latest outputs: - plan: ${{ steps.get-changes.outputs.plan }} + plan: ${{ steps.plan.outputs.plan }} steps: - uses: actions/checkout@v4 @@ -41,17 +41,28 @@ jobs: # fetch depth set to 0 to make sure we have correct diff result. fetch-depth: 0 - - name: Get Changes - id: get-changes + - name: Plan + id: plan run: | git fetch origin main:main FILES_CHANGED=$(git diff --name-only main ${{ github.event.pull_request.head.sha }}) echo "Files changed:" echo "$FILES_CHANGED" - GITHUB_CONTEXT=${{ toJson(github) }} + event_name="${{ github.event_name }}" + repository="${{ github.repository }}" + pr_head_full_name="${{ github.event.pull_request.head.full_name }}" + pr_head_repo_fork="${{ github.event.pull_request.head.repo.fork }}" - PLAN=$(./scripts/workflow_planner.py $GITHUB_CONTEXT $FILES_CHANGED) + has_secrets="False" + if [ "$event_name" == "push" ] && [ "$repository" == "apache/incubator-opendal" ]; then + has_secrets="True" + elif [ "$event_name" == "pull_request" ] && [ "$pr_head_repo_fork" != "true" ]; then + has_secrets="True" + fi + export GITHUB_HAS_SECRETS=$has_secrets + + PLAN=$(./scripts/workflow_planner.py $FILES_CHANGED) echo "Plan:" echo "$PLAN" diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index d0fb4df468fd..be588fde9c96 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -39,7 +39,7 @@ def check_secrets(github): return False -def get_provided_cases(github): +def get_provided_cases(): root_dir = ".github/services" cases = [ @@ -57,7 +57,7 @@ def get_provided_cases(github): # Check if this workflow needs to read secrets. # # We will check if pattern `secrets.XXX` exist in content. - if not check_secrets(github): + if not bool(os.getenv("GITHUB_HAS_SECRETS")): cases[:] = [v for v in cases if "secrets." in v["content"]] return cases @@ -88,10 +88,10 @@ def calculate_core_cases(cases, changed_files): # Context is the github context: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context -def plan(github, changed_files): +def plan(changed_files): # TODO: add bindings/java, bindings/python in the future. components = ["core"] - cases = get_provided_cases(github) + cases = get_provided_cases() core_cases = calculate_core_cases(cases, changed_files) @@ -118,9 +118,8 @@ def plan(github, changed_files): # For quick test: # -# `./scripts/workflow_planner.py '{"event_name": "push", "repository": "apache/incubator-opendal"}' PATH` +# ./scripts/workflow_planner.py PATH if __name__ == "__main__": - github = json.loads(sys.argv[1]) - changed_files = sys.argv[2:] - result = plan(github, changed_files) + changed_files = sys.argv[1:] + result = plan(changed_files) print(result) From f64c752573d3056839c31e7341ebef6050ec6b22 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 00:41:48 +0800 Subject: [PATCH 28/37] Polish fs Signed-off-by: Xuanwo --- scripts/workflow_planner.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index be588fde9c96..1af91357852a 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -97,22 +97,30 @@ def plan(changed_files): jobs = {} - if len(core_cases)> 0: + if len(core_cases) > 0: jobs["components"] = {"core": True} jobs["core"] = [ { "os": "ubuntu-latest", - "features": ",".join(set([f"services-{v['service']}" for v in core_cases])), - "cases": [{"setup": v["setup"], 'service': v['service']} for v in core_cases], + "features": ",".join( + set([f"services-{v['service']}" for v in core_cases]) + ), + "cases": [ + {"setup": v["setup"], "service": v["service"]} for v in core_cases + ], }, - # fs is the only services need to run upon windows, let's hard code it here. - { - "os": "windows-latest", - "features": "services-fs", - "cases": [{"setup": "local-fs", "service": "fs"}], - } ] + # fs is the only services need to run upon windows, let's hard code it here. + if "fs" in [v["service"] for v in core_cases]: + jobs["core"].append( + { + "os": "windows-latest", + "features": "services-fs", + "cases": [{"setup": "local-fs", "service": "fs"}], + } + ) + return json.dumps(jobs) From 2d8dbda114afbf01d0f4dc5e179ebbf30b6fd881 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 00:50:14 +0800 Subject: [PATCH 29/37] Add s3 Signed-off-by: Xuanwo --- .github/services/s3/aws-s3/action.yml | 33 +++++++++++++++++++++++++++ scripts/workflow_planner.py | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/services/s3/aws-s3/action.yml diff --git a/.github/services/s3/aws-s3/action.yml b/.github/services/s3/aws-s3/action.yml new file mode 100644 index 000000000000..36ebf4c29b78 --- /dev/null +++ b/.github/services/s3/aws-s3/action.yml @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: aws_s3 +description: "Setup AWS S3" + +runs: + using: "composite" + steps: + - name: Setup + shell: bash + run: | + echo "OPENDAL_S3_TEST=${{ secrets.OPENDAL_S3_TEST }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ROOT=${{ secrets.OPENDAL_S3_ROOT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_BUCKET=${{ secrets.OPENDAL_S3_BUCKET }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ENDPOINT=${{ secrets.OPENDAL_S3_ENDPOINT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ACCESS_KEY_ID=${{ secrets.OPENDAL_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV + echo "OPENDAL_S3_SECRET_ACCESS_KEY=${{ secrets.OPENDAL_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV + echo "OPENDAL_S3_REGION=ap-northeast-1" >> $GITHUB_ENV diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 1af91357852a..74b2acaa0891 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -58,7 +58,7 @@ def get_provided_cases(): # # We will check if pattern `secrets.XXX` exist in content. if not bool(os.getenv("GITHUB_HAS_SECRETS")): - cases[:] = [v for v in cases if "secrets." in v["content"]] + cases[:] = [v for v in cases if "secrets." not in v["content"]] return cases From 85a69e9c2c48b48e72cf0754006375b3da22614d Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 00:53:06 +0800 Subject: [PATCH 30/37] Make json pretty Signed-off-by: Xuanwo --- .github/workflows/test_planner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_planner.yml b/.github/workflows/test_planner.yml index 08d0cdcf4c05..f1e5af1ee3ca 100644 --- a/.github/workflows/test_planner.yml +++ b/.github/workflows/test_planner.yml @@ -64,7 +64,7 @@ jobs: PLAN=$(./scripts/workflow_planner.py $FILES_CHANGED) echo "Plan:" - echo "$PLAN" + echo "$PLAN" | jq . echo "plan=$PLAN" >> $GITHUB_OUTPUT From 03860f1771c0373a422a29e94bdadc6d3d956c7d Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 01:00:32 +0800 Subject: [PATCH 31/37] Make sure secrets Signed-off-by: Xuanwo --- .github/workflows/test_planner.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_planner.yml b/.github/workflows/test_planner.yml index f1e5af1ee3ca..c9c3832a3951 100644 --- a/.github/workflows/test_planner.yml +++ b/.github/workflows/test_planner.yml @@ -72,6 +72,7 @@ jobs: name: core / ${{ matrix.os }} needs: [plan] if: fromJson(needs.plan.outputs.plan).components.core + secrets: inherit strategy: matrix: include: ${{ fromJson(needs.plan.outputs.plan).core }} From c0287e3a0402badd592c747feaa953cfd857c758 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 01:17:23 +0800 Subject: [PATCH 32/37] Try passing Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 5 +++++ .github/services/s3/aws-s3/action.yml | 17 +++++++++++------ .github/workflows/core_test.yml | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index c3c8a6c473fd..be26c0b14ef2 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -22,6 +22,9 @@ inputs: description: "The setup action for test" service: description: "The service to test" + secrets: + description: "The secrets for test" + default: "{}" runs: using: "composite" @@ -36,6 +39,8 @@ runs: steps: - name: Setup Test Core uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} + with: + secrets: ${{ inputs.secrets }} - name: Run Test Core shell: bash working-directory: core diff --git a/.github/services/s3/aws-s3/action.yml b/.github/services/s3/aws-s3/action.yml index 36ebf4c29b78..75e3ba6717b0 100644 --- a/.github/services/s3/aws-s3/action.yml +++ b/.github/services/s3/aws-s3/action.yml @@ -18,16 +18,21 @@ name: aws_s3 description: "Setup AWS S3" +inputs: + secrets: + description: "The secrets for test" + default: "{}" + runs: using: "composite" steps: - name: Setup shell: bash run: | - echo "OPENDAL_S3_TEST=${{ secrets.OPENDAL_S3_TEST }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ROOT=${{ secrets.OPENDAL_S3_ROOT }}" >> $GITHUB_ENV - echo "OPENDAL_S3_BUCKET=${{ secrets.OPENDAL_S3_BUCKET }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ENDPOINT=${{ secrets.OPENDAL_S3_ENDPOINT }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ACCESS_KEY_ID=${{ secrets.OPENDAL_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV - echo "OPENDAL_S3_SECRET_ACCESS_KEY=${{ secrets.OPENDAL_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV + echo "OPENDAL_S3_TEST=${{ inputs.secrets.OPENDAL_S3_TEST }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ROOT=${{ inputs.secrets.OPENDAL_S3_ROOT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_BUCKET=${{ inputs.secrets.OPENDAL_S3_BUCKET }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ENDPOINT=${{ inputs.secrets.OPENDAL_S3_ENDPOINT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ACCESS_KEY_ID=${{ inputs.secrets.OPENDAL_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV + echo "OPENDAL_S3_SECRET_ACCESS_KEY=${{ inputs.secrets.OPENDAL_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV echo "OPENDAL_S3_REGION=ap-northeast-1" >> $GITHUB_ENV diff --git a/.github/workflows/core_test.yml b/.github/workflows/core_test.yml index 5cda79c758ee..a92cadd9a3f6 100644 --- a/.github/workflows/core_test.yml +++ b/.github/workflows/core_test.yml @@ -90,3 +90,4 @@ jobs: with: setup: ${{ matrix.cases.setup }} service: ${{ matrix.cases.service }} + secrets: ${{ toJson(secrets) }} From 24f1961afea2114dbd7b0e79e972b8109a604c0d Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 01:24:59 +0800 Subject: [PATCH 33/37] Use from json Signed-off-by: Xuanwo --- .github/actions/test-core/action.yaml | 2 +- .github/services/s3/aws-s3/action.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/test-core/action.yaml b/.github/actions/test-core/action.yaml index be26c0b14ef2..da5759fe14ed 100644 --- a/.github/actions/test-core/action.yaml +++ b/.github/actions/test-core/action.yaml @@ -40,7 +40,7 @@ runs: - name: Setup Test Core uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} with: - secrets: ${{ inputs.secrets }} + secrets: ${{ toJson(inputs.secrets) }} - name: Run Test Core shell: bash working-directory: core diff --git a/.github/services/s3/aws-s3/action.yml b/.github/services/s3/aws-s3/action.yml index 75e3ba6717b0..3c5f668f628c 100644 --- a/.github/services/s3/aws-s3/action.yml +++ b/.github/services/s3/aws-s3/action.yml @@ -29,10 +29,10 @@ runs: - name: Setup shell: bash run: | - echo "OPENDAL_S3_TEST=${{ inputs.secrets.OPENDAL_S3_TEST }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ROOT=${{ inputs.secrets.OPENDAL_S3_ROOT }}" >> $GITHUB_ENV - echo "OPENDAL_S3_BUCKET=${{ inputs.secrets.OPENDAL_S3_BUCKET }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ENDPOINT=${{ inputs.secrets.OPENDAL_S3_ENDPOINT }}" >> $GITHUB_ENV - echo "OPENDAL_S3_ACCESS_KEY_ID=${{ inputs.secrets.OPENDAL_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV - echo "OPENDAL_S3_SECRET_ACCESS_KEY=${{ inputs.secrets.OPENDAL_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV + echo "OPENDAL_S3_TEST=${{ fromJson(inputs.secrets).OPENDAL_S3_TEST }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ROOT=${{ fromJson(inputs.secrets).OPENDAL_S3_ROOT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_BUCKET=${{ fromJson(inputs.secrets).OPENDAL_S3_BUCKET }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ENDPOINT=${{ fromJson(inputs.secrets).OPENDAL_S3_ENDPOINT }}" >> $GITHUB_ENV + echo "OPENDAL_S3_ACCESS_KEY_ID=${{ fromJson(inputs.secrets).OPENDAL_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV + echo "OPENDAL_S3_SECRET_ACCESS_KEY=${{ fromJson(inputs.secrets).OPENDAL_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV echo "OPENDAL_S3_REGION=ap-northeast-1" >> $GITHUB_ENV From defbe2666c2102d76f4624095659ed8f7946572c Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 01:26:17 +0800 Subject: [PATCH 34/37] Fix Signed-off-by: Xuanwo --- .github/services/s3/aws-s3/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/services/s3/aws-s3/action.yml b/.github/services/s3/aws-s3/action.yml index 3c5f668f628c..7591937d5a81 100644 --- a/.github/services/s3/aws-s3/action.yml +++ b/.github/services/s3/aws-s3/action.yml @@ -23,6 +23,7 @@ inputs: description: "The secrets for test" default: "{}" +# TODO: we should migrate to 1password instead. runs: using: "composite" steps: From 0642f347f07cd1de09f2e979a5513d0678a0765a Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 01:36:46 +0800 Subject: [PATCH 35/37] Remove migrated tests Signed-off-by: Xuanwo --- .github/workflows/service_test_fs.yml | 58 --------------------------- .github/workflows/service_test_s3.yml | 53 +++++++----------------- 2 files changed, 15 insertions(+), 96 deletions(-) delete mode 100644 .github/workflows/service_test_fs.yml diff --git a/.github/workflows/service_test_fs.yml b/.github/workflows/service_test_fs.yml deleted file mode 100644 index 79119833399f..000000000000 --- a/.github/workflows/service_test_fs.yml +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Service Test Fs - -on: -# push: -# branches: -# - main -# pull_request: -# branches: -# - main -# paths: -# - "core/src/**" -# - "core/tests/**" -# - "!core/src/docs/**" -# - "!core/src/services/**" -# - "core/src/services/fs/**" -# - ".github/workflows/service_test_fs.yml" - workflow_call: - -#concurrency: -# group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} -# cancel-in-progress: true - -jobs: - local_fs: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - uses: ./.github/actions/setup - - name: Test - shell: bash - working-directory: core - run: cargo test services_fs - env: - OPENDAL_FS_TEST: on - OPENDAL_FS_ROOT: ${{ runner.temp }}/ diff --git a/.github/workflows/service_test_s3.yml b/.github/workflows/service_test_s3.yml index efc82da64ccc..95f703ab7095 100644 --- a/.github/workflows/service_test_s3.yml +++ b/.github/workflows/service_test_s3.yml @@ -18,50 +18,27 @@ name: Service Test S3 on: -# push: -# branches: -# - main -# pull_request: -# branches: -# - main -# paths: -# - "core/src/**" -# - "core/tests/**" -# - "!core/src/docs/**" -# - "!core/src/services/**" -# - "core/src/services/s3/**" -# - "bindings/java/**" -# - ".github/workflows/service_test_s3.yml" -# - "fixtures/s3/**" - workflow_call: + push: + branches: + - main + pull_request: + branches: + - main + paths: + - "core/src/**" + - "core/tests/**" + - "!core/src/docs/**" + - "!core/src/services/**" + - "core/src/services/s3/**" + - "bindings/java/**" + - ".github/workflows/service_test_s3.yml" + - "fixtures/s3/**" concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true jobs: - aws_s3: - runs-on: ubuntu-latest - if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - - name: Test - shell: bash - working-directory: core - run: cargo nextest run s3 - env: - OPENDAL_S3_TEST: ${{ secrets.OPENDAL_S3_TEST }} - OPENDAL_S3_ROOT: ${{ secrets.OPENDAL_S3_ROOT }} - OPENDAL_S3_BUCKET: ${{ secrets.OPENDAL_S3_BUCKET }} - OPENDAL_S3_ENDPOINT: ${{ secrets.OPENDAL_S3_ENDPOINT }} - OPENDAL_S3_ACCESS_KEY_ID: ${{ secrets.OPENDAL_S3_ACCESS_KEY_ID }} - OPENDAL_S3_SECRET_ACCESS_KEY: ${{ secrets.OPENDAL_S3_SECRET_ACCESS_KEY }} - OPENDAL_S3_REGION: ap-northeast-1 - aws_s3_with_virtual_host: runs-on: ubuntu-latest if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork From a9343359ad5f806ab3aa218f7b0d8e08420abd6e Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 10:09:32 +0800 Subject: [PATCH 36/37] remove unused functions Signed-off-by: Xuanwo --- scripts/workflow_planner.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index 74b2acaa0891..d57b4a47accb 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -22,23 +22,6 @@ from pathlib import Path -# Check if we can access secrets based on github context. -def check_secrets(github): - if ( - github["event_name"] == "push" - and github["repository"] == "apache/incubator-opendal" - ): - return True - if ( - github["event_name"] == "pull_request" - and github["event"]["pull_request"]["head"]["full_name"] - == "apache/incubator-opendal" - and not github["event"]["pull_request"]["head"]["repo"]["fork"] - ): - return True - return False - - def get_provided_cases(): root_dir = ".github/services" From 342d525c7d2674e7acec3a2cd0c062e8f7d90e2e Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 13 Oct 2023 10:41:21 +0800 Subject: [PATCH 37/37] Work under push event Signed-off-by: Xuanwo --- .github/workflows/test_planner.yml | 35 ++++++++++++++++++++---------- scripts/workflow_planner.py | 4 ++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test_planner.yml b/.github/workflows/test_planner.yml index c9c3832a3951..535170d863ca 100644 --- a/.github/workflows/test_planner.yml +++ b/.github/workflows/test_planner.yml @@ -45,27 +45,38 @@ jobs: id: plan run: | git fetch origin main:main - FILES_CHANGED=$(git diff --name-only main ${{ github.event.pull_request.head.sha }}) - echo "Files changed:" - echo "$FILES_CHANGED" event_name="${{ github.event_name }}" repository="${{ github.repository }}" - pr_head_full_name="${{ github.event.pull_request.head.full_name }}" - pr_head_repo_fork="${{ github.event.pull_request.head.repo.fork }}" - + files_changed="" has_secrets="False" - if [ "$event_name" == "push" ] && [ "$repository" == "apache/incubator-opendal" ]; then - has_secrets="True" - elif [ "$event_name" == "pull_request" ] && [ "$pr_head_repo_fork" != "true" ]; then - has_secrets="True" + is_push="False" + + # Handle event-specific logic + if [ "$event_name" == "push" ]; then + if [ "$repository" == "apache/incubator-opendal" ]; then + is_push="True" + has_secrets="True" + fi + elif [ "$event_name" == "pull_request" ]; then + pr_head_repo_fork="${{ github.event.pull_request.head.repo.fork }}" + if [ "$pr_head_repo_fork" != "true" ]; then + has_secrets="True" + fi + + files_changed=$(git diff --name-only main ${{ github.event.pull_request.head.sha }}) + echo "Files changed:" + echo "$FILES_CHANGED" fi + + # Export variables export GITHUB_HAS_SECRETS=$has_secrets + export GITHUB_IS_PUSH=$is_push - PLAN=$(./scripts/workflow_planner.py $FILES_CHANGED) + # Run the workflow planner script + PLAN=$(./scripts/workflow_planner.py $files_changed) echo "Plan:" echo "$PLAN" | jq . - echo "plan=$PLAN" >> $GITHUB_OUTPUT core_test: diff --git a/scripts/workflow_planner.py b/scripts/workflow_planner.py index d57b4a47accb..7c8d8f9d71e5 100755 --- a/scripts/workflow_planner.py +++ b/scripts/workflow_planner.py @@ -56,6 +56,10 @@ def calculate_core_cases(cases, changed_files): if p in changed_files: return cases + # Always run all tests if it is a push event. + if bool(os.getenv("GITHUB_IS_PUSH")): + return cases + # If any of the core files changed, we will run all cases. if any( p.startswith("core/src/") and not p.startswith("core/src/services")