From a1d05db9f1a444ab67bba98dcbf5383a56984aac Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 20 May 2021 01:45:54 -0400 Subject: [PATCH] ci: attempt to test packaging and installing a gem --- .github/workflows/gem-install.yml | 99 +++++++++++++++++++++++++++++++ scripts/test-gem-build | 39 ++++++++++++ scripts/test-gem-install | 41 +++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 .github/workflows/gem-install.yml create mode 100755 scripts/test-gem-build create mode 100755 scripts/test-gem-install diff --git a/.github/workflows/gem-install.yml b/.github/workflows/gem-install.yml new file mode 100644 index 00000000000..474b9f4c13e --- /dev/null +++ b/.github/workflows/gem-install.yml @@ -0,0 +1,99 @@ +name: gem-install +on: + workflow_dispatch: + push: + branches: + - main + - v*.*.x + tags: + - v*.*.* + pull_request: + types: [opened, synchronize] + branches: + - '*' + +jobs: + cruby-package: + name: "cruby-package" + runs-on: ubuntu-latest + container: + image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.1.0" + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ports/archives + key: tarballs-${{hashFiles('**/dependencies.yml')}} + restore-keys: tarballs- + - run: ./scripts/test-gem-build gems ruby + - uses: actions/upload-artifact@v2 + with: + name: cruby-gem + path: gems + retention-days: 1 + + cruby-linux-install: + needs: ["cruby-package"] + strategy: + fail-fast: false + matrix: + sys: ["enable", "disable"] + runs-on: ubuntu-latest + container: + image: "flavorjones/nokogiri-test:mri-3.0" + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: cruby-gem + path: gems + - run: ./scripts/test-gem-install gems --${{matrix.sys}}-system-libraries + + cruby-osx-install: + needs: ["cruby-package"] + strategy: + fail-fast: false + matrix: + sys: ["enable", "disable"] + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: cruby-gem + path: gems + - run: ./scripts/test-gem-install gems --${{matrix.sys}}-system-libraries + + cruby-windows-install: + needs: ["cruby-package"] + strategy: + fail-fast: false + matrix: + sys: ["enable", "disable"] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: cruby-gem + path: gems + - run: ./scripts/test-gem-install gems --${{matrix.sys}}-system-libraries + + cruby-x86_64-package: + name: "cruby-x86_64-package" + runs-on: ubuntu-latest + container: + image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.1.0" + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ports/archives + key: tarballs-${{hashFiles('**/dependencies.yml')}} + restore-keys: tarballs- + - run: ./scripts/test-gem-build gems x86_64-linux + - uses: actions/upload-artifact@v2 + with: + name: cruby-x86_64-gem + path: gems + retention-days: 1 diff --git a/scripts/test-gem-build b/scripts/test-gem-build new file mode 100755 index 00000000000..4f764559917 --- /dev/null +++ b/scripts/test-gem-build @@ -0,0 +1,39 @@ +#! /usr/bin/env bash +# +# run as part of CI, see gem-install.yml +# +if [[ $# -lt 2 ]] ; then + echo "usage: $(basename $0) " + exit 1 +fi + +OUTPUT_DIR=$1 +BUILD_NATIVE_GEM=$2 + +test -e /etc/os-release && cat /etc/os-release + +if [[ "${BUILD_NATIVE_GEM}" != "ruby" ]] ; then + # normally part of rake-compiler-dock runas which we can't easily use in concourse + . /etc/rubybashrc + ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler + export RAKE_EXTENSION_TASK_NO_NATIVE=true +fi + +set -e -x -u + +bundle install --local || bundle install +bundle exec rake set-version-to-timestamp + +if [[ "${BUILD_NATIVE_GEM}" == "ruby" ]] ; then + # TODO we're only compiling so that we retrieve libxml2/libxslt tarballs, we can do better. + bundle exec rake clean compile + bundle exec rake gem +else + bundle exec rake gem:${BUILD_NATIVE_GEM}:builder FORCE_CROSS_COMPILING=true +fi + +./scripts/test-gem-file-contents pkg/nokogiri*.gem + +mkdir -p ${OUTPUT_DIR} +cp -v pkg/nokogiri*.gem ${OUTPUT_DIR} +sha256sum ${OUTPUT_DIR}/* diff --git a/scripts/test-gem-install b/scripts/test-gem-install new file mode 100755 index 00000000000..21c0aa900e5 --- /dev/null +++ b/scripts/test-gem-install @@ -0,0 +1,41 @@ +#! /usr/bin/env bash +# +# run as part of CI, see gem-install.yml +# +if [[ $# -lt 1 ]] ; then + echo "usage: $(basename $0) [install_flags]" + exit 1 +fi + +GEMS_DIR=$1 +shift +INSTALL_FLAGS=$* + +test -e /etc/os-release && cat /etc/os-release + +set -e -x -u + +pushd $GEMS_DIR + + gemfile=$(ls *.gem | head -n1) + sha256sum ${gemfile} + gem install --no-document ${gemfile} -- ${INSTALL_FLAGS} + gem list -d nokogiri + nokogiri -v + +popd + +if [ -n "${BUNDLE_APP_CONFIG:-}" ] ; then + export BUNDLE_CACHE_PATH="${BUNDLE_APP_CONFIG}/cache" +fi + +bundle install --local || bundle install + +rm -rf lib ext # ensure we don't use the local files +rake test + +./scripts/test-gem-installation + +# delete the Gemfile because that's confusing to older versions of rubygems (e.g., bionic32) +rm -f Gemfile Gemfile.lock +./scripts/test-nokogumbo-compatibility