JCMais/node-libcurl

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
## CircleCI is used to build:
## - Electron (linux)
## - Nwjs (linux)
## - Node.js (alpine)

version: 2.1

# aliases:
#   # add deps on ubuntu img
#   - &install-deps
#     # update automake
#     - run: |
#         wget ftp://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz &> /dev/null
#         tar -xzf automake-1.16.1.tar.gz && cd automake-1.16.1
#         ./configure && make && sudo make install
#     # add missing packages
#     - run: sudo apt-get install texinfo gperf ruby-ronn cmake

executors:
  debian:
    docker:
      - image: jonathancardoso/debian-ci
    environment:
      RECONFIGURE_NGHTTP2: 'true'
      BASH_ENV: '/home/circleci/.bashrc'
      LATEST_LIBCURL_RELEASE: '7.86.0'
  alpine:
    docker:
      - image: jonathancardoso/alpine-ci
    environment:
      LATEST_LIBCURL_RELEASE: '7.86.0'

orbs:
  build-addon-unix-and-publish:
    jobs:
      build-addon:
        # https://circleci.com/docs/2.0/reusing-config/#parameter-syntax
        parameters:
          node-version:
            description: Version of Node.js
            default: '18'
            type: string
          electron-version:
            description: Version of Node.js
            default: ''
            type: string
          nwjs-version:
            description: Version of Nw.js
            default: ''
            type: string
          e:
            type: executor
          node-libcurl-cpp-std:
            type: string
            default: 'c++17'
          cares-version:
            type: string
            default: '1.18.1'
          brotli-version:
            type: string
            default: '1.0.9'
          libcurl-version:
            type: string
            default: '7.86.0'
          libidn2-version:
            type: string
            default: '2.1.1'
          libssh2-version:
            type: string
            default: '1.10.0'
          libunistring-version:
            type: string
            default: '0.9.10'
          ncurses-version:
            type: string
            default: '6.1'
          nghttp2-version:
            type: string
            default: '1.47.0'
          openldap-version:
            type: string
            default: '2.4.47'
          openssl-version:
            type: string
            default: '3.0.7'
          zlib-version:
            type: string
            default: '1.2.13'
          before-build:
            description: 'Steps that will be executed before the build'
            type: steps
            default: []
          after-build:
            description: 'Steps that will be executed before the build'
            type: steps
            default: []
        executor: << parameters.e >>
        steps:
          - checkout
          # temporary fix to solve certificates issues - main docker image must be updated instead
          - when:
              condition:
                equal: ['debian', << parameters.e >>]
              steps:
                - run: sudo apt-get update && sudo apt-get upgrade
          - when:
              condition: <<parameters.node-version>>
              steps:
                - run: |
                    if [[ -n "$(command -v nvm)" ]]; then
                      nvm use <<parameters.node-version>>
                    else
                      [[ -f /usr/local/bin/node<<parameters.node-version>> ]] && ln -s /usr/local/bin/node<<parameters.node-version>> /usr/local/bin/node || true
                    fi
          - run:
              name: Setup Environment Variables
              command: |
                echo 'export ELECTRON_VERSION="<<parameters.electron-version>>"' >> $BASH_ENV
                echo 'export NWJS_VERSION="<<parameters.nwjs-version>>"' >> $BASH_ENV
                echo 'export CARES_RELEASE="<<parameters.cares-version>>"' >> $BASH_ENV
                echo 'export BROTLI_RELEASE="<<parameters.brotli-version>>"' >> $BASH_ENV
                echo 'export LIBCURL_RELEASE="<<parameters.libcurl-version>>"' >> $BASH_ENV
                echo 'export LIBIDN2_RELEASE="<<parameters.libidn2-version>>"' >> $BASH_ENV
                echo 'export LIBSSH2_RELEASE="<<parameters.libssh2-version>>"' >> $BASH_ENV
                echo 'export LIBUNISTRING_RELEASE="<<parameters.libunistring-version>>"' >> $BASH_ENV
                echo 'export NCURSES_RELEASE="<<parameters.ncurses-version>>"' >> $BASH_ENV
                echo 'export NGHTTP2_RELEASE="<<parameters.nghttp2-version>>"' >> $BASH_ENV
                echo 'export OPENLDAP_RELEASE="<<parameters.openldap-version>>"' >> $BASH_ENV
                echo 'export OPENSSL_RELEASE="<<parameters.openssl-version>>"' >> $BASH_ENV
                echo 'export ZLIB_RELEASE="<<parameters.zlib-version>>"' >> $BASH_ENV
                echo 'export NODE_LIBCURL_CPP_STD="<<parameters.node-libcurl-cpp-std>>"' >> $BASH_ENV
          ####
          # Restore caches
          ###
          - run:
              name: Create cache key file
              command: |
                echo "$CARES_RELEASE" >> _libs_versions
                echo "$BROTLI_RELEASE" >> _libs_versions
                echo "$LIBCURL_RELEASE" >> _libs_versions
                echo "$LIBIDN2_RELEASE" >> _libs_versions
                echo "$LIBSSH2_RELEASE" >> _libs_versions
                echo "$LIBUNISTRING_RELEASE" >> _libs_versions
                echo "$NCURSES_RELEASE" >> _libs_versions
                echo "$NGHTTP2_RELEASE" >> _libs_versions
                echo "$OPENLDAP_RELEASE" >> _libs_versions
                echo "$OPENSSL_RELEASE" >> _libs_versions
                echo "$ZLIB_RELEASE" >> _libs_versions
          - restore_cache:
              keys:
                - v4-nodeV<<parameters.node-version>>-electronV<<parameters.electron-version>>-nwjsV<<parameters.nwjs-version>>-deps-libs-{{ checksum "_libs_versions" }}-{{ checksum "yarn.lock" }}
                - v4-nodeV<<parameters.node-version>>-electronV<<parameters.electron-version>>-nwjsV<<parameters.nwjs-version>>-deps-libs-{{ checksum "_libs_versions" }}-

          - steps: <<parameters.before-build>>
          ####
          # Build
          ####
          - run:
              command: GIT_TAG=$CIRCLE_TAG GIT_COMMIT=$CIRCLE_SHA1 ./scripts/ci/build.sh
              no_output_timeout: 40m
          - steps: <<parameters.after-build>>
          ####
          # Cache
          ####
          - save_cache:
              key: v4-nodeV<<parameters.node-version>>-electronV<<parameters.electron-version>>-nwjsV<<parameters.nwjs-version>>-deps-libs-{{ checksum "_libs_versions" }}-{{ checksum "yarn.lock" }}
              paths:
                - ~/.electron
                - ~/.cache/electron
                - ~/.cache/yarn
                - ~/.node-gyp
                - ~/.nw-gyp
                - ~/deps/cares/build/<<parameters.cares-version>>
                - ~/deps/brotli/build/<<parameters.brotli-version>>
                - ~/deps/libcurl/build/<<parameters.libcurl-version>>
                - ~/deps/libssh2/build/<<parameters.libssh2-version>>
                - ~/deps/libidn2/build/<<parameters.libidn2-version>>
                - ~/deps/libunistring/build/<<parameters.libunistring-version>>
                - ~/deps/ncurses/build/<<parameters.ncurses-version>>
                - ~/deps/nghttp2/build/<<parameters.nghttp2-version>>
                - ~/deps/openldap/build/<<parameters.openldap-version>>
                - ~/deps/openssl/build/<<parameters.openssl-version>>
                - ~/deps/zlib/build/<<parameters.zlib-version>>
          - store_artifacts:
              path: ./logs/
# Great docs
# https://circleci.com/docs/2.0/reusing-config/#getting-started-with-config-reuse

workflows:
  build-test-deploy:
    jobs:
      ####
      # Node v21
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-node-v21-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          node-version: '21'
          cares-version: '1.20.1'
          nghttp2-version: '1.58.0'
          openssl-version: '3.0.12'
          e:
            name: alpine
      ####
      # Node v20
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-node-v20-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          node-version: '20'
          cares-version: '1.19.1'
          nghttp2-version: '1.57.0'
          openssl-version: '3.0.10'
          e:
            name: alpine
      ####
      # Node v18
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-node-v18-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          node-version: '18'
          cares-version: '1.18.1'
          nghttp2-version: '1.47.0'
          openssl-version: '3.0.7'
          e:
            name: alpine
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-node-v18-libcurl-old
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          node-version: '18'
          libcurl-version: '7.50.0'
          cares-version: '1.18.1'
          nghttp2-version: '1.47.0'
          openssl-version: '3.0.7'
          e:
            name: alpine
      ####
      # Electron v28
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-electron-v28-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          electron-version: '28.0.0'
          e:
            name: debian
      ####
      # Electron v27
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-electron-v27-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          electron-version: '27.1.3'
          e:
            name: debian
      ####
      # Electron v26
      ####
      - build-addon-unix-and-publish/build-addon:
          name: build-addon-electron-v26-libcurl-latest
          context: general
          filters:
            branches:
              ignore:
                - gh-pages
            tags:
              only: /^v.*/
          electron-version: '26.6.2'
          e:
            name: debian

      # disabled until nwjs supports newer node-gyp versions + python 3
      # ####
      # # Nwjs v0.69
      # ####
      # - build-addon-unix-and-publish/build-addon:
      #     name: build-addon-nwjs-v0.69-libcurl-latest
      #     context: general
      #     filters:
      #       branches:
      #         ignore:
      #           - gh-pages
      #       tags:
      #         only: /^v.*/
      #     nwjs-version: '0.69.1'
      #     e:
      #       name: debian
      # ####
      # # Nwjs v0.68
      # ####
      # - build-addon-unix-and-publish/build-addon:
      #     name: build-addon-nwjs-v0.68-libcurl-latest
      #     context: general
      #     filters:
      #       branches:
      #         ignore:
      #           - gh-pages
      #       tags:
      #         only: /^v.*/
      #     nwjs-version: '0.68.1'
      #     e:
      #       name: debian
      # ####
      # # Nwjs v0.67
      # ####
      # - build-addon-unix-and-publish/build-addon:
      #     name: build-addon-nwjs-v0.67-libcurl-latest
      #     context: general
      #     filters:
      #       branches:
      #         ignore:
      #           - gh-pages
      #       tags:
      #         only: /^v.*/
      #     nwjs-version: '0.67.1'
      #     e:
      #       name: debian