ci.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. name: GitHub Actions CI
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. jobs:
  8. build:
  9. name: ${{ matrix.config.name }}
  10. runs-on: ${{ matrix.config.os }}
  11. container: ${{ matrix.config.container }}
  12. strategy:
  13. fail-fast: false
  14. matrix:
  15. config:
  16. - {name: 'ubuntu-14.04 gcc-4.8', os: ubuntu-latest, container: 'ubuntu:14.04', cc: 'gcc-4.8', cxx: 'g++-4.8', tag: '4.8', toolchain: 'ppa:ubuntu-toolchain-r/test'}
  17. - {name: 'ubuntu-14.04 gcc-4.9', os: ubuntu-latest, container: 'ubuntu:14.04', cc: 'gcc-4.9', cxx: 'g++-4.9', tag: '4.9', toolchain: 'ppa:ubuntu-toolchain-r/test'}
  18. - {name: 'ubuntu-18.04 gcc-5', os: ubuntu-latest, container: 'ubuntu:18.04', cc: 'gcc-5', cxx: 'g++-5', tag: '5'}
  19. - {name: 'ubuntu-18.04 gcc-6', os: ubuntu-latest, container: 'ubuntu:18.04', cc: 'gcc-6', cxx: 'g++-6', tag: '6'}
  20. - {name: 'ubuntu-18.04 gcc-7', os: ubuntu-latest, container: 'ubuntu:18.04', cc: 'gcc-7', cxx: 'g++-7', tag: '7'}
  21. - {name: 'ubuntu-18.04 gcc-8', os: ubuntu-latest, container: 'ubuntu:18.04', cc: 'gcc-8', cxx: 'g++-8', tag: '8'}
  22. - {name: 'ubuntu-20.04 gcc-9', os: ubuntu-20.04, cc: 'gcc-9', cxx: 'g++-9', tag: '9'}
  23. - {name: 'ubuntu-20.04 gcc-10', os: ubuntu-20.04, cc: 'gcc-10', cxx: 'g++-10', tag: '10'}
  24. - {name: 'ubuntu-20.04 gcc-11', os: ubuntu-20.04, cc: 'gcc-11', cxx: 'g++-11', tag: '11'}
  25. - {name: 'ubuntu-22.04 gcc-12', os: ubuntu-22.04, cc: 'gcc-12', cxx: 'g++-12', tag: '12'}
  26. env:
  27. CC: ${{ matrix.config.cc }}
  28. CXX: ${{ matrix.config.cxx }}
  29. CCVERSION: ${{ matrix.config.tag }}
  30. GHA_CONTAINER: ${{ matrix.config.container }}
  31. GHA_CONFIG_NAME: ${{ matrix.config.name }}
  32. steps:
  33. - name: if running in a container, update and install sudo, git, and other basics
  34. if: matrix.config.container != ''
  35. run: |
  36. case "${GHA_CONTAINER}" in
  37. ubuntu*)
  38. apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y install tzdata sudo apt-transport-https make apt-file software-properties-common libssl-dev build-essential autotools-dev autoconf automake pkgconf iproute2
  39. sudo apt-add-repository ppa:git-core/ppa
  40. sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
  41. ;;
  42. *)
  43. ;;
  44. esac
  45. - name: override DNS to fix IP address for hostname in some Docker containers
  46. if: matrix.config.container != ''
  47. run: |
  48. case "${GHA_CONTAINER}" in
  49. ubuntu*)
  50. echo "==="
  51. echo "Before: /etc/hosts"
  52. cat /etc/hosts
  53. echo "==="
  54. echo "Removing localhost name from ::1 entry in /etc/hosts..."
  55. sed 's/^::1\s\s*localhost\s\(.*\)/::1 \1/' /etc/hosts > /tmp/hosts.temp
  56. cp /tmp/hosts.temp /etc/hosts
  57. rm /tmp/hosts.temp
  58. echo "After: /etc/hosts"
  59. cat /etc/hosts
  60. echo "==="
  61. ip addr
  62. echo "==="
  63. echo "'hostname -i' shows '$(hostname -i)'"
  64. echo "'hostname -I' shows '$(hostname -I)'"
  65. echo "'hostname -s' shows '$(hostname -s)'"
  66. echo "'hostname -f' shows '$(hostname -f)'"
  67. ;;
  68. *)
  69. ;;
  70. esac
  71. - name: configure toolchain (optional)
  72. if: matrix.config.toolchain != ''
  73. run: |
  74. sudo apt-add-repository ${{ matrix.config.toolchain }}
  75. sudo apt-get update
  76. sudo apt-get -y install libtool
  77. - uses: actions/checkout@v3
  78. - name: set ownership of git repository in Docker containers
  79. if: matrix.config.container != ''
  80. run: |
  81. chown -R $(id -u):$(id -g) .
  82. - name: tweak multi_client_test.cc for container usage
  83. if: matrix.config.container != ''
  84. run: |
  85. case "${GHA_CONTAINER}" in
  86. ubuntu*)
  87. echo "==="
  88. echo "Before multi_client_test.cc:"
  89. grep push_port tests/libgearman-1.0/multi_client_test.cc
  90. echo "Changing multi_client_test.cc..."
  91. sed -i -e '0,/test->push_port.*libtest/ s/\(test.*push_port(\).*libtest.*\();\)/\1 19298 \2/' tests/libgearman-1.0/multi_client_test.cc
  92. sed -i -e '0,/test->push_port.*libtest/ s/\(test.*push_port(\).*libtest.*\();\)/\1 19300 \2/' tests/libgearman-1.0/multi_client_test.cc
  93. echo "After multi_client_test.cc:"
  94. grep push_port tests/libgearman-1.0/multi_client_test.cc
  95. echo "==="
  96. ;;
  97. *)
  98. ;;
  99. esac
  100. - name: install dependencies
  101. run: |
  102. case "${GHA_CONFIG_NAME}" in
  103. ubuntu*)
  104. sudo apt-get update && sudo apt-get -o Acquire::Retries=3 install -y libboost-all-dev gperf libevent-dev uuid-dev sphinx-doc sphinx-common libhiredis-dev ${{ matrix.config.cc }} ${{ matrix.config.cxx }}
  105. ;;
  106. *)
  107. ;;
  108. esac
  109. - name: bootstrap
  110. run: |
  111. if [ -n "$GHA_CONTAINER" ]; then
  112. echo "container: $GHA_CONTAINER"
  113. fi
  114. if [ -f "/etc/lsb-release" ]; then
  115. cat /etc/lsb-release
  116. fi
  117. ./bootstrap.sh -a
  118. - name: configure
  119. run: |
  120. if [[ "${CC}" == gcc* ]] && [ "${CCVERSION}" -ge 9 ]; then
  121. CXXFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS"
  122. export CXXFLAGS
  123. echo "CXXFLAGS: $CXXFLAGS"
  124. fi
  125. ./configure --enable-ssl
  126. shell: bash
  127. - name: make
  128. run: |
  129. if [[ "${CC}" == gcc* ]] && [ "${CCVERSION}" -ge 9 ]; then
  130. CXXFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS"
  131. export CXXFLAGS
  132. echo "CXXFLAGS: $CXXFLAGS"
  133. fi
  134. ${CC} --version && make
  135. shell: bash
  136. - name: make test
  137. run: ${CC} --version && make test
  138. - name: check test-suite.log
  139. if: success() || failure()
  140. run: |
  141. if [ -f "./test-suite.log" ]; then
  142. cat ./test-suite.log
  143. else
  144. echo "No test-suite.log file found."
  145. fi