Skip to content

Commit

Permalink
Skip CI in some cases to save resources (#6340)
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Feb 7, 2021
1 parent ba6d49a commit 30a88b5
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/actions/plugins-test/action.yml
Expand Up @@ -43,7 +43,7 @@ runs:
shell: bash
run: |
echo "::group::Add checkstyle plugin to the pom.xml"
sed -i "/<\/sourceDirectories>/i <sourceDirectory>scenarios\/""${{ matrix.case }}""<\/sourceDirectory>" test/plugin/pom.xml
sed -i "/<\/sourceDirectories>/i <sourceDirectory>scenarios\/""${{ inputs.test_case }}""<\/sourceDirectory>" test/plugin/pom.xml
echo "::endgroup::"
- name: Build SkyWalking Agent
shell: bash
Expand Down
76 changes: 76 additions & 0 deletions .github/actions/skip/action.yml
@@ -0,0 +1,76 @@
#
# 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: "Set Skip Env Var"
description: "Action to set the SKIP_CI environment variable indicating that we should skip CI jobs"
inputs:
paths:
description: >-
Set the SKIP_CI environment variable when and only when all the changed files located in one of the path,
the paths is shell-style pattern.
required: false
default: >-
"*.md"
"skywalking-ui"
runs:
using: "composite"
steps:
- name: Check Changed Files And Set Env Var
shell: bash
run: |
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
exit 0
fi
BASE_SHA=$(jq -r '.pull_request.base.sha' $GITHUB_EVENT_PATH)
echo "Base sha is $BASE_SHA, head sha is $GITHUB_SHA"
git fetch --no-tags --progress --recurse-submodules --depth=1 origin ${BASE_SHA}:origin/${BASE_SHA}
BASE_SHA=origin/${BASE_SHA}
echo "Base sha is $BASE_SHA, head sha is $GITHUB_SHA"
if ! files=$(git --no-pager diff --name-only ${GITHUB_SHA} ${BASE_SHA}); then
exit 1
fi
echo "Ignore pattern:"
for pattern in $(echo '${{ inputs.paths }}'); do
echo $pattern
done
echo "Changed files:"
for file in ${files}; do
echo $file
done
echo "SKIP_CI=true" >> $GITHUB_ENV
for file in ${files}; do
matched=0
for pattern in $(echo '${{ inputs.paths }}'); do
pattern=$(echo "$pattern" | sed 's/"//g')
if eval "[[ '$file' == $pattern ]]"; then
matched=1
break
fi
done
if [[ "$matched" == "0" ]]; then
echo "$file doesn't match pattern $(echo '${{ inputs.paths }}'), stop checking"
echo "SKIP_CI=false" >> $GITHUB_ENV
break
fi
done
23 changes: 23 additions & 0 deletions .github/workflows/ci-it.yaml
Expand Up @@ -33,27 +33,35 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Check License Header
if: env.SKIP_CI != 'true'
uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-java@v1
if: env.SKIP_CI != 'true'
with:
java-version: 8
- name: 'Check Javaagent Plugin List'
if: env.SKIP_CI != 'true'
run: tools/plugin/check-javaagent-plugin-list.sh
- name: 'Install & Test'
if: env.SKIP_CI != 'true'
run: |
./mvnw --batch-mode -P"agent,backend,ui,dist,CI-with-IT" clean cobertura:cobertura verify install javadoc:javadoc
bash <(curl -s https://codecov.io/bash)
- name: 'Check Dependencies Licenses'
if: env.SKIP_CI != 'true'
run: tools/dependencies/check-LICENSE.sh

CI-on-JDK11:
Expand All @@ -63,19 +71,25 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Check License Header
if: env.SKIP_CI != 'true'
uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-java@v1
if: env.SKIP_CI != 'true'
with:
java-version: 11
- name: 'Install & Test'
if: env.SKIP_CI != 'true'
run: ./mvnw --batch-mode -P"agent,backend,ui,dist" clean verify install

CI-on-Windows:
Expand All @@ -85,10 +99,14 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- uses: actions/setup-java@v1
if: env.SKIP_CI != 'true'
with:
java-version: 8
- name: 'Install & Test'
if: env.SKIP_CI != 'true'
run: ./mvnw --batch-mode -P"agent,backend,ui,dist" clean verify install


Expand All @@ -99,17 +117,22 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-java@v1
if: env.SKIP_CI != 'true'
with:
java-version: 8
- name: 'Install & Test'
if: env.SKIP_CI != 'true'
run: |
# Given packaging on Mac has a high possibility to fail, we retry one more time here
./mvnw --batch-mode -P"agent,backend,ui,dist" clean verify install || \
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e.cluster.yaml
Expand Up @@ -40,14 +40,18 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run E2E Test
if: env.SKIP_CI != 'true'
uses: ./.github/actions/e2e-test
with:
test_class: org.apache.skywalking.e2e.ClusterE2E
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/e2e.compat.yaml
Expand Up @@ -34,18 +34,23 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set Up Java
if: env.SKIP_CI != 'true'
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run E2E Test
if: env.SKIP_CI != 'true'
uses: ./.github/actions/e2e-test
with:
test_class: org.apache.skywalking.e2e.simple.SimpleE2E
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e.event.yaml
Expand Up @@ -40,14 +40,18 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run E2E Test
if: env.SKIP_CI != 'true'
uses: ./.github/actions/e2e-test
with:
test_class: org.apache.skywalking.e2e.event.EventE2E
4 changes: 4 additions & 0 deletions .github/workflows/e2e.go.yaml
Expand Up @@ -36,14 +36,18 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip
- name: Cache local Maven repository
if: env.SKIP_CI != 'true'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run E2E Test
if: env.SKIP_CI != 'true'
uses: ./.github/actions/e2e-test
with:
test_class: org.apache.skywalking.e2e.GOE2E
Expand Down

0 comments on commit 30a88b5

Please sign in to comment.