You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/10/11 16:43:34 UTC
[incubator-opendal] 01/01: Try workflow call
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch refactor-actions
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 65f363d32e7cad6701ba596254dcbbbb63b38ce8
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Thu Oct 12 00:43:19 2023 +0800
Try workflow call
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
.github/workflows/service_test_fs.yml | 27 +++++------
.../workflows/{service_test_fs.yml => test.yml} | 52 ++++++++++++----------
scripts/workflow_planner.py | 31 +++++++++++++
3 files changed, 73 insertions(+), 37 deletions(-)
diff --git a/.github/workflows/service_test_fs.yml b/.github/workflows/service_test_fs.yml
index c06b9e81d..bcb22643f 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/service_test_fs.yml b/.github/workflows/test.yml
similarity index 55%
copy from .github/workflows/service_test_fs.yml
copy to .github/workflows/test.yml
index c06b9e81d..e2f630ae4 100644
--- a/.github/workflows/service_test_fs.yml
+++ b/.github/workflows/test.yml
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-name: Service Test Fs
+name: Test
on:
push:
@@ -24,34 +24,38 @@ on:
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"
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
+ plan:
+ runs-on: ubuntu-latest
+ outputs:
+ plan: ${{ steps.get-changes.outputs.plan }}
+
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 }}/
+ 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 000000000..1c94e0020
--- /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)