Skip to content

Commit

Permalink
ci: add path-filter (#1422)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed May 6, 2023
1 parent f416fbb commit 70b12c6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/config/changes.yml
Original file line number Diff line number Diff line change
@@ -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'
27 changes: 25 additions & 2 deletions .github/workflows/kvrocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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" \
Expand All @@ -288,3 +309,5 @@ jobs:
echo "Required jobs haven't been completed successfully."
exit 1
fi
- name: Sentinel
run: true

0 comments on commit 70b12c6

Please sign in to comment.