Skip to content

Commit

Permalink
Merge pull request #352 from sparklemotion/351-fix-tarball-packaging
Browse files Browse the repository at this point in the history
fix: sqlite tarball packaging
  • Loading branch information
flavorjones authored Sep 30, 2022
2 parents 8ab3ecc + d37f248 commit 5ab9cd8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gem-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/cache@v3
with:
path: ports/archives
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb')}}
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb','dependencies.yml')}}
- uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: "3.1"
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/cache@v3
with:
path: ports/archives
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb')}}
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb','dependencies.yml')}}
- uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: "3.1"
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
- uses: actions/cache@v3
with:
path: ports/archives
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb')}}
key: ports-archives-tarball-${{hashFiles('ext/sqlite3/extconf.rb','dependencies.yml')}}
- run: |
docker run --rm -v "$(pwd):/sqlite3" -w /sqlite3 \
larskanis/rake-compiler-dock-mri-${{matrix.plat}}:1.2.1 \
Expand Down
7 changes: 5 additions & 2 deletions bin/test-gem-file-contents
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ describe File.basename(gemfile) do
end

it "contains the port files" do
# TODO: once Ruby 2.7 is no longer supported, use symbolize_names: true
dependencies = YAML.load_file(File.join(__dir__, "..", "dependencies.yml"))
sqlite_tarball = File.basename(dependencies[:sqlite3][:files].first[:url])
actual_ports = gemfile_contents.grep(%r{^ports/})
assert_equal(1, actual_ports.count { |f| File.fnmatch?("ports/archives/sqlite-autoconf-*.tar.gz", f) })
assert_equal(1, actual_ports.length)

assert_equal(["ports/archives/#{sqlite_tarball}"], actual_ports)
end

it "contains the patch files" do
Expand Down
14 changes: 14 additions & 0 deletions dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TODO: stop using symbols here once we no longer support Ruby 2.7 and can rely on symbolize_names
:sqlite3:
# checksum verified by first checking the published sha3(256) checksum against https://sqlite.org/download.html:
#
# $ sha3sum -a 256 ports/archives/sqlite-autoconf-3390400.tar.gz
# 431328e30d12c551da9ba7ef2122b269076058512014afa799caaf62ca567090 ports/archives/sqlite-autoconf-3390400.tar.gz
#
# $ sha256sum ports/archives/sqlite-autoconf-3390400.tar.gz
# f31d445b48e67e284cf206717cc170ab63cbe4fd7f79a82793b772285e78fdbb ports/archives/sqlite-autoconf-3390400.tar.gz
#
:version: "3.39.4"
:files:
- :url: "https://sqlite.org/2022/sqlite-autoconf-3390400.tar.gz"
:sha256: "f31d445b48e67e284cf206717cc170ab63cbe4fd7f79a82793b772285e78fdbb"
20 changes: 3 additions & 17 deletions ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "mkmf"
require "mini_portile2"
require "yaml"

module Sqlite3
module ExtConf
Expand Down Expand Up @@ -131,23 +132,8 @@ def sqlite3_config
end

def mini_portile_config
{
sqlite3: {
# checksum verified by first checking the published sha3(256) checksum against https://sqlite.org/download.html:
#
# $ sha3sum -a 256 ports/archives/sqlite-autoconf-3390400.tar.gz
# 431328e30d12c551da9ba7ef2122b269076058512014afa799caaf62ca567090 ports/archives/sqlite-autoconf-3390400.tar.gz
#
# $ sha256sum ports/archives/sqlite-autoconf-3390400.tar.gz
# f31d445b48e67e284cf206717cc170ab63cbe4fd7f79a82793b772285e78fdbb ports/archives/sqlite-autoconf-3390400.tar.gz
#
version: "3.39.4",
files: [{
url: "https://sqlite.org/2022/sqlite-autoconf-3390400.tar.gz",
sha256: "f31d445b48e67e284cf206717cc170ab63cbe4fd7f79a82793b772285e78fdbb",
}],
}
}
# TODO: once Ruby 2.7 is no longer supported, use symbolize_names: true
YAML.load_file(File.join(package_root_dir, "dependencies.yml"))
end

def abort_could_not_find(missing)
Expand Down
6 changes: 5 additions & 1 deletion rakelib/native.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require "bundler/gem_tasks"
require "rubygems/package_task"
require "rake/extensiontask"
require "rake_compiler_dock"
require "yaml"

cross_rubies = ["3.1.0", "3.0.0", "2.7.0", "2.6.0"]
cross_platforms = [
Expand Down Expand Up @@ -41,7 +42,10 @@ def add_file_to_gem(relative_source_path)
end

task gem_build_path do
archive = Dir.glob(File.join("ports", "archives", "sqlite-autoconf-*.tar.gz")).first
# TODO: once Ruby 2.7 is no longer supported, use symbolize_names: true
dependencies = YAML.load_file(File.join(__dir__, "..", "dependencies.yml"))
sqlite_tarball = File.basename(dependencies[:sqlite3][:files].first[:url])
archive = Dir.glob(File.join("ports", "archives", sqlite_tarball)).first
add_file_to_gem(archive)

patches = %x(#{["git", "ls-files", "patches"].shelljoin}).split("\n").grep(/\.patch\z/)
Expand Down
1 change: 1 addition & 0 deletions sqlite3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Gem::Specification.new do |s|
"LICENSE",
"LICENSE-DEPENDENCIES",
"README.md",
"dependencies.yml",
"ext/sqlite3/aggregator.c",
"ext/sqlite3/aggregator.h",
"ext/sqlite3/backup.c",
Expand Down

0 comments on commit 5ab9cd8

Please sign in to comment.