From 22d427c9dba6b10a8a2789f26c71e648b6d4c181 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Sat, 28 Oct 2023 18:59:43 -0700 Subject: [PATCH] Move binaries build to GitHub Actions --- .circleci/config.yml | 70 +-------------------- .github/dependabot.yml | 8 +++ .github/workflows/ci.yml | 94 +++++++++++++++++++++++++++++ .github/workflows/draft-release.yml | 23 ------- .gitignore | 5 ++ build/Dockerfile | 74 +++++++++++++++++++++++ ci/build_module_binaries.sh | 19 ------ ci/build_module_binary.sh | 43 ------------- ci/build_static_opentracing.sh | 16 ----- ci/do_ci.sh | 9 --- ci/release.sh | 29 --------- 11 files changed, 182 insertions(+), 208 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/draft-release.yml create mode 100644 build/Dockerfile delete mode 100755 ci/build_module_binaries.sh delete mode 100755 ci/build_module_binary.sh delete mode 100755 ci/build_static_opentracing.sh delete mode 100755 ci/release.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 6da43911..eb80514c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,46 +39,7 @@ jobs: - checkout - run: command: docker build -t opentracing/openresty -f Dockerfile-openresty . - module_binaries_opentracing_15: - docker: - - image: ubuntu:18.04 - environment: - OPENTRACING_VERSION: v1.5.1 - MODULE_DIR: /workspace/modules - steps: - - checkout - - run: mkdir -p /workspace/modules - - run: ./ci/setup_build_environment.sh - - run: - name: Build modules with opentracing v1.5.1 - command: ./ci/do_ci.sh module.binaries - - store_artifacts: - path: /workspace/modules - - persist_to_workspace: - root: /workspace - paths: - - modules - module_binaries_opentracing_16: - docker: - - image: ubuntu:18.04 - environment: - OPENTRACING_VERSION: v1.6.0 - MODULE_DIR: /workspace/modules - NAME_SUFFIX: "-ot16" - steps: - - checkout - - run: ./ci/setup_build_environment.sh - - attach_workspace: - at: /workspace - - run: - name: Build modules with opentracing v1.6.0 - command: ./ci/do_ci.sh module.binaries - - store_artifacts: - path: /workspace/modules - - persist_to_workspace: - root: /workspace - paths: - - modules + push_docker_image: machine: true steps: @@ -86,18 +47,6 @@ jobs: - run: command: ./ci/do_ci.sh push_docker_image - release: - docker: - - image: ubuntu:18.04 - environment: - MODULE_DIR: /workspace/modules - steps: - - run: apt-get -qq update; apt-get -y install git ssh - - checkout - - attach_workspace: - at: /workspace - - run: ./ci/setup_build_environment.sh - - run: ./ci/do_ci.sh release workflows: version: 2 @@ -109,14 +58,6 @@ workflows: ignore: /.*/ tags: &tags only: /^v[0-9]+(\.[0-9]+)*$/ - - release: - requires: - - module_binaries_opentracing_15 - - module_binaries_opentracing_16 - filters: - branches: - ignore: /.*/ - tags: *tags - system_testing - build_gcc48_opentracing_15 - build_gcc48_opentracing_16: @@ -125,12 +66,3 @@ workflows: - openresty_docker_image: requires: - system_testing - - module_binaries_opentracing_15: - filters: - tags: *tags - - - module_binaries_opentracing_16: - requires: - - module_binaries_opentracing_15 - filters: - tags: *tags diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9e42de81..52fb6e87 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,14 +4,22 @@ updates: directory: "/" schedule: interval: daily + + - package-ecosystem: "docker" + directory: "/build" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" directory: "/" schedule: interval: daily + - package-ecosystem: "pip" directory: "/test" schedule: interval: "daily" + - package-ecosystem: "pip" directory: "/test/environment/grpc" schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ef1f413f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: CI + +on: + push: + branches: + - master + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + branches: + - master + +concurrency: + group: ${{ github.ref_name }}-ci + cancel-in-progress: true + +jobs: + build-binaries: + name: Build Binaries + runs-on: ubuntu-20.04 + strategy: + matrix: + nginx_version: + [ + 1.15.12, + 1.16.1, + 1.17.10, + 1.18.0, + 1.19.10, + 1.20.2, + 1.21.6, + 1.22.1, + 1.23.4, + 1.24.0, + 1.25.0, + 1.25.1, + 1.25.2, + 1.25.3, + ] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Create/Update Draft + uses: lucacome/draft-release@v1.0.1 + with: + minor-label: "enhancement" + major-label: "change" + publish: ${{ github.ref_type == 'tag' }} + collapse-after: 50 + if: github.event_name != 'pull_request' + + - name: Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + + - name: Build binary + uses: docker/build-push-action@v5 + with: + pull: true + push: false + file: build/Dockerfile + tags: ${{ matrix.nginx_version }} + cache-from: type=gha,scope=${{ matrix.nginx_version }} + cache-to: type=gha,scope=${{ matrix.nginx_version }},mode=max + platforms: linux/amd64,linux/arm64 + provenance: true + target: export + build-args: NGINX_VERSION=${{ matrix.nginx_version }} + outputs: type=local,dest=out + + - name: Compress output + run: | + tar -czf linux-amd64-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.tgz -C out/linux_amd64/ ngx_http_opentracing_module.so + tar -czf linux-arm64-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.tgz -C out/linux_arm64/ ngx_http_opentracing_module.so + cp out/linux_amd64/provenance.json linux-amd64-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.provenance.json + cp out/linux_arm64/provenance.json linux-arm64-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.provenance.json + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: nginx-opentracing-modules-${{ matrix.nginx_version }} + path: linux-*-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.* + + - name: Upload binaries on release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: github.ref_type == 'tag' + run: | + gh release upload ${{ github.ref_name }} linux-*-nginx-${{ matrix.nginx_version }}-ngx_http_module.so.* --clobber diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml deleted file mode 100644 index 9a3bf019..00000000 --- a/.github/workflows/draft-release.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Release Drafter - -on: - push: - branches: - - master - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - -jobs: - update_release_draft: - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Create/Update Draft - uses: lucacome/draft-release@v1.0.1 - with: - minor-label: "enhancement" - major-label: "change" - publish: ${{ github.ref_type == 'tag' }} - collapse-after: 50 diff --git a/.gitignore b/.gitignore index 92b5f87e..b5d11599 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,8 @@ test-log/ # IDEs .vscode + +# macOS +.DS_Store + +out diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 00000000..8992e361 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,74 @@ +FROM ubuntu:23.10 as base + +RUN apt-get update && \ + apt-get install --no-install-recommends --no-install-suggests -y \ + build-essential \ + cmake \ + pkg-config \ + git \ + ca-certificates \ + automake \ + autogen \ + autoconf \ + libtool \ + ssh \ + wget \ + libpcre3 libpcre3-dev \ + zlib1g-dev + +ENV CFLAGS="-fPIC" +ENV CXXFLAGS="-fPIC" +ENV LDFLAGS="-fPIC" + + +FROM base as opentracing +ARG OPENTRACING_VERSION=v1.6.0 + +RUN <<"eot" bash -euo pipefail + git clone -b "${OPENTRACING_VERSION}" https://github.com/opentracing/opentracing-cpp.git + cd opentracing-cpp + mkdir .build && cd .build + cmake -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="-fPIC" \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_TESTING=OFF \ + -DBUILD_MOCKTRACER=OFF \ + .. + make && make install +eot + + +FROM opentracing as binary +ARG NGINX_VERSION + +COPY --link opentracing /opentracing + +ADD --link https://github.com/nginx/nginx/archive/release-${NGINX_VERSION}.tar.gz / +RUN tar zxf release-${NGINX_VERSION}.tar.gz +WORKDIR /nginx-release-${NGINX_VERSION} + +COPY <<-EOT export.map +{ + global: + ngx_*; + local: *; +}; +EOT + +RUN ./auto/configure \ + --with-compat \ + --add-dynamic-module=/opentracing \ + && make modules + +RUN /usr/bin/g++ -o ngx_http_opentracing_module.so \ + objs/addon/src/*.o \ + objs/ngx_http_opentracing_module_modules.o \ + -static-libstdc++ -static-libgcc \ + -lopentracing \ + -Wl,--version-script="export.map" \ + -shared + + +FROM scratch as export +ARG NGINX_VERSION +COPY --from=binary /nginx-release-${NGINX_VERSION}/ngx_http_opentracing_module.so / diff --git a/ci/build_module_binaries.sh b/ci/build_module_binaries.sh deleted file mode 100755 index e9842784..00000000 --- a/ci/build_module_binaries.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -[ -z "${OPENTRACING_VERSION}" ] && export OPENTRACING_VERSION="v1.6.0" -NAME_SUFFIX=${NAME_SUFFIX:-""} - -NGINX_VERSIONS=(1.25.3 1.25.2 1.25.1 1.25.0 1.24.0 1.23.4 1.23.3 1.23.2 1.23.1 1.23.0 1.22.1 1.22.0 1.21.6 1.21.5 1.21.4 1.21.3 1.21.2 1.21.1 1.21.0 1.20.2 1.20.1 1.20.0 1.19.10 1.19.9 1.19.8 1.19.7 1.19.6 1.19.5 1.19.4 1.19.3 1.19.2 1.18.0 1.17.8 1.17.3 1.17.2 1.17.1 1.17.0 1.16.1 1.16.0 1.15.8 1.15.1 1.15.0 1.14.2 1.13.6) - -# Compile for a portable cpu architecture -export CFLAGS="-march=x86-64 -fPIC" -export CXXFLAGS="-march=x86-64 -fPIC" -export LDFLAGS="-fPIC" - -./ci/build_static_opentracing.sh - -for NGINX_VERSION in ${NGINX_VERSIONS[*]}; do - ./ci/build_module_binary.sh "${NGINX_VERSION}" "${NAME_SUFFIX}" -done diff --git a/ci/build_module_binary.sh b/ci/build_module_binary.sh deleted file mode 100755 index 031f6c53..00000000 --- a/ci/build_module_binary.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -e - -pushd "${BUILD_DIR}" -NGINX_VERSION=$1 -NAME_SUFFIX=${2:-""} - -wget -O nginx-release-${NGINX_VERSION}.tar.gz https://github.com/nginx/nginx/archive/release-${NGINX_VERSION}.tar.gz -tar zxf nginx-release-$NGINX_VERSION.tar.gz -cd nginx-release-$NGINX_VERSION - -# Set up an export map so that symbols from the opentracing module don't -# clash with symbols from other libraries. -cat < export.map -{ - global: - ngx_*; - local: *; -}; -EOF - -./auto/configure \ - --with-compat \ - --add-dynamic-module="${SRC_DIR}"/opentracing -make modules - -# Statically linking won't work correctly unless g++ is used instead of gcc, and -# there doesn't seem to be any way to have nginx build with g++ -# (-with-cc=/usr/bin/g++ will fail when compiling the c files), so manually -# redo the linking. -/usr/bin/g++-7 -o ngx_http_opentracing_module.so \ - objs/addon/src/*.o \ - objs/ngx_http_opentracing_module_modules.o \ - -static-libstdc++ -static-libgcc \ - -lopentracing \ - -Wl,--version-script="${PWD}/export.map" \ - -shared - -TARGET_NAME=linux-amd64-nginx-${NGINX_VERSION}${NAME_SUFFIX}-ngx_http_module.so.tgz -tar czf ${TARGET_NAME} ngx_http_opentracing_module.so -cp ${TARGET_NAME} "${MODULE_DIR}"/ -popd diff --git a/ci/build_static_opentracing.sh b/ci/build_static_opentracing.sh deleted file mode 100755 index a07b0a2b..00000000 --- a/ci/build_static_opentracing.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e - -pushd "${BUILD_DIR}" -git clone -b "${OPENTRACING_VERSION}" https://github.com/opentracing/opentracing-cpp.git -cd opentracing-cpp -mkdir .build && cd .build -cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_FLAGS="-fPIC" \ - -DBUILD_SHARED_LIBS=OFF \ - -DBUILD_TESTING=OFF \ - -DBUILD_MOCKTRACER=OFF \ - .. -make && make install -popd diff --git a/ci/do_ci.sh b/ci/do_ci.sh index d57464e9..605f2ca5 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -4,7 +4,6 @@ set -e [ -z "${SRC_DIR}" ] && export SRC_DIR="$(pwd)" [ -z "${BUILD_DIR}" ] && export BUILD_DIR=/build -[ -z "${MODULE_DIR}" ] && export MODULE_DIR=/modules if [[ "$1" == "system.testing" ]]; then docker build -t nginx-opentracing-test/nginx -f Dockerfile-test . @@ -19,11 +18,6 @@ elif [[ "$1" == "build" ]]; then mkdir -p "${BUILD_DIR}" ./ci/build_nginx_opentracing_module.sh exit 0 -elif [[ "$1" == "module.binaries" ]]; then - mkdir -p "${BUILD_DIR}" - mkdir -p "${MODULE_DIR}" - ./ci/build_module_binaries.sh - exit 0 elif [[ "$1" == "push_docker_image" ]]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin VERSION_TAG="$(git describe --abbrev=0 --tags)" @@ -36,9 +30,6 @@ elif [[ "$1" == "push_docker_image" ]]; then docker tag opentracing/openresty opentracing/openresty:latest docker push opentracing/openresty:latest exit 0 -elif [[ "$1" == "release" ]]; then - ./ci/release.sh - exit 0 else echo "Invalid do_ci.sh target" exit 1 diff --git a/ci/release.sh b/ci/release.sh deleted file mode 100755 index 6b7d0c36..00000000 --- a/ci/release.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -e -apt-get update -apt-get install --no-install-recommends --no-install-suggests -y \ - wget \ - unzip - -# Install ghr -cd / -wget https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_amd64.zip -unzip ghr_v0.5.4_linux_amd64.zip - -# Create release -cd "${SRC_DIR}" -VERSION_TAG="`git describe --abbrev=0 --tags`" - -echo "/ghr -t \ - -u $CIRCLE_PROJECT_USERNAME \ - -r $CIRCLE_PROJECT_REPONAME \ - -replace \ - ${VERSION_TAG} \ - ${MODULE_DIR}" -/ghr -t $GITHUB_TOKEN \ - -u $CIRCLE_PROJECT_USERNAME \ - -r $CIRCLE_PROJECT_REPONAME \ - -replace \ - "${VERSION_TAG}" \ - "${MODULE_DIR}"