From 6049b67f1e1cf00da8e0e913b8adc81a7b16bb87 Mon Sep 17 00:00:00 2001 From: Kirill Isakov Date: Thu, 31 Mar 2022 21:19:59 +0600 Subject: [PATCH] Adjust CI to new integration tests --- .ci/build.sh | 7 ++++-- .ci/cross/msvc/arm64 | 11 +++++++++ .ci/deps.sh | 18 ++++++++------ .ci/package/deb/debian/preinst | 30 +++++++++++------------ .ci/test/run.sh | 14 ++++++++--- .ci/tidy/run.sh | 2 +- .ci/warn/run.sh | 2 +- .ci/windows/build.cmd | 8 +++++- .ci/windows/test.cmd | 26 ++++---------------- .github/workflows/test.yml | 45 ++++++++++++++++------------------ 10 files changed, 86 insertions(+), 77 deletions(-) create mode 100644 .ci/cross/msvc/arm64 diff --git a/.ci/build.sh b/.ci/build.sh index 7be77ce3..e7ca4e11 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -2,9 +2,12 @@ set -eux +dir="$1" +shift + flags=$(./.ci/conf.sh "$@") # shellcheck disable=SC2086 -meson setup build $flags +meson setup "$dir" $flags -ninja -C build +ninja -C "$dir" diff --git a/.ci/cross/msvc/arm64 b/.ci/cross/msvc/arm64 new file mode 100644 index 00000000..187c74ab --- /dev/null +++ b/.ci/cross/msvc/arm64 @@ -0,0 +1,11 @@ +[host_machine] +system = 'windows' +cpu_family = 'aarch64' +cpu = 'armv8' +endian = 'little' + +[binaries] +c = 'cl' +cpp = 'cl' +ar = 'lib' +windres = 'rc' diff --git a/.ci/deps.sh b/.ci/deps.sh index b29ee12a..c33016ad 100755 --- a/.ci/deps.sh +++ b/.ci/deps.sh @@ -6,8 +6,7 @@ deps_linux_alpine() { apk upgrade apk add \ - git binutils meson pkgconf gcc linux-headers diffutils \ - procps socat shadow sudo libgcrypt-dev texinfo gzip \ + git binutils meson pkgconf gcc linux-headers shadow sudo libgcrypt-dev texinfo gzip \ openssl-dev zlib-dev lzo-dev ncurses-dev readline-dev musl-dev lz4-dev vde2-dev cmocka-dev } @@ -52,8 +51,7 @@ deps_linux_debian() { apt-get update apt-get upgrade -y - apt-get install -y git pkgconf diffutils sudo texinfo \ - netcat-openbsd procps socat + apt-get install -y git pkgconf sudo texinfo HOST=${HOST:-} if [ "$HOST" = mingw ]; then @@ -88,8 +86,8 @@ deps_linux_rhel() { yum upgrade -y yum install -y \ - git binutils make meson pkgconf gcc diffutils sudo texinfo-tex netcat procps systemd perl-IPC-Cmd \ - findutils socat lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@" + git binutils make meson pkgconf gcc sudo texinfo-tex systemd perl-IPC-Cmd \ + lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@" if yum info openssl11-devel; then yum install -y openssl11-devel @@ -103,6 +101,11 @@ deps_linux_rhel() { } linux_openssl3() { + if [ -n "${SKIP_OPENSSL3:-}" ]; then + echo >&2 "skipping openssl3 installation in this job" + return + fi + src=/usr/local/src/openssl ssl3=/opt/ssl3 @@ -147,8 +150,7 @@ deps_linux() { } deps_macos() { - brew install coreutils netcat lzo lz4 miniupnpc libgcrypt openssl meson "$@" - pip3 install --user compiledb + brew install lzo lz4 miniupnpc libgcrypt openssl meson "$@" } case "$(uname -s)" in diff --git a/.ci/package/deb/debian/preinst b/.ci/package/deb/debian/preinst index 030c1d0b..63a57f57 100644 --- a/.ci/package/deb/debian/preinst +++ b/.ci/package/deb/debian/preinst @@ -7,22 +7,22 @@ WANTS="/etc/systemd/system/multi-user.target.wants" set -e case "$1" in - upgrade) - if dpkg --compare-versions "$2" '<<' "1.1~pre11-1"; then - if [ -f "$NETSFILE" ]; then - echo -n "Creating systemd service instances from nets.boot:" - mkdir -p "$WANTS" - egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do - echo -n " $net" - ln -s "$SYSTEM/tinc@.service" "$WANTS/tinc@$net.service" 2>/dev/null || true - done - echo "." - fi - fi - ;; +upgrade) + if dpkg --compare-versions "$2" '<<' "1.1~pre11-1"; then + if [ -f "$NETSFILE" ]; then + echo -n "Creating systemd service instances from nets.boot:" + mkdir -p "$WANTS" + egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do + echo -n " $net" + ln -s "$SYSTEM/tinc@.service" "$WANTS/tinc@$net.service" 2>/dev/null || true + done + echo "." + fi + fi + ;; + +*) ;; - *) - ;; esac #DEBHELPER# diff --git a/.ci/test/run.sh b/.ci/test/run.sh index fa23e241..3d0d6716 100644 --- a/.ci/test/run.sh +++ b/.ci/test/run.sh @@ -24,24 +24,30 @@ run_tests() { sudo pkill -KILL -x "$name" || true done - sudo git clean -dfx sudo chown -R "${USER:-$(whoami)}" . mkdir -p sanitizer /tmp/logs header "Running test flavor $flavor" - ./.ci/build.sh "$@" + ./.ci/build.sh "$flavor" "$@" if [ "${HOST:-}" = mingw ]; then echo >&2 "Integration tests cannot run under wine, skipping" return 0 fi + if [ -n "${HOST:-}" ]; then + echo >&2 "Using higher test timeout for cross-compilation job $HOST" + timeout=10 + else + timeout=1 + fi + code=0 - meson test -C build --verbose || code=$? + meson test -C "$flavor" --timeout-multiplier $timeout --verbose || code=$? - sudo tar -c -z -f "/tmp/logs/tests.$flavor.tar.gz" build/ sanitizer/ + sudo tar -c -z -f "/tmp/logs/tests.$flavor.tar.gz" "$flavor" sanitizer/ || true return $code } diff --git a/.ci/tidy/run.sh b/.ci/tidy/run.sh index bb975868..cf055568 100755 --- a/.ci/tidy/run.sh +++ b/.ci/tidy/run.sh @@ -2,7 +2,7 @@ set -eu -./.ci/build.sh "$@" +./.ci/build.sh build "$@" # Which paths to ignore. paths='src/solaris src/windows src/gcrypt' diff --git a/.ci/warn/run.sh b/.ci/warn/run.sh index a4b3d9dc..b84bc2ec 100755 --- a/.ci/warn/run.sh +++ b/.ci/warn/run.sh @@ -8,7 +8,7 @@ result=0 check_warnings() { git clean -dfx - ./.ci/build.sh -Dwerror=true "$@" || result=$? + ./.ci/build.sh build -Dwerror=true "$@" || result=$? } check_warnings diff --git a/.ci/windows/build.cmd b/.ci/windows/build.cmd index 6cafcac7..873971ec 100644 --- a/.ci/windows/build.cmd +++ b/.ci/windows/build.cmd @@ -1,8 +1,14 @@ set crypto=%1 set builddir=%crypto% +set args= +set crossfile=.ci\cross\msvc\%HOST_ARCH% + +if exist %crossfile% ( + set args=--cross-file %crossfile% +) echo configure build directory -meson setup %builddir% -Dbuildtype=release -Dcrypto=%crypto% || exit 1 +meson setup %builddir% -Dbuildtype=release -Dcrypto=%crypto% %args% || exit 1 echo build project meson compile -C %builddir% || exit 1 diff --git a/.ci/windows/test.cmd b/.ci/windows/test.cmd index 042740aa..211a2190 100644 --- a/.ci/windows/test.cmd +++ b/.ci/windows/test.cmd @@ -1,24 +1,8 @@ set builddir=%1 -set data=%builddir%\test-data -set tinc=%builddir%\src\tinc -set tincd=%tinc%d -mkdir %data% || exit 1 +REM Windows jobs on GitHub CI sometimes show surprisingly poor performance +REM (building tinc with default flags can take from 3 to upwards of 20+ +REM minutes, depending on which machine you happened to land on), so timeout +REM is set a bit higher here. -echo can tinc run at all? -%tinc% --version || exit 1 - -echo try to initialize a node -%tinc% -c %data% -b init foo || exit 1 - -echo try to generate EC keys -%tinc% -c %data% -b generate-ed25519-keys || exit 1 - -echo can tincd run? -%tincd% --version || exit 1 - -echo bail out if we're missing support for the legacy protocol -%tinc% --version | findstr legacy_protocol || exit 0 - -echo try to generate RSA keys -%tinc% -c %data% -b generate-keys || exit 1 +meson test -C %builddir% --timeout-multiplier 2 --verbose || exit 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 27f364b0..f9b39eb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,33 +65,25 @@ jobs: tar -C ~ --strip-components=1 --wildcards -xf ./shellcheck-*.tar.xz 'shellcheck-*/shellcheck' curl -o ~/shfmt -L "https://github.com/mvdan/sh/releases/download/v$SHFMT/shfmt_v${SHFMT}_linux_amd64" chmod 755 ~/shfmt ~/shellcheck - pip3 install --user compiledb + python3 -m venv /tmp/venv + . /tmp/venv/bin/activate + pip3 install black pylint mypy env: CLANG: 11 SHELLCHECK: 0.7.2 SHFMT: 3.3.0 - name: Install deps - run: sudo sh .ci/deps.sh - - - name: Run clang-tidy - run: sh .ci/tidy/run.sh - if: always() - - - name: Check code formatting - run: "! astyle --exclude=build -r --options=.astylerc --dry-run --formatted '*.c' '*.h' | grep '^Formatted'" - if: always() - - - name: Check scripts formatting - run: find -type f -regextype egrep -regex '.+\.(sh|sh\.in|test)$' -exec ~/shfmt -d -i 2 -s '{}' + - if: always() + run: sudo SKIP_OPENSSL3=1 sh .ci/deps.sh - - name: Run static analysis on scripts - run: find -type f -regextype egrep -regex '.+\.sh(\.in)?$' -exec shellcheck -x '{}' + + - name: Lint/typecheck/check formatting on C/shell/Python code + run: | + . /tmp/venv/bin/activate + PATH=$PATH:$HOME ./lint.py if: always() - - name: Run static analysis on tests - run: find -type f -name '*.test' -execdir shellcheck -x '{}' + + - name: Run clang-tidy + run: sh .ci/tidy/run.sh if: always() - name: Check warnings (gcc) @@ -340,9 +332,14 @@ jobs: strategy: fail-fast: false matrix: - arch: - - amd64 - - amd64_x86 + target: + - { build: amd64, host: amd64, test: test } + - { build: amd64, host: x86, test: test } + - { build: amd64, host: arm64, test: notest } + + env: + HOST_ARCH: ${{ matrix.target.host }} + BUILD_ARCH: ${{ matrix.target.build }} steps: - name: Install meson @@ -354,14 +351,14 @@ jobs: - name: Activate dev environment uses: ilammy/msvc-dev-cmd@v1 with: - arch: ${{ matrix.arch }} + arch: ${{ matrix.target.build == matrix.target.host && matrix.target.host || format('{0}_{1}', matrix.target.build, matrix.target.host) }} - name: Build (nolegacy) run: .ci\windows\build.cmd nolegacy - name: Test (nolegacy) run: .ci\windows\test.cmd nolegacy - if: always() + if: always() && matrix.target.test == 'test' - name: Build (OpenSSL) run: .ci\windows\build.cmd openssl @@ -369,4 +366,4 @@ jobs: - name: Test (OpenSSL) run: .ci\windows\test.cmd openssl - if: always() + if: always() && matrix.target.test == 'test' -- 2.20.1