diff --git a/.github/workflows/gem-install.yml b/.github/workflows/gem-install.yml index 01ffb3df..0c523a83 100644 --- a/.github/workflows/gem-install.yml +++ b/.github/workflows/gem-install.yml @@ -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" @@ -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" @@ -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 \ diff --git a/bin/test-gem-file-contents b/bin/test-gem-file-contents index e8e10bdf..f76579bd 100755 --- a/bin/test-gem-file-contents +++ b/bin/test-gem-file-contents @@ -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 diff --git a/dependencies.yml b/dependencies.yml new file mode 100644 index 00000000..279eff0d --- /dev/null +++ b/dependencies.yml @@ -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" diff --git a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb index fcf5d568..9a9a7caf 100644 --- a/ext/sqlite3/extconf.rb +++ b/ext/sqlite3/extconf.rb @@ -1,5 +1,6 @@ require "mkmf" require "mini_portile2" +require "yaml" module Sqlite3 module ExtConf @@ -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) diff --git a/rakelib/native.rake b/rakelib/native.rake index e2ec4664..89cea4b1 100644 --- a/rakelib/native.rake +++ b/rakelib/native.rake @@ -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 = [ @@ -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/) diff --git a/sqlite3.gemspec b/sqlite3.gemspec index 662cfd5a..c5f2b2d3 100644 --- a/sqlite3.gemspec +++ b/sqlite3.gemspec @@ -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",