From a5206eb696f0d17c2f587582dcc913c159241a31 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 14 Jun 2023 07:40:14 +0200 Subject: [PATCH] CI: cleanups --- .github/workflows/ci.yml | 29 +++-- ...s.yml => github-close-inactive-issues.yml} | 3 +- ...opr.yml => github-close-pull-requests.yml} | 0 .../{spell-check.yml => misc-spell-check.yml} | 0 ...an-build.yml => static-analyzer-clang.yml} | 5 +- ...nalysis.yml => static-analyzer-codeql.yml} | 12 +- .github/workflows/test-alpine-linux.yml | 4 + .../{minimal-ci.yml => weekly-ci-alpine.yml} | 12 +- .../workflows/weekly-ci-macos-cmake-xcode.yml | 31 +++++ .github/workflows/weekly-ci-zigcc.yml | 121 ++++++++++++++++++ .gitignore | 1 + 11 files changed, 184 insertions(+), 34 deletions(-) rename .github/workflows/{close-stale-issues.yml => github-close-inactive-issues.yml} (96%) rename .github/workflows/{nopr.yml => github-close-pull-requests.yml} (100%) rename .github/workflows/{spell-check.yml => misc-spell-check.yml} (100%) rename .github/workflows/{scan-build.yml => static-analyzer-clang.yml} (91%) rename .github/workflows/{codeql-analysis.yml => static-analyzer-codeql.yml} (73%) rename .github/workflows/{minimal-ci.yml => weekly-ci-alpine.yml} (89%) create mode 100644 .github/workflows/weekly-ci-macos-cmake-xcode.yml create mode 100644 .github/workflows/weekly-ci-zigcc.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b4c3b72..c42efbc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ on: [push, workflow_dispatch] env: DEBIAN_FRONTEND: noninteractive UPX_CMAKE_BUILD_FLAGS: --verbose + # 2023-06-11 + ZIG_DIST_VERSION: 0.11.0-dev.3395+1e7dcaa3a jobs: job-rebuild-and-verify-stubs: @@ -366,28 +368,27 @@ jobs: fail-fast: false matrix: include: + # only build a few targets => more targets are tested in the Weekly CI - { zig_target: aarch64-linux-musl } - - { zig_target: aarch64-linux-musl, zig_pic: -fPIE } + # { zig_target: aarch64-linux-musl, zig_pic: -fPIE } - { zig_target: aarch64-macos.11-none } - - { zig_target: aarch64-macos.12-none } - - { zig_target: aarch64-macos.13-none } + # { zig_target: aarch64-macos.12-none } + # { zig_target: aarch64-macos.13-none } - { zig_target: aarch64-windows-gnu } - - { zig_target: i386-linux-musl } + # { zig_target: i386-linux-musl } - { zig_target: i386-windows-gnu } - - { zig_target: mips-linux-musl } - - { zig_target: mipsel-linux-musl } - - { zig_target: powerpc-linux-musl } - - { zig_target: powerpc64-linux-musl } - - { zig_target: powerpc64le-linux-musl } + # { zig_target: mips-linux-musl } + # { zig_target: mipsel-linux-musl } + # { zig_target: powerpc-linux-musl } + # { zig_target: powerpc64-linux-musl } + # { zig_target: powerpc64le-linux-musl } - { zig_target: x86_64-linux-musl } - - { zig_target: x86_64-linux-musl, zig_pic: -fPIE } + # { zig_target: x86_64-linux-musl, zig_pic: -fPIE } - { zig_target: x86_64-macos.11-none } - - { zig_target: x86_64-macos.12-none } - - { zig_target: x86_64-macos.13-none } + # { zig_target: x86_64-macos.12-none } + # { zig_target: x86_64-macos.13-none } - { zig_target: x86_64-windows-gnu } env: - # 2023-06-11 - ZIG_DIST_VERSION: 0.11.0-dev.3395+1e7dcaa3a # for zig-cc wrapper scripts (see below): ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING ZIG_FLAGS: ${{ matrix.zig_flags }} diff --git a/.github/workflows/close-stale-issues.yml b/.github/workflows/github-close-inactive-issues.yml similarity index 96% rename from .github/workflows/close-stale-issues.yml rename to .github/workflows/github-close-inactive-issues.yml index 82ef64a3..ae9cdc23 100644 --- a/.github/workflows/close-stale-issues.yml +++ b/.github/workflows/github-close-inactive-issues.yml @@ -12,8 +12,7 @@ name: 'GitHub - Close inactive issues' on: - schedule: - - cron: '40 3 * * 3' + schedule: [cron: '50 3 * * 3'] # run weekly Wednesday 03:50 UTC workflow_dispatch: jobs: close-issues: diff --git a/.github/workflows/nopr.yml b/.github/workflows/github-close-pull-requests.yml similarity index 100% rename from .github/workflows/nopr.yml rename to .github/workflows/github-close-pull-requests.yml diff --git a/.github/workflows/spell-check.yml b/.github/workflows/misc-spell-check.yml similarity index 100% rename from .github/workflows/spell-check.yml rename to .github/workflows/misc-spell-check.yml diff --git a/.github/workflows/scan-build.yml b/.github/workflows/static-analyzer-clang.yml similarity index 91% rename from .github/workflows/scan-build.yml rename to .github/workflows/static-analyzer-clang.yml index 0c368fa9..b8313c2b 100644 --- a/.github/workflows/scan-build.yml +++ b/.github/workflows/static-analyzer-clang.yml @@ -1,12 +1,11 @@ name: 'Static Analyzer - clang scan-build' on: - schedule: - - cron: '40 4 * * 3' + schedule: [cron: '20 5 * * 3'] # run weekly Wednesday 05:20 UTC workflow_dispatch: jobs: - analyze: + job-analyze-clang: strategy: fail-fast: false matrix: {container: ['alpine:3.16','alpine:3.17','alpine:3.18','alpine:edge','i386/alpine:edge']} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/static-analyzer-codeql.yml similarity index 73% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows/static-analyzer-codeql.yml index 60c2873d..678e39b0 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/static-analyzer-codeql.yml @@ -1,29 +1,21 @@ name: 'Static Analyzer - CodeQL' on: -# push: -# branches: [ 'devel', 'devel4', 'devel5', 'master' ] -# pull_request: -# # The branches below must be a subset of the branches above -# branches: [ 'devel', 'devel4', 'devel5' ] - schedule: - - cron: '20 4 * * 3' + schedule: [cron: '40 5 * * 3'] # run weekly Wednesday 05:40 UTC workflow_dispatch: jobs: - analyze: + job-analyze-codeql: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write - strategy: fail-fast: false matrix: language: [ 'cpp' ] - steps: - name: Checkout repository uses: actions/checkout@v3 diff --git a/.github/workflows/test-alpine-linux.yml b/.github/workflows/test-alpine-linux.yml index 474652ff..8ed32c3b 100644 --- a/.github/workflows/test-alpine-linux.yml +++ b/.github/workflows/test-alpine-linux.yml @@ -1,3 +1,7 @@ +# test minimal number of packages required for building UPX under Alpine Linux +# clang: apk add clang cmake make +# gcc: apk add cmake g++ make + name: 'Test - Minimal Alpine build' on: [workflow_dispatch] jobs: diff --git a/.github/workflows/minimal-ci.yml b/.github/workflows/weekly-ci-alpine.yml similarity index 89% rename from .github/workflows/minimal-ci.yml rename to .github/workflows/weekly-ci-alpine.yml index 0d3e02ae..c223d6d3 100644 --- a/.github/workflows/minimal-ci.yml +++ b/.github/workflows/weekly-ci-alpine.yml @@ -1,9 +1,11 @@ -# minimal GitHub CI building UPX with clang and gcc in an Alpine Linux container +# build under various Alpine Linux versions with clang and gcc + +name: 'Weekly CI - Alpine Linux' -name: 'CI - Minimal CI with Alpine Linux' on: - schedule: [cron: '50 3 * * 3'] + schedule: [cron: '10 4 * * 3'] # run weekly Wednesday 04:10 UTC workflow_dispatch: + jobs: job-alpine-cmake: strategy: @@ -13,7 +15,7 @@ jobs: name: ${{ format('container {0}', matrix.container) }} runs-on: ubuntu-latest container: ${{ matrix.container }} - env: { VERBOSE: 1 } + env: { UPX_CMAKE_CONFIG_FLAGS: '-DCMAKE_VERBOSE_MAKEFILE=ON' } steps: - name: ${{ format('Install packages {0}', matrix.container) }} run: 'apk update && apk upgrade && apk add clang cmake g++ git make' @@ -23,7 +25,7 @@ jobs: git -C upx submodule update --init x="$(apk list -I "$(apk info -Wq "$(which clang)")")"; echo "clang_package=${x%% *}" >> $GITHUB_ENV x="$(apk list -I "$(apk info -Wq "$(which gcc)")")"; echo "gcc_package=${x%% *}" >> $GITHUB_ENV - echo "artifact_name=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-minimal-ci-${{ matrix.container }}" | sed 's/[^=0-9a-zA-Z_.-]/-/g' >> $GITHUB_ENV + echo "artifact_name=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-alpine-${{ matrix.container }}" | sed 's/[^=0-9a-zA-Z_.-]/-/g' >> $GITHUB_ENV - name: ${{ format('Build clang Release with {0}', env.clang_package) }} run: 'make -C upx UPX_XTARGET=clang-static CC="clang -static" CXX="clang++ -static"' - name: ${{ format('Build clang Debug with {0}', env.clang_package) }} diff --git a/.github/workflows/weekly-ci-macos-cmake-xcode.yml b/.github/workflows/weekly-ci-macos-cmake-xcode.yml new file mode 100644 index 00000000..480c175c --- /dev/null +++ b/.github/workflows/weekly-ci-macos-cmake-xcode.yml @@ -0,0 +1,31 @@ +# build with "cmake -G Xcode" + +name: 'Weekly CI - macOS cmake Xcode' + +on: + schedule: [cron: '20 4 * * 3'] # run weekly Wednesday 04:20 UTC + workflow_dispatch: + +jobs: + job-macos-cmake-xcode: + name: ${{ format('{0} cmake Xcode', matrix.os) }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - { os: macos-11, run_test: true } + - { os: macos-12, run_test: true } + - { os: macos-13, run_test: false } # TODO: enable once UPX fully works on macos-13 + steps: + - name: 'Check out code' + uses: actions/checkout@v3 + with: { submodules: true } + - { name: 'Config cmake Xcode', run: 'cmake -S . -B build/xcode -G Xcode' } + - { name: 'Build cmake Xcode Debug', run: 'cmake --build build/xcode --config Debug' } + - { name: 'Build cmake Xcode Release', run: 'cmake --build build/xcode --config Release' } + - name: 'Run basic tests' + if: ${{ matrix.run_test }} + run: | + ctest --test-dir build/xcode -C Debug + ctest --test-dir build/xcode -C Release diff --git a/.github/workflows/weekly-ci-zigcc.yml b/.github/workflows/weekly-ci-zigcc.yml new file mode 100644 index 00000000..cebf8797 --- /dev/null +++ b/.github/workflows/weekly-ci-zigcc.yml @@ -0,0 +1,121 @@ +# build with "zig cc"; see https://ziglang.org/download/ + +name: 'Weekly CI - zigcc' + +on: + schedule: [cron: '30 4 * * 3'] # run weekly Wednesday 04:30 UTC + workflow_dispatch: + +env: + # 2023-06-11 + ZIG_DIST_VERSION: 0.11.0-dev.3395+1e7dcaa3a + +jobs: + job-linux-zigcc: + name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} + runs-on: ubuntu-latest + container: 'alpine:3.18' # older versions such as alpine:3.12 also work; no-container also works + strategy: + fail-fast: false + matrix: + include: + - { zig_target: aarch64-linux-musl } + - { zig_target: aarch64-linux-musl, zig_pic: -fPIE } + - { zig_target: aarch64-macos.11-none } + - { zig_target: aarch64-macos.12-none } + - { zig_target: aarch64-macos.13-none } + - { zig_target: aarch64-windows-gnu } + - { zig_target: i386-linux-musl } + - { zig_target: i386-windows-gnu } + - { zig_target: mips-linux-musl } + - { zig_target: mipsel-linux-musl } + - { zig_target: powerpc-linux-musl } + - { zig_target: powerpc64-linux-musl } + - { zig_target: powerpc64le-linux-musl } + - { zig_target: x86_64-linux-musl } + - { zig_target: x86_64-linux-musl, zig_pic: -fPIE } + - { zig_target: x86_64-macos.11-none } + - { zig_target: x86_64-macos.12-none } + - { zig_target: x86_64-macos.13-none } + - { zig_target: x86_64-windows-gnu } + env: + # for zig-cc wrapper scripts (see below): + ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING + ZIG_FLAGS: ${{ matrix.zig_flags }} + ZIG_PIC: ${{ matrix.zig_pic }} + ZIG_TARGET: ${{ matrix.zig_target }} + steps: + - name: 'Install Alpine Linux container packages' + if: ${{ job.container }} + shell: sh + run: | + apk update && apk upgrade && apk add bash cmake file git make tar xz + # set PATH like in Ubuntu + echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV + # this seems to be needed when running in a container (beause of UID mismatch??) + git config --global --add safe.directory '*' + - name: 'Check out code' + uses: actions/checkout@v3 + with: { submodules: true } + - name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }} + shell: bash + run: | + # GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below + rev=$(git rev-parse --short=7 HEAD) + echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV + # update ZIG_TARGET (i386 => x86) + ZIG_TARGET=${ZIG_TARGET/i386-/x86-} + echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV + # install zig; note that ~/.local/bin is included in the default $PATH on Ubuntu + mkdir -p -v ~/.local/bin + cd ~/.local/bin + ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION} + wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz + ls -l ${ZIG_DIST_NAME}.tar.xz + tar -xoJf ${ZIG_DIST_NAME}.tar.xz + rm ${ZIG_DIST_NAME}.tar.xz + ln -s -v ${ZIG_DIST_NAME}/zig zig + #echo "PATH=$PATH" && which zig + echo -n 'zig version: '; zig version + # create wrapper scripts (needed for CMake) + echo -e '#!/bin/sh\nexec zig ar "$@"' > zig-ar + echo -e '#!/bin/sh\nexec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc + echo -e '#!/bin/sh\nexec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx + echo -e '#!/bin/sh\nexec zig ranlib "$@"' > zig-ranlib + chmod +x zig-ar zig-cc zig-cxx zig-ranlib + ls -la; head zig-ar zig-cc zig-cxx zig-ranlib + - name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} + run: | + mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release + cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release + cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE + cmake --build . --config Release --parallel --verbose + file ./upx* + - name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} + run: | + mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug + cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug + cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG + cmake --build . --config Debug --parallel --verbose + file ./upx* + - name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }} + shell: bash + run: | + N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-weekly-ci-zigcc-${{ matrix.zig_target }}${ZIG_PIC} + mkdir -p "tmp/artifact/$N" + (cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N") + (cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") + # GitHub Actions magic: set "artifact_name" environment value for use in next step + echo "artifact_name=$N" >> $GITHUB_ENV + - name: ${{ format('Upload artifact {0}', env.artifact_name) }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.artifact_name }} + path: tmp/artifact + - name: 'Run install tests' + if: ${{ contains(matrix.zig_target, '-linux-') }} + run: | + (cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-cmake cmake --install .) + (cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-make make install) + +# vim:set ts=2 sw=2 et: diff --git a/.gitignore b/.gitignore index fcd73630..d54552a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.hg* /.vscode* /Makevars.global* +/Testing* /build* /maint* /vendor*