[Build] Cache vcpkg install to accelerate the CI
@@ -41,6 +41,8 @@ jobs:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
+ env:
+ VCPKG_ROOT: '${{ github.workspace }}/vcpkg'
strategy:
fail-fast: false
matrix:
@@ -74,11 +76,38 @@ jobs:
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: Restore vcpkg and its artifacts.
+ uses: actions/cache@v2
+ id: vcpkg-cache
+ with:
+ path: |
+ ${{ env.VCPKG_ROOT }}
+ pulsar-client-cpp/vcpkg_installed
+ !${{ env.VCPKG_ROOT }}/.git
+ !${{ env.VCPKG_ROOT }}/buildtrees
+ !${{ env.VCPKG_ROOT }}/packages
+ !${{ env.VCPKG_ROOT }}/downloads
+ key: |
+ ${{ runner.os }}-${{ matrix.triplet}}-${{ hashFiles( 'pulsar-client-cpp/vcpkg.json' ) }}
+
+ - name: Get vcpkg(windows)
+ if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }}
+ run: |
+ cd ${{ github.workspace }}
+ mkdir build -force
+ git clone https://github.com/Microsoft/vcpkg.git
+ cd vcpkg
+ .\bootstrap-vcpkg.bat
+
+ - name: remove system vcpkg(windows)
+ if: runner.os == 'Windows'
+ run: rm -rf "$VCPKG_INSTALLATION_ROOT"
+ shell: bash
+
- name: Install vcpkg packages
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
- shell: bash
run: |
- cd pulsar-client-cpp && vcpkg install --triplet ${{ matrix.triplet }}
+ cd pulsar-client-cpp && ${{ env.VCPKG_ROOT }}\vcpkg.exe install --triplet ${{ matrix.triplet }}
- name: Configure (default)
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
@@ -87,7 +116,7 @@ jobs:
if [ "$RUNNER_OS" == "Windows" ]; then
cd pulsar-client-cpp && \
cmake \
- -B ./build \
+ -B ./build-0 \
-G "${{ matrix.generator }}" ${{ matrix.arch }} \
-DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF \
-DVCPKG_TRIPLET=${{ matrix.triplet }} \
@@ -101,7 +130,7 @@ jobs:
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cd pulsar-client-cpp && \
- cmake --build ./build --config Release
+ cmake --build ./build-0 --parallel --config Release
fi
- name: Configure (dynamic library only)
@@ -126,5 +155,5 @@ jobs:
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cd pulsar-client-cpp && \
- cmake --build ./build-1 --config Release
+ cmake --build ./build-1 --parallel --config Release
fi
