From 70b12c6efa8e9c168bfe0e01d8cb2ede9fc6232f Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 6 May 2023 17:49:15 +0800 Subject: [PATCH] ci: add path-filter (#1422) Signed-off-by: tison --- .github/config/changes.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/kvrocks.yaml | 27 +++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/config/changes.yml diff --git a/.github/config/changes.yml b/.github/config/changes.yml new file mode 100644 index 00000000000..f556a862849 --- /dev/null +++ b/.github/config/changes.yml @@ -0,0 +1,29 @@ +# 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. + +all: + - '**' +docs: + - '*.md' + - '**/*.md' + - '.github/ISSUE_TEMPLATE/**' + - 'assets/**' + - 'licenses/**' + - '.asf.yaml' + - '.github/changes.yaml' + - '.gitignore' + - 'NOTICE' diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml index 54535e842bf..225ffd6432a 100644 --- a/.github/workflows/kvrocks.yaml +++ b/.github/workflows/kvrocks.yaml @@ -33,9 +33,28 @@ concurrency: cancel-in-progress: true jobs: + precondition: + name: Precondition + runs-on: ubuntu-22.04 + outputs: + docs_only: ${{ steps.result.outputs.docs_only }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: .github/config/changes.yml + list-files: csv + - name: Calculate changes + id: result + run: | + echo "docs_only=${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" >> $GITHUB_OUTPUT + check-and-lint: name: Lint and check code + if: ${{ needs.precondition.outputs.docs_only != 'true' }} runs-on: ubuntu-22.04 + needs: [precondition] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -72,6 +91,7 @@ jobs: build-and-test: name: Build and test + if: ${{ needs.precondition.outputs.docs_only != 'true' }} needs: [check-and-lint] strategy: fail-fast: false @@ -259,6 +279,7 @@ jobs: check-docker: name: Check Docker image + if: ${{ needs.precondition.outputs.docs_only != 'true' }} needs: [check-and-lint] runs-on: ubuntu-20.04 steps: @@ -268,8 +289,7 @@ jobs: - uses: docker/build-push-action@v3 with: context: . - build-args: | - MORE_BUILD_ARGS=-j${{ env.NPROC }} + build-args: MORE_BUILD_ARGS=-j${{ env.NPROC }} required: if: always() @@ -280,6 +300,7 @@ jobs: - check-docker steps: - name: Merge requirement checking + if: ${{ needs.precondition.outputs.docs_only != 'true' }} run: | if [[ ! ( \ "${{ needs.build-and-test.result }}" == "success" \ @@ -288,3 +309,5 @@ jobs: echo "Required jobs haven't been completed successfully." exit 1 fi + - name: Sentinel + run: true