Skip to content

Commit

Permalink
Print install manifest after cmake installation
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 699324233
  • Loading branch information
mkruskal-google authored and copybara-github committed Nov 23, 2024
1 parent a02ec0f commit 5745fbf
Show file tree
Hide file tree
Showing 6 changed files with 516 additions and 4 deletions.
69 changes: 65 additions & 4 deletions .github/workflows/test_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,18 @@ jobs:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
type: [package, fetch]
type: [package, static, fetch]
include:
# Set defaults
- type: package
name: Install
flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON
flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON -Dprotobuf_BUILD_SHARED_LIBS=ON
- type: static
name: Install (static)
flags: -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF
- type: fetch
name: Install (Fetch)
flags: -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON
flags: -Dprotobuf_FORCE_FETCH_DEPENDENCIES=ON -Dprotobuf_BUILD_SHARED_LIBS=ON
continuous-only: true
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }}Linux CMake ${{ matrix.name }}
runs-on: ubuntu-latest
Expand All @@ -220,7 +223,9 @@ jobs:
command: >-
/install.sh -DCMAKE_CXX_STANDARD=17 ${{ env.SCCACHE_CMAKE_FLAGS }}
${{ matrix.flags }}
-Dprotobuf_BUILD_SHARED_LIBS=ON \&\&
\&\&
cp build/install_manifest.txt .
\&\&
/test.sh
${{ env.SCCACHE_CMAKE_FLAGS }}
-Dprotobuf_REMOVE_INSTALLED_HEADERS=ON
Expand All @@ -229,6 +234,62 @@ jobs:
-DCMAKE_CXX_STANDARD=17
${{ matrix.flags }}
- name: Clean up install manifest
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
run: |
mkdir manifest
cat install_manifest.txt | sort | sed 's:/usr/local/::g' > manifest/all.txt
cat manifest/all.txt | grep -e '^include/' > manifest/include.txt
cat manifest/all.txt | grep -e '^bin/' > manifest/bin.txt
cat manifest/all.txt | grep -e '^lib/' > manifest/lib.txt
- name: Upload install manifest
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
name: installed_files_${{ matrix.type }}
# Tests shouldn't have access to the whole upb repo, upload the one file we need
path: manifest/*.txt

install-manifests:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
type: [include, bin, lib]
build: [static, package]
include:
- type: lib
build: static
golden: 'static_lib'
- type: lib
build: package
golden: 'shared_lib'
name: Check Installed Files
needs: linux-cmake-install
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: protocolbuffers/protobuf-ci/checkout@v3
with:
ref: ${{ inputs.safe-checkout }}

- name: Download manifest
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 #4.1.8
with:
name: installed_files_${{ matrix.build }}
path: ${{ matrix.build }}

- name: Compare against golden
run: |
DIFF="$(diff -u cmake/installed_${{ matrix.golden || matrix.type }}.txt ${{ matrix.build }}/${{ matrix.type }}.txt)"
if [ -n "$DIFF" ]; then
echo "Installed files do not match goldens!"
echo "$DIFF"
exit 1
else
echo "Installed files match goldens."
fi
# This test should always be skipped on presubmit
linux-cmake-examples:
name: ${{ inputs.continuous-prefix }} Linux CMake Examples
Expand Down
4 changes: 4 additions & 0 deletions cmake/installed_bin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
protoc
protoc-gen-upb
protoc-gen-upbdefs
protoc-gen-upb_minitable
24 changes: 24 additions & 0 deletions cmake/installed_file_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

check_golden() {
DIR=$1
TYPE=$2
echo "Checking $DIR/$TYPE.txt against cmake/installed_$TYPE.txt"
DIFF="$(diff -u cmake/installed_${TYPE}.txt $DIR/$TYPE.txt)"
if [ -n "$DIFF" ]; then
echo "Installed files do not match goldens!"
echo "$DIFF"
exit 1
else
echo "Installed files match goldens."
fi
}

check_golden "static/include.txt" "include"
check_golden "shared/include.txt" "include"
check_golden "static/bin.txt" "bin"
check_golden "shared/bin.txt" "bin"
check_golden "static/lib.txt" "static_lib"
check_golden "shared/lib.txt" "shared_lib"
Loading

0 comments on commit 5745fbf

Please sign in to comment.