Skip to content

Commit

Permalink
Workflow refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Oct 20, 2022
1 parent 61a85b0 commit d5785a6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 27 deletions.
74 changes: 49 additions & 25 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ concurrency:
cancel-in-progress: true

env:
BUNDLER_VER: 2.3.22
BUNDLER_VER: 2.3.24
# Forcing bundler version to ensure that it is consistent everywhere and
# does not cause bundler gem reinstalls
# bundler/rubygems 2.3.22 is a minimal requirement to support gnu/musl differentiation
# https://github.com/rubygems/rubygems/pull/4488
#
# 2.3.23 is broken

jobs:
pack:
Expand Down Expand Up @@ -70,29 +72,12 @@ jobs:
name: build-logs-${{ matrix.platform }}
path: tmp/*/ports/*/*/*.log

- if: matrix.platform != 'any' && matrix.platform != 'aarch64-linux'
uses: metanorma/metanorma-build-scripts/native-deps-action@main
with:
libname: archive
directory: lib/ffi-libarchive-binary

- run: |
cd pkg/
gem unpack ffi-libarchive-binary-*.gem
ls */lib/ffi-libarchive-binary
- uses: actions/upload-artifact@v3
with:
name: pkg
path: pkg/*.gem

- if: matrix.platform != 'any'
uses: actions/upload-artifact@v3
with:
name: lib-${{ matrix.platform }}
path: lib/ffi-libarchive-binary/libarchive*

test:
test-binary:
needs: pack
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -110,18 +95,57 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: pkg
path: pkg

- name: Setup ffi-libarchive-binary
run: |
gem unpack --target pkg pkg/ffi-libarchive-binary-*-${{ matrix.platform }}.gem
mv pkg/ffi-libarchive-binary-*-${{ matrix.platform }} pkg/ffi-libarchive-binary
echo "gem 'ffi-libarchive-binary', path: 'pkg/ffi-libarchive-binary'" > Gemfile.devel
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: ${{ env.BUNDLER_VER }}
bundler-cache: true

- run: bundle exec rake spec

test-any:
needs: pack
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ruby: [ '2.7', '3.0', '3.1' ]
os: [ windows-latest, macos-latest, ubuntu-latest ]

steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: lib-${{ matrix.platform }}
path: lib/ffi-libarchive-binary
name: pkg
path: pkg

- name: Setup ffi-libarchive-binary
run: |
rm pkg/ffi-libarchive-binary-*-*.gem
gem unpack --target pkg pkg/ffi-libarchive-binary-*.gem
rm -rf pkg/*.gem
mv pkg/ffi-libarchive-binary-* pkg/ffi-libarchive-binary
echo "gem 'ffi-libarchive-binary', path: 'pkg/ffi-libarchive-binary'" > Gemfile.devel
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: ${{ env.BUNDLER_VER }}
bundler-cache: true

- run: bundle exec rspec
- run: bundle exec rake spec

metanorma:
needs: pack
Expand Down Expand Up @@ -165,15 +189,15 @@ jobs:
echo "gem 'ffi-libarchive-binary', path: 'pkg/ffi-libarchive-binary'" > Gemfile.devel
# https://github.com/rubygems/rubygems/issues/5160
- if: matrix.ruby == '3.0' && matrix.os != 'windows-latest'
- if: matrix.ruby == '3.0'
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: ${{ env.BUNDLER_VER }}
rubygems: latest

- if: matrix.ruby != '3.0' || matrix.os == 'windows-latest'
- if: matrix.ruby != '3.0'
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand All @@ -185,7 +209,7 @@ jobs:
# ----- Release -----
release:
name: Release gem
needs: [ pack, test, metanorma ]
needs: [ test-binary, test-any, metanorma ]
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/v')
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= Binaries for ffi-libarchive

image:https://img.shields.io/gem/v/ffi-libarchive-binary.svg["Gem Version", link="https://rubygems.org/gems/ffi-libarchive-binary"]
image:https://github.com/fontist/ffi-libarchive-binary/actions/workflows/rspec.yml/badge.svg["Build Status", link="https://github.com/fontist/ffi-libarchive-binary/actions/workflows/rspec.yml"]
image:https://github.com/fontist/ffi-libarchive-binary/actions/workflows/test-and-release.yml/badge.svg["Build Status", link="https://github.com/fontist/ffi-libarchive-binary/actions/workflows/test-and-release.yml"]

== Purpose

Expand Down
2 changes: 1 addition & 1 deletion ffi-libarchive-binary.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|

spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject do |f|
f.match(%r{\A(?:test|spec|features|bin|.github)/})
f.match(%r{\A(?:test|spec|features|bin|.github|toolchain)/})
end
end

Expand Down

0 comments on commit d5785a6

Please sign in to comment.