regular_conformance.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. name: Run Conformance Tests
  2. # This workflow is a subset of the build.yml. It *only* try to run the
  3. # conformance checks. It is triggered weekly on a cron to catch when new
  4. # conformance tests are added and they don't pass.
  5. #
  6. # Without this workflow the new tests wouldn't be noticed until a PR was made.
  7. #
  8. # This workflow shares the caching logic with build.yml. It should serve to
  9. # update a subset of the caches for when things do land on trunk. If that
  10. # is deemed not worth it in the future, this can be simplify.
  11. # NOTE: If making changes to most of the steps, please also look to update
  12. # build.yml also.
  13. on:
  14. schedule:
  15. # Every Sunday at 5am.
  16. - cron: '0 5 * * 0'
  17. # Also allow manual triggering from the github UX to revalidate things.
  18. workflow_dispatch:
  19. jobs:
  20. build:
  21. runs-on: ubuntu-latest
  22. strategy:
  23. matrix:
  24. # We "float" the bug fix so we pick up new ones. This helps since the GitHub CI
  25. # is set to ensure the actions pass, thus updates are only needed when the
  26. # "major.minor" pairs changes.
  27. #
  28. # Looking at https://hub.docker.com/_/swift, the version only tags (i.e. - 6.1)
  29. # could use different Ubuntu releases. At the moment they are all the "noble",
  30. # which is also what would be desired, so we don't bother listing explicit ones.
  31. swift:
  32. - "6.2"
  33. # protobuf_git can reference a commit, tag, or branch
  34. # commit: "commits/6935eae45c99926a000ecbef0be20dfd3d159e71"
  35. # tag: "ref/tags/v3.11.4"
  36. # branch: "ref/heads/main"
  37. protobuf_git: ["ref/heads/main"]
  38. container:
  39. image: swift:${{ matrix.swift }}
  40. steps:
  41. - name: Checkout
  42. uses: actions/checkout@v4
  43. with:
  44. path: swift-protobuf
  45. - name: Update and install dependencies
  46. # dependencies from https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
  47. # this step is run before get-sha because we need curl and jq for get-sha
  48. run: apt-get update && apt-get install -y curl make g++ cmake jq
  49. - name: Get Protobuf Commit SHA
  50. id: get-sha
  51. run: |
  52. set -eu
  53. url="https://api.github.com/repos/protocolbuffers/protobuf/git/${{ matrix.protobuf_git }}"
  54. case ${{ matrix.protobuf_git }} in
  55. ref/*)
  56. echo "sha=$( curl -s -u "u:${{ github.token }}" "${url}" | jq -r .object.sha )" >> $GITHUB_OUTPUT
  57. ;;
  58. commits/*)
  59. echo "sha=$( curl -s -u "u:${{ github.token }}" "${url}" | jq -r .sha )" >> $GITHUB_OUTPUT
  60. ;;
  61. esac
  62. - name: Cache protobuf
  63. id: cache-protobuf
  64. uses: actions/cache@v4
  65. with:
  66. path: protobuf
  67. # NOTE: for refs that can float like 'main' the cache might be out of date!
  68. key: ${{ runner.os }}-${{ matrix.swift }}-protobuf-${{ steps.get-sha.outputs.sha }}
  69. - name: Checkout protobuf repo
  70. if: steps.cache-protobuf.outputs.cache-hit != 'true'
  71. uses: actions/checkout@v4
  72. with:
  73. repository: protocolbuffers/protobuf
  74. ref: ${{ steps.get-sha.outputs.sha }}
  75. submodules: true
  76. path: protobuf
  77. - name: Build protobuf
  78. if: steps.cache-protobuf.outputs.cache-hit != 'true'
  79. working-directory: protobuf
  80. # https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md#c-version
  81. run: |
  82. mkdir cmake_build
  83. cd cmake_build
  84. cmake \
  85. -DCMAKE_CXX_STANDARD=17 \
  86. -DCMAKE_BUILD_TYPE=Release \
  87. -Dprotobuf_BUILD_TESTS=OFF \
  88. -Dprotobuf_INSTALL=OFF \
  89. -Dprotobuf_BUILD_CONFORMANCE=ON \
  90. -S ..
  91. NUM_CPUS=$(getconf _NPROCESSORS_ONLN)
  92. make -j "${NUM_CPUS}" protoc conformance_test_runner
  93. - name: Test conformance
  94. working-directory: swift-protobuf
  95. run: make test-conformance CONFORMANCE_TEST_RUNNER=../protobuf/cmake_build/conformance_test_runner