Skip to content

Commit

Permalink
ci: attempt to test packaging and installing a gem
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed May 20, 2021
1 parent 73e8592 commit a1d05db
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/gem-install.yml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions scripts/test-gem-build
Original file line number Diff line number Diff line change
@@ -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) <output_dir> <platform>"
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}/*
41 changes: 41 additions & 0 deletions scripts/test-gem-install
Original file line number Diff line number Diff line change
@@ -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) <gems_dir> [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

0 comments on commit a1d05db

Please sign in to comment.