From d693951067cb4505a77c53efccf37a9015d710cf Mon Sep 17 00:00:00 2001 From: Brad House Date: Thu, 1 Aug 2024 15:56:47 -0400 Subject: [PATCH] CI: Move more to GitHub actions including Containers (#842) GitHub actions supports running tests on various docker containers, move Ubuntu 20.04 and Alpine tests to containers. Also move iOS testing to GitHub actions since that runs on MacOS which is supported. This should take additional load off of Cirrus-CI which consumes credits like crazy. This leaves only FreeBSD and Linux ARM testing on Cirrus-CI. Authored-By: Brad House (@bradh352) --- .cirrus.yml | 61 ----------- .github/workflows/alpine-latest.yml | 96 +++++++++++++++++ .github/workflows/codespell.yml | 5 + .github/workflows/coverity.yml | 6 ++ .github/workflows/djgpp.yml | 5 + .github/workflows/ios.yml | 45 ++++++++ .github/workflows/netbsd.yml | 5 + .github/workflows/openbsd.yml | 6 +- .github/workflows/reuse.yml | 1 + .github/workflows/solaris.yml | 4 + .github/workflows/sonarcloud.yml | 7 +- .github/workflows/ubuntu-2004.yml | 100 ++++++++++++++++++ .../{ubuntu.yml => ubuntu-latest.yml} | 3 + .github/workflows/watcom.yml | 5 + .github/workflows/watt32.yml | 5 + test/ares-test-mock-et.cc | 4 +- 16 files changed, 292 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/alpine-latest.yml create mode 100644 .github/workflows/ios.yml create mode 100644 .github/workflows/ubuntu-2004.yml rename .github/workflows/{ubuntu.yml => ubuntu-latest.yml} (98%) diff --git a/.cirrus.yml b/.cirrus.yml index f0c81ff264..fe60090dcd 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,28 +8,6 @@ env: task: matrix: - - name: "Alpine amd64" - env: - DIST: "ALPINE" - LC_ALL: "C" - SCAN_BUILD: "scan-build" - MAKE: "make" - BUILD_ASAN: "yes" - BUILD_UBSAN: "yes" - BUILD_VALGRIND: "yes" - BUILD_ANALYZE: "yes" - TEST_DEBUGGER: "gdb" - TEST_SYMBOL_VISIBILITY: "yes" - container: - image: alpine:latest - - name: "Ubuntu OLD amd64" - env: - DIST: "UBUNTU" - LC_ALL: "C" - MAKE: "make" - TEST_DEBUGGER: "gdb" - container: - image: ubuntu:20.04 - name: "Debian arm64" env: DIST: "DEBIAN-ARM" @@ -58,16 +36,6 @@ task: TEST_SYMBOL_VISIBILITY: "yes" freebsd_instance: image_family: freebsd-14-1 - - name: "iOS" - env: - DIST: "iOS" - MAKE: "make" - CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 -DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64 -G Ninja" - CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=OFF" - CFLAGS: "-arch armv7 -arch armv7s -arch arm64 -miphoneos-version-min=10.0" - CONFIG_OPTS: "--host=arm-apple-darwin10 --disable-tests" - macos_instance: - image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest matrix: - name: "CMAKE" env: @@ -118,23 +86,6 @@ task: install_script: - | case "${DIST}" in - ALPINE) - apk add bash cmake samurai gtest-dev autoconf autoconf-archive automake libtool pkgconf make - case "${BUILD_TYPE}" in - asan|lsan|ubsan) - apk add clang17 compiler-rt lldb - ;; - analyze) - apk add clang17 clang17-analyzer compiler-rt lldb - ;; - valgrind) - apk add gcc g++ valgrind - ;; - *) - apk add gcc g++ gdb - ;; - esac - ;; UBUNTU|DEBIAN*) export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ @@ -167,18 +118,6 @@ task: ;; esac ;; - MACOS|iOS) - brew update - brew install ninja cmake googletest - case "${BUILD_TYPE}" in - asan|ubsan|lsan|analyze) - brew install llvm autoconf automake libtool make ninja - ;; - autotools) - brew install autoconf automake libtool make - ;; - esac - ;; esac script: diff --git a/.github/workflows/alpine-latest.yml b/.github/workflows/alpine-latest.yml new file mode 100644 index 0000000000..916c8d4b91 --- /dev/null +++ b/.github/workflows/alpine-latest.yml @@ -0,0 +1,96 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: Alpine (latest) +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-alpine-latest + cancel-in-progress: true + +env: + TEST_FILTER: "--gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*" + CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -G Ninja" + MAKE: make + +jobs: + build: + runs-on: ubuntu-latest + container: + image: alpine:latest +# Needed for TCP FastOpen + options: --privileged + name: "Alpine (latest)" + steps: + - name: Install packages + run: | + apk add bash cmake samurai gtest-dev autoconf autoconf-archive automake libtool pkgconf make clang17 clang17-analyzer compiler-rt lldb gcc g++ valgrind gdb sudo + - name: Checkout c-ares + uses: actions/checkout@v4 + - name: "Make sure TCP FastOpen is enabled" + run: | + sudo sysctl -w net.ipv4.tcp_fastopen=3 + - name: "CMake: build and test c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + TEST_DEBUGGER: gdb + run: | + ./ci/build.sh + ./ci/test.sh + - name: "Autotools: build and test c-ares" + env: + BUILD_TYPE: autotools + TEST_DEBUGGER: gdb + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: UBSAN: build and test c-ares" + env: + BUILD_TYPE: "ubsan" + CC: "clang" + CXX: "clang++" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + CFLAGS: "-fsanitize=undefined -fno-sanitize-recover" + CXXFLAGS: "-fsanitize=undefined -fno-sanitize-recover" + LDFLAGS: "-fsanitize=undefined" + TEST_DEBUGGER: "none" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: ASAN: build and test c-ares" + env: + BUILD_TYPE: "asan" + CC: "clang" + CXX: "clang++" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + CFLAGS: "-fsanitize=address" + CXXFLAGS: "-fsanitize=address" + LDFLAGS: "-fsanitize=address" + TEST_DEBUGGER: "none" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: Static Analyzer: build c-ares" + env: + BUILD_TYPE: "analyze" + CC: "clang" + CXX: "clang++" + SCAN_WRAP: "scan-build -v --status-bugs" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=OFF" + TEST_DEBUGGER: "lldb" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "Valgrind: build and test c-ares (no TCP FastOpen)" + env: + BUILD_TYPE: "valgrind" + TEST_WRAP: "valgrind --leak-check=full" + TEST_FILTER: "--gtest_filter=-*Container*:*LiveSearchANY*:*LiveSearchTXT*" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + TEST_DEBUGGER: none + run: | + sudo sysctl -w net.ipv4.tcp_fastopen=0 + ./ci/build.sh + ./ci/test.sh diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index fc3d87a1ff..0cb74f5b73 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -14,9 +14,14 @@ on: - 'src/**' - 'include/**' +concurrency: + group: ${{ github.ref }}-codespell + cancel-in-progress: true + jobs: codespell: runs-on: ubuntu-latest + name: Codespell steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 51e38b638e..2351850b47 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -7,9 +7,15 @@ on: push: branches: [ coverity_scan ] workflow_dispatch: + +concurrency: + group: ${{ github.ref }}-coverity + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest + name: Coverity steps: - name: Checkout Source uses: actions/checkout@v4 diff --git a/.github/workflows/djgpp.yml b/.github/workflows/djgpp.yml index cbed2ac02e..838948c9aa 100644 --- a/.github/workflows/djgpp.yml +++ b/.github/workflows/djgpp.yml @@ -5,9 +5,14 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-djgpp + cancel-in-progress: true + jobs: build: runs-on: windows-latest + name: DJGPP steps: - name: Install GNU Make run: | diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 0000000000..128644f9a0 --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,45 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: iOS +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-ios + cancel-in-progress: true + +env: + DIST: "iOS" + MAKE: "make" + CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=10.0 -DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64 -G Ninja" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=OFF" + +jobs: + build: + runs-on: macos-latest + name: "iOS" + steps: + - name: Install packages + run: brew install cmake googletest llvm autoconf automake libtool make ninja + - name: Checkout c-ares + uses: actions/checkout@v4 + - name: "CMake: build and test c-ares" + env: + BUILD_TYPE: CMAKE + run: | + ./ci/build.sh + - name: "Autotools: build and test c-ares" + env: + BUILD_TYPE: autotools + CFLAGS: "-arch armv7 -arch armv7s -arch arm64 -miphoneos-version-min=10.0" + CONFIG_OPTS: "--host=arm-apple-darwin10 --disable-tests" + run: | + ./ci/build.sh + - name: "Cmake: Static Analyzer: build c-ares" + env: + BUILD_TYPE: "analyze" + CC: "clang" + SCAN_WRAP: "/opt/homebrew/opt/llvm/bin/scan-build-py -v --status-bugs" + run: | + ./ci/build.sh diff --git a/.github/workflows/netbsd.yml b/.github/workflows/netbsd.yml index 0739605c08..e67fc17bc6 100644 --- a/.github/workflows/netbsd.yml +++ b/.github/workflows/netbsd.yml @@ -6,9 +6,14 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-netbsd + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest + name: NetBSD steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index d5c9b899b4..c16d5e2dca 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -5,12 +5,16 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-openbsd + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest + name: OpenBSD steps: - uses: actions/checkout@v4 - - name: Test uses: cross-platform-actions/action@v0.24.0 env: diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 69786121af..adf81952d0 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -17,6 +17,7 @@ permissions: {} jobs: check: runs-on: ubuntu-latest + name: REUSE compliance steps: - uses: actions/checkout@v4 - name: REUSE Compliance Check diff --git a/.github/workflows/solaris.yml b/.github/workflows/solaris.yml index 77d5a9d859..3afee653e6 100644 --- a/.github/workflows/solaris.yml +++ b/.github/workflows/solaris.yml @@ -6,6 +6,10 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-solaris + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1c296e045a..2ed160678b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -7,12 +7,17 @@ on: - main # pull_request: # types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.ref }}-sonarcloud + cancel-in-progress: true + jobs: build: - name: Build and analyze runs-on: ubuntu-latest env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + name: "SonarCloud: Build and analyze" steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/ubuntu-2004.yml b/.github/workflows/ubuntu-2004.yml new file mode 100644 index 0000000000..171afd2ffa --- /dev/null +++ b/.github/workflows/ubuntu-2004.yml @@ -0,0 +1,100 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: Ubuntu 20.04 +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-ubuntu-2004 + cancel-in-progress: true + +env: + TEST_FILTER: "--gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*" + CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -G Ninja" + MAKE: make + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ubuntu:20.04 +# Needed for TCP FastOpen + options: --privileged + name: "Ubuntu 20.04" + steps: + - name: Install packages + env: + DEBIAN_FRONTEND: noninteractive + run: | + apt-get update + apt-get dist-upgrade -y --assume-yes + apt-get install -y --assume-yes sudo curl wget cmake ninja-build autoconf automake libtool g++ libgmock-dev pkg-config clang clang-tools lldb gdb valgrind + - name: Checkout c-ares + uses: actions/checkout@v4 + - name: "Make sure TCP FastOpen is enabled" + run: | + sudo sysctl -w net.ipv4.tcp_fastopen=3 + - name: "CMake: build and test c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + TEST_DEBUGGER: gdb + run: | + ./ci/build.sh + ./ci/test.sh + - name: "Autotools: build and test c-ares" + env: + BUILD_TYPE: autotools + TEST_DEBUGGER: gdb + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: UBSAN: build and test c-ares" + env: + BUILD_TYPE: "ubsan" + CC: "clang" + CXX: "clang++" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + CFLAGS: "-fsanitize=undefined -fno-sanitize-recover" + CXXFLAGS: "-fsanitize=undefined -fno-sanitize-recover" + LDFLAGS: "-fsanitize=undefined" + TEST_DEBUGGER: "none" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: ASAN: build and test c-ares" + env: + BUILD_TYPE: "asan" + CC: "clang" + CXX: "clang++" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + CFLAGS: "-fsanitize=address" + CXXFLAGS: "-fsanitize=address" + LDFLAGS: "-fsanitize=address" + TEST_DEBUGGER: "none" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "CMake: Static Analyzer: build c-ares" + env: + BUILD_TYPE: "analyze" + CC: "clang" + CXX: "clang++" + SCAN_WRAP: "scan-build -v --status-bugs" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=OFF" + TEST_DEBUGGER: "lldb" + run: | + ./ci/build.sh + ./ci/test.sh + - name: "Valgrind: build and test c-ares (no TCP FastOpen)" + env: + BUILD_TYPE: "valgrind" + TEST_WRAP: "valgrind --leak-check=full" + TEST_FILTER: "--gtest_filter=-*Container*:*LiveSearchANY*:*LiveSearchTXT*" + CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" + TEST_DEBUGGER: none + run: | + sudo sysctl -w net.ipv4.tcp_fastopen=0 + ./ci/build.sh + ./ci/test.sh diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu-latest.yml similarity index 98% rename from .github/workflows/ubuntu.yml rename to .github/workflows/ubuntu-latest.yml index 898fd47742..ac9a09c19c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -67,6 +67,7 @@ jobs: env: BUILD_TYPE: "ubsan" CC: "clang" + CXX: "clang++" CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" CFLAGS: "-fsanitize=undefined -fno-sanitize-recover" CXXFLAGS: "-fsanitize=undefined -fno-sanitize-recover" @@ -79,6 +80,7 @@ jobs: env: BUILD_TYPE: "asan" CC: "clang" + CXX: "clang++" CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=ON" CFLAGS: "-fsanitize=address" CXXFLAGS: "-fsanitize=address" @@ -91,6 +93,7 @@ jobs: env: BUILD_TYPE: "analyze" CC: "clang" + CXX: "clang++" SCAN_WRAP: "scan-build -v --status-bugs" CMAKE_TEST_FLAGS: "-DCARES_BUILD_TESTS=OFF" TEST_DEBUGGER: "lldb" diff --git a/.github/workflows/watcom.yml b/.github/workflows/watcom.yml index f050aa45f5..4f365fee3d 100644 --- a/.github/workflows/watcom.yml +++ b/.github/workflows/watcom.yml @@ -5,9 +5,14 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-openwatcom + cancel-in-progress: true + jobs: build: runs-on: windows-latest + name: OpenWatcom steps: - uses: open-watcom/setup-watcom@v0 - name: Checkout Source diff --git a/.github/workflows/watt32.yml b/.github/workflows/watt32.yml index 82b2f63fd7..5f482fcbd0 100644 --- a/.github/workflows/watt32.yml +++ b/.github/workflows/watt32.yml @@ -5,9 +5,14 @@ on: push: pull_request: +concurrency: + group: ${{ github.ref }}-watt32 + cancel-in-progress: true + jobs: build: runs-on: windows-latest + name: WATT32 env: WATT_ROOT: "${{ github.workspace }}\\watt-32" steps: diff --git a/test/ares-test-mock-et.cc b/test/ares-test-mock-et.cc index d50d444117..1ee15c4379 100644 --- a/test/ares-test-mock-et.cc +++ b/test/ares-test-mock-et.cc @@ -1421,10 +1421,8 @@ TEST_P(NoRotateMultiMockEventThreadTest, ServerNoResponseFailover) { * system. Its possible we could set a realtime priority on a thread to * help with this, but for now, just increase the delay */ # define SERVER_FAILOVER_RETRY_DELAY 750 -#elif defined(_WIN32) -# define SERVER_FAILOVER_RETRY_DELAY 500 #else -# define SERVER_FAILOVER_RETRY_DELAY 250 +# define SERVER_FAILOVER_RETRY_DELAY 500 #endif class ServerFailoverOptsMockEventThreadTest : public MockMultiServerEventThreadTest { public: