Skip to content

Commit

Permalink
[Build] Fix skipping tests when there are only documentation changes …
Browse files Browse the repository at this point in the history
…and run centos7 & windows cpp build only when there are cpp changes (apache#10376)

Fixes apache#10373

### Motivation

Tests should be skipped for PR builds that only contain documentation changes. This is currently broken.

A new build has been introduced for building the CPP client on Windows. Make the changes in `ci-cpp-build-centos7.yaml` and `ci-cpp-build-windows.yaml` so that the builds run only when there are changes in CPP client files (or the workflow definitions). 

### Modifications

Refactor logic to be less error prone. Use [`fromJSON`](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#fromjson) function to parse a number in a string as a number. 

### Additional Context

apache#10276
  • Loading branch information
lhotari authored Apr 28, 2021
1 parent 212ad48 commit 0984022
Show file tree
Hide file tree
Showing 29 changed files with 373 additions and 452 deletions.
10 changes: 10 additions & 0 deletions .github/changes-filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# contains pattern definitions used in workflows "changes" step
# pattern syntax: https://github.com/micromatch/picomatch
all:
- '**'
docs:
- 'site2/**'
- 'deployment/**'
- '.asf.yaml'
- '*.md'
- '**/*.md'
16 changes: 14 additions & 2 deletions .github/workflows/ci-build-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ on:
pull_request:
branches:
- master
paths-ignore: ['site2/**', 'deployment/**']
push:
branches:
- branch-*
paths-ignore: ['site2/**', 'deployment/**']

env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
Expand All @@ -45,7 +43,18 @@ jobs:
- name: Tune Runner VM
uses: ./.github/actions/tune-runner-vm

- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: Cache Maven dependencies
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
uses: actions/cache@v2
with:
path: |
Expand All @@ -56,12 +65,15 @@ jobs:
${{ runner.os }}-m2-dependencies-all-
- name: Set up JDK 1.8
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Replace maven's wagon-http version
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: sudo ./build/replace_maven-wagon-http-version.sh

- name: build package
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: mvn -B clean install -DskipTests
28 changes: 14 additions & 14 deletions .github/workflows/ci-cpp-build-centos7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ on:
pull_request:
branches:
- master
paths:
- '.github/workflows/**'
- 'pulsar-client-cpp/**'
push:
branches:
- branch-*

paths:
- '.github/workflows/**'
- 'pulsar-client-cpp/**'
jobs:

cpp-build-centos7:
Expand All @@ -40,23 +45,18 @@ jobs:
- name: Tune Runner VM
uses: ./.github/actions/tune-runner-vm

- name: Changed files check
- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: |
# pattern syntax: https://github.com/micromatch/picomatch
all:
- 'pulsar-client-cpp/**'
docs:
- 'site2/**'
- 'deployment/**'
- '.asf.yaml'
- '*.md'
- '**/*.md'
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: build cpp client on centos 7
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
echo "Build C++ client library on CentOS 7"
pulsar-client-cpp/docker-build-centos7.sh
pulsar-client-cpp/docker-build-centos7.sh
21 changes: 20 additions & 1 deletion .github/workflows/ci-cpp-build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ on:
pull_request:
branches:
- master
paths:
- '.github/workflows/**'
- 'pulsar-client-cpp/**'
push:
branches:
- branch-*
paths:
- '.github/workflows/**'
- 'pulsar-client-cpp/**'

env:
VCPKG_FEATURE_FLAGS: manifests
Expand All @@ -51,12 +57,24 @@ jobs:
- name: checkout
uses: actions/checkout@v2

- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: Install vcpkg packages
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
shell: bash
run: |
cd pulsar-client-cpp && vcpkg install --triplet ${{ matrix.triplet }}
- name: Configure
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
Expand All @@ -71,9 +89,10 @@ jobs:
fi
- name: Compile
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cd pulsar-client-cpp && \
cmake --build ./build
fi
fi
31 changes: 13 additions & 18 deletions .github/workflows/ci-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,18 @@ jobs:
- name: Tune Runner VM
uses: ./.github/actions/tune-runner-vm

- name: Changed files check
- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: |
# pattern syntax: https://github.com/micromatch/picomatch
all:
- '**'
docs:
- 'site2/**'
- 'deployment/**'
- '.asf.yaml'
- '*.md'
- '**/*.md'
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: Cache local Maven repository
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
uses: actions/cache@v2
with:
path: |
Expand All @@ -71,12 +66,12 @@ jobs:
- name: Set up JDK 1.8
uses: actions/setup-java@v1
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
with:
java-version: 1.8

- name: clean disk
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
sudo swapoff -a
sudo rm -f /swapfile
Expand All @@ -85,22 +80,22 @@ jobs:
df -h
- name: Replace maven's wagon-http version
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: sudo ./build/replace_maven-wagon-http-version.sh

- name: build package
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: mvn -B -ntp -q install -Pcore-modules,-main -DskipTests

- name: build cpp artifacts
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
echo "Build C++ client library"
export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_DYNAMIC_LIB=OFF -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so"
pulsar-client-cpp/docker-build.sh
- name: run c++ tests
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: pulsar-client-cpp/docker-tests.sh

- name: Upload test-logs
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/ci-go-functions-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,38 @@ jobs:
- name: Tune Runner VM
uses: ./.github/actions/tune-runner-vm

- name: Changed files check
- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: |
# pattern syntax: https://github.com/micromatch/picomatch
all:
- '**'
docs:
- 'site2/**'
- 'deployment/**'
- '.asf.yaml'
- '*.md'
- '**/*.md'
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: Set up Go
uses: actions/setup-go@v2
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
with:
go-version: ${{ matrix.go-version }}
id: go

- name: InstallTool
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
cd pulsar-function-go
wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.18.0
./bin/golangci-lint --version
- name: Build
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
cd pulsar-function-go
go build ./...
- name: CheckStyle
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
cd pulsar-function-go
./bin/golangci-lint run -c ./golangci.yml ./pf
21 changes: 8 additions & 13 deletions .github/workflows/ci-go-functions-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,25 @@ jobs:
- name: Tune Runner VM
uses: ./.github/actions/tune-runner-vm

- name: Changed files check
- name: Detect changed files
id: changes
uses: apache/pulsar-test-infra/paths-filter@master
with:
filters: |
# pattern syntax: https://github.com/micromatch/picomatch
all:
- '**'
docs:
- 'site2/**'
- 'deployment/**'
- '.asf.yaml'
- '*.md'
- '**/*.md'
filters: .github/changes-filter.yaml

- name: Check changed files
id: check_changes
run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}"

- name: Set up Go
uses: actions/setup-go@v2
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Run tests
if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: |
cd pulsar-function-go
go test -v $(go list ./... | grep -v examples)
Loading

0 comments on commit 0984022

Please sign in to comment.