diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3717cec --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,147 @@ +name: Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: '37 13 * * 0' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: + # - 3.0 + - 2.7 + - 2.6 + + env: + EXPECTED_GPG_VERSION: "2.3" + GPG_VERSION: "latest" + RNP_VERSION: "v0.11.0" + + steps: + - name: Set up environment + run: | + + # To install and cache our dependencies we need an absolute path + # that does not change, is writable, and resides within + # GITHUB_WORKSPACE. + # On macOS GITHUB_WORKSPACE includes the github runner version, + # so it does not remain constant. + # This causes problems with, for example, pkgconfig files + # referencing paths that no longer exist. + export DEPS_BUILD_DIR="${{ github.workspace }}/build" + export DEPS_PREFIX="${{ github.workspace }}/opt" + export CACHE_DIR="${DEPS_PREFIX}" + export BOTAN_PREFIX="${DEPS_PREFIX}/botan" + export JSONC_PREFIX="${DEPS_PREFIX}/json-c" + export RNP_PREFIX="${DEPS_PREFIX}/rnp" + export GPG_PREFIX="${DEPS_PREFIX}/gpg" + export PATH="${RNP_PREFIX}/bin:${GPG_PREFIX}/bin:${PATH}" + + # Many of these are supported only in few GPG components, hence bunch of + # harmless warnings typically shows up. + export GPG_CONFIGURE_OPTS=" + --disable-doc \ + --enable-pinentry-curses \ + --disable-pinentry-emacs \ + --disable-pinentry-gtk2 \ + --disable-pinentry-gnome3 \ + --disable-pinentry-qt \ + --disable-pinentry-qt4 \ + --disable-pinentry-qt5 \ + --disable-pinentry-tqt \ + --disable-pinentry-fltk \ + --prefix=${GPG_PREFIX} \ + --with-libgpg-error-prefix=${GPG_PREFIX} \ + --with-libassuan-prefix=${GPG_PREFIX} \ + --with-libgpg-error-prefix=${GPG_PREFIX} \ + --with-libgcrypt-prefix=${GPG_PREFIX} \ + --with-libassuan-prefix=${GPG_PREFIX} \ + --with-ksba-prefix=${GPG_PREFIX} \ + --with-npth-prefix=${GPG_PREFIX}" + + + # Be aware of differences between LD_LIBRARY_PATH and LD_RUN_PATH. + # - http://osr507doc.sco.com/en/tools/ccs_linkedit_dynamic_dirsearch.html + # - https://www.hpc.dtu.dk/?page_id=1180 + # + # You should be careful when attempting to replicate following in your + # setup, because setting LD_LIBRARY_PATH is often a bad idea. Nevertheless, + # it is okay here in Travis, and actually any attempt to change these led me + # to linking failures. Side note: I am not a Linux expert, and you may be + # more lucky. + # + # I'd be happy to get rid of LD_LIBRARY_PATH eventually in some future + # pull request. + export LD_LIBRARY_PATH="${BOTAN_PREFIX}/lib:${JSONC_PREFIX}/lib:${RNP_PREFIX}/lib" + export LD_RUN_PATH="${GPG_PREFIX}/lib" + + for i in \ + CACHE_DIR \ + DEPS_BUILD_DIR \ + DEPS_PREFIX \ + BOTAN_PREFIX \ + JSONC_PREFIX \ + RNP_PREFIX \ + GPG_PREFIX \ + PATH \ + LD_LIBRARY_PATH \ + LD_RUN_PATH \ + ; do \ + echo "${i}=${!i}" >> $GITHUB_ENV; \ + done + + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + submodules: true + + - name: Prepare cache key + run: | + echo "YEAR_MONTH=$(date +%Y%m)" >> "${GITHUB_ENV}" + + - name: Cache + id: cache + uses: actions/cache@v2 + with: + path: ${{ env.CACHE_DIR }} + key: ${{ github.workflow }}-${{ runner.os }}-${{ env.RNP_VERSION }}-${{ env.GPG_VERSION }}-gpg-${{ env.EXPECTED_GPG_VERSION }}-${{ hashFiles('ci/**') }}-${{ hashFiles('.github/workflows/**') }}-${{ env.YEAR_MONTH }} + + - name: Build cache + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p "${DEPS_PREFIX}" + pushd ci/gpg + ./install_gpg_all.sh \ + --suite-version "${GPG_VERSION}" \ + --build-dir "${DEPS_BUILD_DIR}/gpg" \ + --sudo --ldconfig \ + --configure-opts "${GPG_CONFIGURE_OPTS}" + popd + pushd ci + ./install_botan.sh + ./install_json_c.sh + ./install_rnp.sh + popd + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + env: + --env: ImageOS=ubuntu18 + + - name: Before script + run: | + bundle exec rake pgp_keys:generate + bundle exec rake pgp_keys:list + + - name: Run tests + run: bundle exec rspec --format documentation --profile 200 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 79e283b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,94 +0,0 @@ -dist: xenial -sudo: required -language: ruby - -rvm: - - 2.6 - - 2.5 - - 2.4 - - 2.3 - - ruby-head - -env: - global: - - EXPECT_GPG_VERSION="2.2" - - GPG_VERSION="latest" - - RNP_VERSION="master" - - - DEPS_BUILD_DIR="${TRAVIS_BUILD_DIR}/build" - - DEPS_PREFIX="${TRAVIS_BUILD_DIR}/opt" - - BOTAN_PREFIX="${DEPS_PREFIX}/botan" - - JSONC_PREFIX="${DEPS_PREFIX}/json-c" - - RNP_PREFIX="${DEPS_PREFIX}/rnp" - - GPG_PREFIX="${DEPS_PREFIX}/gpg" - - # Be aware of differences between LD_LIBRARY_PATH and LD_RUN_PATH. - # - http://osr507doc.sco.com/en/tools/ccs_linkedit_dynamic_dirsearch.html - # - https://www.hpc.dtu.dk/?page_id=1180 - # - # You should be careful when attempting to replicate following in your - # setup, because setting LD_LIBRARY_PATH is often a bad idea. Nevertheless, - # it is okay here in Travis, and actually any attempt to change these led me - # to linking failures. Side note: I am not a Linux expert, and you may be - # more lucky. - # - # I'd be happy to get rid of LD_LIBRARY_PATH eventually in some future - # pull request. - - LD_LIBRARY_PATH="${BOTAN_PREFIX}/lib:${JSONC_PREFIX}/lib:${RNP_PREFIX}/lib" - - LD_RUN_PATH="${GPG_PREFIX}/lib" - - - PATH="${RNP_PREFIX}/bin:${GPG_PREFIX}/bin:${PATH}" - - # Many of these are supported only in few GPG components, hence bunch of - # harmless warnings typically shows up. - - > - GPG_CONFIGURE_OPTS="--disable-doc --enable-pinentry-curses - --disable-pinentry-emacs --disable-pinentry-gtk2 --disable-pinentry-gnome3 - --disable-pinentry-qt --disable-pinentry-qt4 --disable-pinentry-qt5 - --disable-pinentry-tqt --disable-pinentry-fltk - --prefix=${GPG_PREFIX} - --with-libgpg-error-prefix=${GPG_PREFIX} - --with-libassuan-prefix=${GPG_PREFIX} - --with-libgpg-error-prefix=${GPG_PREFIX} - --with-libgcrypt-prefix=${GPG_PREFIX} - --with-libassuan-prefix=${GPG_PREFIX} - --with-ksba-prefix=${GPG_PREFIX} - --with-npth-prefix=${GPG_PREFIX}" - -before_install: - - mkdir -p ${DEPS_PREFIX} - - pushd ci/gpg - - > - ./install_gpg_all.sh - --suite-version "${GPG_VERSION}" - --build-dir "${DEPS_BUILD_DIR}/gpg" - --configure-opts "${GPG_CONFIGURE_OPTS}" - --folding-style travis - - popd - - pushd ci - - ./install_botan.sh - - ./install_json_c.sh - - ./install_rnp.sh - - popd - - gem install bundler -v "~> 2.0" - -before_script: - - bundle exec rake pgp_keys:generate - - bundle exec rake pgp_keys:list - -script: - - bundle exec rspec --format documentation --profile 200 - -matrix: - include: - - env: TEST_WITHOUT_RNP="1" - - env: TEST_WITHOUT_GPGME="1" - # Test against older GPG versions - - env: GPG_VERSION="2.1" EXPECT_GPG_VERSION="2.1" - - gemfile: "ci/Mail-2.6.4.gemfile" - - gemfile: "ci/Mail-2.6.gemfile" - - gemfile: "ci/Mail-head.gemfile" - - allow_failures: - - rvm: ruby-head - - gemfile: "ci/Mail-head.gemfile" diff --git a/README.adoc b/README.adoc index 56ef148..07f56e5 100644 --- a/README.adoc +++ b/README.adoc @@ -3,8 +3,8 @@ ifdef::env-github[] image:https://img.shields.io/gem/v/enmail.svg[ Gem Version, link="https://rubygems.org/gems/enmail"] -image:https://img.shields.io/travis/riboseinc/enmail/master.svg[ - Build Status, link="https://travis-ci.com/riboseinc/enmail/branches"] +image:https://github.com/riboseinc/enmail/actions/workflows/tests.yml/badge.svg[ + Build Status, link="https://github.com/riboseinc/enmail/actions/workflows/tests.yml"] image:https://img.shields.io/codecov/c/github/riboseinc/enmail.svg[ Test Coverage, link="https://codecov.io/gh/riboseinc/enmail"] image:https://img.shields.io/codeclimate/maintainability/riboseinc/enmail.svg[ diff --git a/ci/botan-modules b/ci/botan-modules new file mode 100644 index 0000000..626e0fe --- /dev/null +++ b/ci/botan-modules @@ -0,0 +1,45 @@ +aead +aes +auto_rng +bigint +blowfish +camellia +cast128 +cbc +cfb +crc24 +curve25519 +des +dl_algo +dl_group +dsa +eax +ecc_key +ecdh +ecdsa +ed25519 +elgamal +eme_pkcs1 +emsa_pkcs1 +emsa_raw +ffi +hash +hmac +hmac_drbg +idea +kdf +md5 +ocb +pgp_s2k +rfc3394 +rmd160 +rsa +sha1 +sha2_32 +sha2_64 +sha3 +sm2 +sm3 +sm4 +sp800_56a +twofish diff --git a/ci/install_botan.sh b/ci/install_botan.sh index b3962dc..f2783b3 100755 --- a/ci/install_botan.sh +++ b/ci/install_botan.sh @@ -8,21 +8,35 @@ set -eux -: "${CORES:=2}" +: "${MAKE_PARALLEL:=2}" : "${MAKE:=make}" +: "${BOTAN_MODULES=$(<./botan-modules tr '\n' ',')}" -botan_build="${DEPS_BUILD_DIR}/botan" +# Copied from rnp:ci/lib/cacheable_install_functions.inc.sh +install_botan() { + # botan + local botan_build=${LOCAL_BUILDS}/botan + if [[ ! -e "${BOTAN_INSTALL}/lib/libbotan-2.so" ]] && \ + [[ ! -e "${BOTAN_INSTALL}/lib/libbotan-2.dylib" ]] && \ + [[ ! -e "${BOTAN_INSTALL}/lib/libbotan-2.a" ]]; then -if [ ! -e "${BOTAN_PREFIX}/lib/libbotan-2.so" ] && \ - [ ! -e "${BOTAN_PREFIX}/lib/libbotan-2.dylib" ]; then - - if [ -d "${botan_build}" ]; then + if [[ -d "${botan_build}" ]]; then rm -rf "${botan_build}" fi - git clone --depth 1 https://github.com/randombit/botan "${botan_build}" + git clone --depth 1 --branch "${RECOMMENDED_BOTAN_VERSION}" https://github.com/randombit/botan "${botan_build}" pushd "${botan_build}" - ./configure.py --prefix="${BOTAN_PREFIX}" --with-debug-info --cxxflags="-fno-omit-frame-pointer" - ${MAKE} -j${CORES} install - popd -fi + + ./configure.py --prefix="${BOTAN_INSTALL}" --with-debug-info --cxxflags="-fno-omit-frame-pointer" \ + --without-documentation --without-openssl --build-targets=shared \ + --minimized-build --enable-modules="$BOTAN_MODULES" + ${MAKE} -j"${MAKE_PARALLEL}" install + popd + fi +} + +export LOCAL_BUILDS="${DEPS_BUILD_DIR}" +export BOTAN_INSTALL="${BOTAN_PREFIX}" +export RECOMMENDED_BOTAN_VERSION="${BOTAN_VERSION:-2.17.3}" + +install_botan diff --git a/ci/install_json_c.sh b/ci/install_json_c.sh index 49a34a9..6ee800c 100755 --- a/ci/install_json_c.sh +++ b/ci/install_json_c.sh @@ -1,6 +1,6 @@ #!/bin/bash -# (c) Copyright 2018 Ribose Inc. +# (c) Copyright 2021 Ribose Inc. # # Based on: @@ -8,25 +8,36 @@ set -eux -: "${CORES:=2}" +: "${MAKE_PARALLEL:=2}" : "${MAKE:=make}" jsonc_build="${DEPS_BUILD_DIR}/json-c" -if [ ! -e "${JSONC_PREFIX}/lib/libjson-c.so" ] && \ - [ ! -e "${JSONC_PREFIX}/lib/libjson-c.dylib" ]; then +# Copied from rnp:ci/lib/cacheable_install_functions.inc.sh +install_jsonc() { + local jsonc_build=${LOCAL_BUILDS}/json-c + if [[ ! -e "${JSONC_INSTALL}/lib/libjson-c.so" ]] && \ + [[ ! -e "${JSONC_INSTALL}/lib/libjson-c.dylib" ]] && \ + [[ ! -e "${JSONC_INSTALL}/lib/libjson-c.a" ]]; then - if [ -d "${jsonc_build}" ]; then - rm -rf "${jsonc_build}" - fi + if [ -d "${jsonc_build}" ]; then + rm -rf "${jsonc_build}" + fi mkdir -p "${jsonc_build}" - pushd ${jsonc_build} - wget https://s3.amazonaws.com/json-c_releases/releases/json-c-0.12.1.tar.gz -O json-c.tar.gz + pushd "${jsonc_build}" + wget https://s3.amazonaws.com/json-c_releases/releases/json-c-"${RECOMMENDED_JSONC_VERSION}".tar.gz -O json-c.tar.gz tar xzf json-c.tar.gz --strip 1 autoreconf -ivf - env CFLAGS="-fno-omit-frame-pointer -g" ./configure --prefix="${JSONC_PREFIX}" - ${MAKE} -j${CORES} install + env CFLAGS="-fno-omit-frame-pointer -Wno-implicit-fallthrough -g" ./configure --prefix="${JSONC_INSTALL}" + ${MAKE} -j"${MAKE_PARALLEL}" install popd -fi + fi +} + +export LOCAL_BUILDS="${DEPS_BUILD_DIR}" +export JSONC_INSTALL="${JSONC_PREFIX}" +export RECOMMENDED_JSONC_VERSION="${JSONC_VERSION:-0.12.1}" + +install_jsonc diff --git a/ci/install_rnp.sh b/ci/install_rnp.sh index 7ca14de..1b2d125 100755 --- a/ci/install_rnp.sh +++ b/ci/install_rnp.sh @@ -13,10 +13,10 @@ set -eux rnp_build="${DEPS_BUILD_DIR}/rnp" -if [ ! -e "${RNP_PREFIX}/lib/librnp.so" ] && \ - [ ! -e "${RNP_PREFIX}/lib/librnp.dylib" ]; then +if [[ ! -e "${RNP_PREFIX}/lib/librnp.so" ]] && \ + [[ ! -e "${RNP_PREFIX}/lib/librnp.dylib" ]]; then - git clone https://github.com/riboseinc/rnp ${rnp_build} + git clone https://github.com/riboseinc/rnp "${rnp_build}" pushd "${rnp_build}" git checkout "$RNP_VERSION" cmake \ diff --git a/enmail.gemspec b/enmail.gemspec index d174cfd..e38b617 100644 --- a/enmail.gemspec +++ b/enmail.gemspec @@ -44,5 +44,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", ">= 10", "< 13" spec.add_development_dependency "rnp", *EnMail::DependencyConstraints::RNP spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rspec-pgp_matchers", "~> 0.1.1" + spec.add_development_dependency "rspec-pgp_matchers", "~> 0.2.0" end diff --git a/spec/support/expect_correct_gpg_version.rb b/spec/support/expect_correct_gpg_version.rb index 8822d25..485582b 100644 --- a/spec/support/expect_correct_gpg_version.rb +++ b/spec/support/expect_correct_gpg_version.rb @@ -1,7 +1,7 @@ # (c) Copyright 2018 Ribose Inc. # -expected_gpg_version = ENV.fetch("EXPECT_GPG_VERSION", nil) +expected_gpg_version = ENV.fetch("EXPECTED_GPG_VERSION", nil) if expected_gpg_version && ENV.fetch("TEST_WITHOUT_GPGME", nil).nil? require "gpgme"