Migrate remaining Windows tests to GHA

PiperOrigin-RevId: 506766851
pull/11769/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 1325913afd
commit f1e746c491
  1. 27
      .github/actions/bash/action.yml
  2. 11
      .github/actions/internal/gcloud-auth/action.yml
  3. 104
      .github/workflows/test_cpp.yml
  4. 30
      .github/workflows/test_csharp.yml
  5. 8
      .github/workflows/test_runner.yml
  6. 8
      regenerate_stale_files.sh

@ -0,0 +1,27 @@
name: 'Non-Bazel Bash Run'
description: 'Run a bash script for Protobuf CI testing with a non-Bazel build system'
inputs:
credentials:
required: true
description: "The GCP credentials to use for reading the docker image"
type: string
command:
required: true
description: A command to run in the docker image
runs:
using: 'composite'
steps:
- name: Setup Runner
uses: ./.github/actions/internal/setup-runner
- name: Update stale files using Bazel
uses: ./.github/actions/bazel
with:
credentials: ${{ inputs.credentials }}
bazel-cache: regenerate-stale-files
bash: ./regenerate_stale_files.sh $BAZEL_FLAGS
- name: Run
shell: bash
run: ${{ inputs.command }}

@ -26,16 +26,17 @@ runs:
run: gcloud info
- name: Store credentials path
if: ${{ runner.os != 'Windows' }}
shell: bash
run: echo "credentials-file=${{ steps.auth.outputs.credentials_file_path }}" >> $GITHUB_ENV
- name: Store credentials path (Windows)
run: echo "CREDENTIALS_FILE=${{ steps.auth.outputs.credentials_file_path }}" >> $GITHUB_ENV
- name: Fix credentials path (Windows)
if: ${{ runner.os == 'Windows' }}
# Bash commands in windows don't like the backslash in the file path.
# Assume we're running in the root directory and grab the base name.
shell: bash
run: echo "credentials-file='${{ steps.auth.outputs.credentials_file_path }}'" >> $GITHUB_ENV
run: echo "CREDENTIALS_FILE="$(basename ${CREDENTIALS_FILE//\\//}) >> $GITHUB_ENV
- name: Output credentials file
id: output
shell: bash
run: echo "credentials-file=${{ env.credentials-file }}" >> $GITHUB_OUTPUT
run: echo "credentials-file=${{ env.CREDENTIALS_FILE }}" >> $GITHUB_OUTPUT

@ -50,7 +50,7 @@ jobs:
bazel-cache: cpp_linux/${{ matrix.config.name }}
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }} --distinct_host_configuration=false
cmake:
linux-cmake:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
@ -93,7 +93,6 @@ jobs:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:cc23dbe065668158ca2732aa305a07bd0913a175b2079d27d9c16925d23f2335
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: ${{ matrix.command }}
non-linux:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
@ -118,3 +117,104 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel: test ${{ matrix.bazel }}
bazel-cache: cpp_${{ matrix.os }}
windows-cmake:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
- name: Visual Studio
flags: >-
-Dprotobuf_BUILD_SHARED_LIBS=OFF
-Dprotobuf_BUILD_EXAMPLES=ON
- name: Shared
flags: -Dprotobuf_BUILD_SHARED_LIBS=ON
name: Windows CMake ${{ matrix.name}}
runs-on: windows-2019
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: recursive
ref: ${{ inputs.safe-checkout }}
- name: Setup MSVC
uses: microsoft/setup-msbuild@d3ea839497466fb4c6b91ce85831f3a251a2fe3f # v1.0.0
with:
vs-version: '15'
msbuild-architecture: x64
- name: Configure CMake
uses: ./.github/actions/bash
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
cmake . -G "Visual Studio 16 2019" -A x64 \
-Dprotobuf_BUILD_CONFORMANCE=OFF \
-Dprotobuf_WITH_ZLIB=OFF \
${{ matrix.flags }}
- name: Build for Windows 15 2017
run: >-
msbuild.exe protobuf.sln /maxcpucount:8 /p:BuildInParallel=true
/p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=15.0
- name: Run Tests
run: ctest --verbose -C Debug
windows-cmake-install:
name: Windows CMake Install
runs-on: windows-2019
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: recursive
ref: ${{ inputs.safe-checkout }}
- name: Setup MSVC
uses: microsoft/setup-msbuild@d3ea839497466fb4c6b91ce85831f3a251a2fe3f # v1.0.0
with:
vs-version: '15'
msbuild-architecture: x64
- name: Configure CMake for Install
uses: ./.github/actions/bash
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
mkdir build
pushd build
cmake .. -G "Visual Studio 16 2019" -A x64 \
-Dprotobuf_BUILD_CONFORMANCE=OFF \
-Dprotobuf_WITH_ZLIB=OFF
popd
- name: Build and Install Protobuf for Windows 15 2017
run: |
pushd build
msbuild.exe INSTALL.vcxproj /p:Platform=x64 /p:VisualStudioVersion=15.0 /maxcpucount:8 /p:BuildInParallel=true
popd
- name: Clear CMake cache
shell: bash
run: rm -rf build/*
- name: Configure CMake
uses: ./.github/actions/bash
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: |
cmake . -G "Visual Studio 16 2019" -A x64 \
-Dprotobuf_REMOVE_INSTALLED_HEADERS=ON \
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF \
-Dprotobuf_BUILD_CONFORMANCE=OFF
- name: Build for Windows 15 2017
run: >-
msbuild.exe protobuf.sln /maxcpucount:8 /p:BuildInParallel=true
/p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=15.0
- name: Run Tests
run: ctest --verbose -C Debug

@ -0,0 +1,30 @@
name: C# Tests
on:
workflow_call:
inputs:
safe-checkout:
required: true
description: "The SHA key for the commit we want to run over"
type: string
jobs:
windows:
name: Windows
runs-on: windows-2019
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
- name: Setup dotnet
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: '6.0.x'
- name: Build
run: dotnet build csharp/src/Google.Protobuf.sln
- name: Run Tests
run: dotnet test csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj

@ -129,6 +129,14 @@ jobs:
safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }}
secrets: inherit
csharp:
name: C#
needs: [check-tag]
uses: ./.github/workflows/test_csharp.yml
with:
safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }}
secrets: inherit
objectivec:
name: Objective-c
needs: [check-tag]

@ -8,15 +8,17 @@ set -ex
# Cd to the repo root.
cd $(dirname -- "$0")
readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}"
# Run and fix all staleness tests.
# LINT.IfChange(staleness_tests)
bazel test //src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix
bazel test //src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
${BazelBin} test src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix
${BazelBin} test src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
# LINT.ThenChange(//depot/google3/third_party/protobuf/github/kokoro/windows/prepare_build_win64.bat:staleness_tests)
# Generate C# code.
# This doesn't currently have Bazel staleness tests, but there's an existing
# shell script that generates everything required. The output files are stable,
# so just regenerating in place should be harmless.
bazel build src/google/protobuf/compiler:protoc "$@"
${BazelBin} build src/google/protobuf/compiler:protoc "$@"
(export PROTOC=$PWD/bazel-bin/protoc && cd csharp && ./generate_protos.sh)

Loading…
Cancel
Save