diff --git a/.buildkite/test-indexer.sh b/.buildkite/test-indexer.sh index ba99e36192..09319a18fd 100755 --- a/.buildkite/test-indexer.sh +++ b/.buildkite/test-indexer.sh @@ -79,21 +79,11 @@ test_args=( --test_output=errors \ "${test_args[@]}" || err=$? -echo "--- Installing Ruby" - -if (! file /root/.asdf/installs/ruby/2.7.0) || (! asdf global ruby 2.7.0); then - rm -rf .asdf/shims - OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration asdf install ruby - asdf global ruby 2.7.0 -fi - echo "+++ Running repo tests" test_args=( "//test/scip/repos" "-c" "opt" - "--test_env" "PATH=${PATH}" - "--test_env" "HOME=${HOME}" "--config=forcedebug" "--spawn_strategy=local" ) @@ -106,6 +96,23 @@ test_args=( --test_output=errors \ "${test_args[@]}" || err=$? +echo "+++ Running packaging tests" + +test_args=( + "//test/scip/packaging" + "-c" "opt" + "--config=forcedebug" + "--spawn_strategy=local" +) + +./bazel test \ + --experimental_generate_json_trace_profile \ + --profile=_out_/profile_packaging_tests.json \ + --experimental_execution_log_file=_out_/packaging_test.log \ + --test_summary=terse \ + --test_output=errors \ + "${test_args[@]}" || err=$? + if [ "$err" -ne 0 ]; then echo "--- annotating build result" failing_tests="$(mktemp)" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7d4f46837..a8bf90e1bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,35 +43,7 @@ jobs: path: log - name: "🏋️‍♂️ Run tests" run: ./bazel test //test/scip --config=dbg - # Repo tests are kinda' broken right now because the bundle cache step needs synchronization - # - # - name: "🏋️‍♂️ Build repo tests" - # continue-on-error: true - # run: | - # sudo apt-get install --reinstall build-essential - # ls "$(dirname "$(command -v gcc)")" - # echo "$PATH" - # ls /usr/bin /usr/local/bin /bin - # # Technically, this is for Ruby 2.7.0 but it's probably fine. - # sudo apt-get install ruby2.7-dev - # ./bazel test //test/scip/repos --test_env GITHUB_ACTIONS=1 --test_env GEM_PATH="$(dirname "$(command -v gem)")" --config=dbg - # - # Blocked on a bundler bug in 2.3.4. I get a crash trace like this when running locally. - # - # NoMethodError: undefined method `metadata' for nil:NilClass - # /Users/varun/Code/scip-ruby/.cache_ruby/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/common.rb:22:in `block in output_fund_metadata_summary' - # /Users/varun/Code/scip-ruby/.cache_ruby/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/common.rb:22:in `count' - # /Users/varun/Code/scip-ruby/.cache_ruby/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/common.rb:22:in `output_fund_metadata_summary' - # /Users/varun/Code/scip-ruby/.cache_ruby/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.3.4/lib/bundler/cli/install.rb:87:in `run' - # - # This is the method in question: - # - # def self.output_fund_metadata_summary - # definition = Bundler.definition - # current_dependencies = definition.requested_dependencies - # current_specs = definition.specs - # - # count = current_dependencies.count {|dep| current_specs[dep.name].first.metadata.key?("funding_uri") } - # ^ boom! - # We should probably file a bug against bundler but I haven't been able to repro - # the issue outside of a Bazel sandbox yet. + - name: "🏋️‍♂️ Run repo tests" + run: ./bazel test //test/scip/repos --config=dbg + - name: "🏋️‍♂️ Run packaging tests" + run: ./bazel test //test/scip/packaging --config=dbg diff --git a/docs/scip-ruby/CONTRIBUTING.md b/docs/scip-ruby/CONTRIBUTING.md index 2409252abe..6d2fb8c30e 100644 --- a/docs/scip-ruby/CONTRIBUTING.md +++ b/docs/scip-ruby/CONTRIBUTING.md @@ -44,8 +44,8 @@ see the [Design Decisions doc][]. ## Configuring Ruby (optional) -If you're going to be running the repository tests or building the -scip-ruby gem locally, follow these steps before building stuff. +If you're going to be building the scip-ruby gem locally, follow these steps +before building stuff. ### macOS pre-requisites @@ -180,19 +180,15 @@ Snapshot outputs can be easily updated: ./bazel test --config=dev //test/scip:update_alias ``` -Repo tests are kinda' broken right now; they're disabled -in CI (see ci.yml), and may or may not work on your machine. - -If you want to run repo tests, first complete the -[Configuring Ruby](#configuring-ruby-optional) steps. -Then run the tests using: +Repo tests index pinned OSS projects using the `scip-ruby` binary built from +this checkout. Run them using: ```bash -# If Ruby was installed via asdf (recommended to avoid dependency on system Ruby on macOS) ./bazel test //test/scip/repos --config=dev ``` -This may take a few minutes to run. +These tests currently check that indexing succeeds and creates a non-empty +`index.scip` file. ### Writing a new snapshot test @@ -210,26 +206,20 @@ and follow the same structure. ### Writing a new repo test -First, clone the repo using Sorbet locally -and check if you can index it. -Typically, the commands will be something like: +First, add the project archive information to +[`third_party/test_gem_data.bzl`](../../third_party/test_gem_data.bzl). +The archive should be pinned to a specific version and checksum. -```bash -BUNDLE_WITH=sorbet bundle install +Then check that the project can be indexed with the built binary. Typically, +the command will look like: -# Replace srb binary with scip-ruby binary -cp /path/to/scip-ruby "$(find . -name 'srb' -type f | head -n 1)" -bundle exec srb --index-file index.scip --gem-metadata "name@version" -``` - -In case there are any type errors, create a patch and save it: ```bash -git diff > /path/to/test/scip/repos/name-version.patch +./bazel build //main:scip-ruby --config=dev +./bazel-bin/main/scip-ruby --index-file index.scip --gem-metadata "name@version" ``` -Once you're able to successfully index the code, -modify the [scip_repos_test.bzl](test/scip/repos/scip_repos_test.bzl) -file to include the relevant data. +Once you're able to successfully index the code, run +`./bazel test //test/scip/repos --config=dev`. ## Debugging diff --git a/docs/scip-ruby/DESIGN.md b/docs/scip-ruby/DESIGN.md index c60a635797..180840219e 100644 --- a/docs/scip-ruby/DESIGN.md +++ b/docs/scip-ruby/DESIGN.md @@ -1,81 +1,56 @@ # Design Decisions -## Repo tests - - - -WARNING: Right now, the repo tests are broken/disabled, -so this information is a bit inaccurate. We should fix -this once the repo tests are fixed. +## Repo tests and packaging tests have separate jobs -The repo tests have a couple of unusual things: -#. Tests are broken up into 3 stages, - instead of being a simple script that does clone - + apply patch + invoke dev tool (`scip-ruby`). -#. There is "manual" caching going on for the intermediate results - of these steps. The cache cannot be used in parallel; repo tests run serially. +Repo tests and packaging tests intentionally cover different risks. -I'll cover each of these one-by-one. +Repo tests answer: "Can the indexer built from this checkout process real Ruby +projects?" They use the built `scip-ruby` binary directly against pinned OSS +projects. -Some constraints to keep in mind while reading the sections below: -#. We want to run tests using as close to "real-world" tools (such as Bundler) - as possible instead of trying to mimic what they do. -#. We want to cache intermediate results as much as possible, - as many steps in Ruby installation + Gem installation are slow. -#. Tests should hopefully run reasonably quickly, especially if you only - modify the indexer (most common situation). -#. Tests should be isolated from each other. We don't one test to "install" - `scip-ruby` and have that be visible to another test. +Packaging tests answer: "Can the packaged gem be installed and run the way a +user would get it?" They install the built gem into a small temporary Ruby +project and run `scip-ruby` from that installation. -Before going into details about the caching, first let's cover -an outline of the 3 stages. -### 3 stages of repo tests +Keeping these tests separate makes each failure easier to understand. A repo +test failure points at indexing behavior on a real project. A packaging test +failure points at gem building, gem installation, Bundler setup, or the packaged +launcher. -#. Create a standalone ruby installation: This is cached - and the installation is blown away. -#. Test prep: This step involves installing the dependencies of the gem, - including any custom bundler version it may require. - The pristine toolchain from the first step is extracted - and we run `bundle cache`. - After this is done, the _entire_ Ruby toolchain is cached again - (because it will be have been modified by `bundle cache`). - The modified source tree is also cached (I tried `--frozen` earlier but - ran into some error with it that I didn't have time to look into). -#. Index: This step reuses the two caches from the previous step, - applies a patch, copies the `scip-ruby` gem into the `vendor/cache` - directory, runs `bundle install --local` (so nothing should be - fetched from the internet). Now, everything is in a state which mostly - mimics what a user would have. Then we invoke `scip-ruby` normally. - -Intermediate results use tarballs for caching directory trees instead of copying -directories because it seemed much simpler to deal with a tarball in Bazel. +## Repo tests -Why do we go through all this trouble to cache things "manually"? -### Manual caching + -Here are some obstacles the caching system needs to overcome. +Repo tests exercise `scip-ruby` against pinned, real-world OSS projects. +They intentionally do not install the `scip-ruby` gem into those projects. +Instead, each test: -* Ruby installation is [path-dependent](https://github.com/ruby/setup-ruby#using-self-hosted-runners). -* Ruby installation is relatively slow as it builds everything from source: - it takes a few minutes even on a Macbook Pro. - Installing it per-test would be too time-consuming. +1. unpacks a pinned source archive into a fresh temporary directory, +2. runs the `scip-ruby` binary built from this checkout, +3. passes explicit gem metadata for the project, and +4. checks that a non-empty `index.scip` file was created. -These two factors together imply that we should cache a Ruby installation -inside a stable directory, not a temporary test directory. +This keeps the tests focused on whether the current indexer can process a +real project. It avoids modifying third-party lockfiles, installing a freshly +built gem through Bundler, or mutating a shared Ruby installation while the test +runs. -Additionally, we only want one Ruby toolchain cache; to ensure test isolation, -we run them in serial on the same directory (a GIL for the test suite). +The current check is intentionally lightweight. -* We want to ensure reproducibility, and not mess with the global environment. +## Packaging tests -To achieve this, we delete the toolchain directory at the start of a test, -and restore it from the cache in the 'Test prep' step. +Packaging tests exercise the built `scip-ruby` gem, not just the built binary. +They intentionally use a small fixture project instead of the pinned OSS +projects used by repo tests. Each test: -### Bonus: Bundler weirdness +1. builds a gem for the current platform, +2. creates a temporary Ruby project, +3. installs that gem through Bundler from a local cache, +4. runs the installed `scip-ruby` command against a sample Ruby file, and +5. checks that a non-empty `index.scip` file was created. -If you run `bundle install --local` for a test gem X, -after copying an updated `scip-ruby` gem (same version, new checksum) -into X's `vendor/cache` directory, -you would naively expect `bundle` to re-install the updated `scip-ruby` gem. -(install = copy/setup stuff in toolchain-adjacent directories) -But `bundle` doesn't actually do that. 🙈 \ No newline at end of file +This keeps packaging coverage focused on the path users rely on when installing +the gem: the gem file, its platform tag, its executable, its bundled binary, and +the Ruby/Bundler environment around it. It avoids making every repo test also +prove gem installation, which would make failures harder to diagnose and would +slow down the real-project coverage. diff --git a/gems/scip-ruby/BUILD b/gems/scip-ruby/BUILD index 604dea881f..bce2857638 100644 --- a/gems/scip-ruby/BUILD +++ b/gems/scip-ruby/BUILD @@ -1,4 +1,4 @@ -load(":build_gems.bzl", "build_gems", "setup_standalone_ruby", "version") +load(":build_gems.bzl", "build_current_platform_gem", "build_gems", "setup_standalone_ruby", "version") version( name = "version", @@ -26,5 +26,26 @@ build_gems( "@platforms//os:linux": "linux", "@platforms//os:osx": "darwin", }), + llvm_libunwind = select({ + "@platforms//os:osx": ["@llvm_toolchain_15_0_6_llvm//:lib/libunwind.1.0.dylib"], + "//conditions:default": [], + }), + visibility = ["//visibility:public"], +) + +build_current_platform_gem( + name = "scip-ruby-current-platform", + srcs = [ + "bin/scip-ruby", + "scip-ruby.template.gemspec", + ], + gem_name = select({ + "//tools/config:dbg": "scip-ruby-debug", + "//conditions:default": "scip-ruby", + }), + llvm_libunwind = select({ + "@platforms//os:osx": ["@llvm_toolchain_15_0_6_llvm//:lib/libunwind.1.0.dylib"], + "//conditions:default": [], + }), visibility = ["//visibility:public"], ) diff --git a/gems/scip-ruby/build_gems.bzl b/gems/scip-ruby/build_gems.bzl index 196358c470..76e99f1620 100644 --- a/gems/scip-ruby/build_gems.bzl +++ b/gems/scip-ruby/build_gems.bzl @@ -48,7 +48,10 @@ def _build_gems(ctx): version = ctx.attr._version[VersionProvider].version name = ctx.attr.gem_name os = ctx.attr.gem_target_os - darwin_versions = [22, 23] + + # Keep this list in step with macOS versions that should be able to install + # the packaged gem through Bundler. + darwin_versions = [22, 23, 24] if os == "darwin": outs = [ "{}-{}-arm64-darwin-{}.gem".format(name, version, dv) @@ -62,6 +65,13 @@ def _build_gems(ctx): for src in ctx.attr.srcs: inputs += src.files.to_list() inputs.append(ctx.file._scip_ruby_binary) + inputs += ctx.files.llvm_libunwind + + llvm_libunwind = "" + if ctx.files.llvm_libunwind: + if len(ctx.files.llvm_libunwind) != 1: + fail("Expected one libunwind input") + llvm_libunwind = ctx.files.llvm_libunwind[0].short_path ctx.actions.run( outputs = output_files, @@ -74,12 +84,54 @@ def _build_gems(ctx): "VERSION": version, "DARWIN_VERSIONS": " ".join([str(dv) for dv in darwin_versions]), "SCIP_RUBY_BINARY": ctx.file._scip_ruby_binary.path, + "LLVM_LIBUNWIND": llvm_libunwind, "OUT_DIR": output_files[0].dirname, }, ) runfiles = ctx.runfiles(files = output_files) return [DefaultInfo(files = depset(output_files), runfiles = runfiles)] +# Build one gem for the same platform as the machine running this action. +# This is useful for local packaging tests, where we want to install and run +# the gem immediately instead of producing every release platform variant. +def _build_current_platform_gem(ctx): + version = ctx.attr._version[VersionProvider].version + name = ctx.attr.gem_name + output_file = ctx.actions.declare_file("{}-{}-current-platform.gem".format(name, version)) + + inputs = ctx.attr._build_script.files.to_list() + for src in ctx.attr.srcs: + inputs += src.files.to_list() + inputs.append(ctx.file._scip_ruby_binary) + inputs += ctx.files.llvm_libunwind + + llvm_libunwind = "" + if ctx.files.llvm_libunwind: + if len(ctx.files.llvm_libunwind) != 1: + fail("Expected one libunwind input") + llvm_libunwind = ctx.files.llvm_libunwind[0].short_path + + ctx.actions.run( + outputs = [output_file], + inputs = inputs, + mnemonic = "BuildCurrentSCIPRubyGem", + executable = ctx.file._build_script, + # The macOS platform tag is chosen inside the build script from the + # machine running the action. Do not reuse this output across machines. + execution_requirements = {"no-cache": "1"}, + env = { + "CURRENT_PLATFORM_GEM_OUT": output_file.path, + "DARWIN_VERSIONS": "current", + "EXTERNAL_GEM_EXE": ctx.var["EXTERNAL_GEM_EXE"], + "LLVM_LIBUNWIND": llvm_libunwind, + "NAME": name, + "OUT_DIR": output_file.dirname, + "SCIP_RUBY_BINARY": ctx.file._scip_ruby_binary.path, + "VERSION": version, + }, + ) + return [DefaultInfo(files = depset([output_file]), runfiles = ctx.runfiles(files = [output_file]))] + build_gems = rule( implementation = _build_gems, attrs = { @@ -91,6 +143,20 @@ build_gems = rule( "_standalone_ruby_tgz": attr.label(default = "//gems/scip-ruby:standalone-ruby", allow_single_file = True), "gem_name": attr.string(), "gem_target_os": attr.string(), + "llvm_libunwind": attr.label_list(allow_files = True), }, doc = "Builds gems for scip-ruby using 'gem build'.", ) + +build_current_platform_gem = rule( + implementation = _build_current_platform_gem, + attrs = { + "_version": attr.label(default = ":version"), + "_build_script": attr.label(default = "build_scip_ruby_gems.sh", allow_single_file = True), + "srcs": attr.label_list(allow_files = True), + "_scip_ruby_binary": attr.label(default = "//main:scip-ruby", allow_single_file = True), + "gem_name": attr.string(), + "llvm_libunwind": attr.label_list(allow_files = True), + }, + doc = "Builds the scip-ruby gem for the machine running the build.", +) diff --git a/gems/scip-ruby/build_scip_ruby_gems.sh b/gems/scip-ruby/build_scip_ruby_gems.sh index 42981df638..59a8493507 100755 --- a/gems/scip-ruby/build_scip_ruby_gems.sh +++ b/gems/scip-ruby/build_scip_ruby_gems.sh @@ -29,6 +29,16 @@ if [ ! -f "$EXTERNAL_GEM_EXE" ]; then exit 1 fi +if [ -n "${LLVM_LIBUNWIND:-}" ]; then + if [ ! -f "$LLVM_LIBUNWIND" ] && [[ "$LLVM_LIBUNWIND" == ../* ]]; then + LLVM_LIBUNWIND="../../external/${LLVM_LIBUNWIND#../}" + fi + case "$LLVM_LIBUNWIND" in + /*) ;; + *) LLVM_LIBUNWIND="$PWD/$LLVM_LIBUNWIND" ;; + esac +fi + GEM_EXE="$EXTERNAL_GEM_EXE" file "$GEM_EXE" @@ -39,9 +49,22 @@ cat scip-ruby.template.gemspec \ > "$GEMSPEC" if [ "$(uname -s)" == "Darwin" ]; then + if [ -z "${LLVM_LIBUNWIND:-}" ]; then + echo "Missing LLVM_LIBUNWIND for Darwin gem build" + exit 1 + fi + cp -L "$LLVM_LIBUNWIND" native/libunwind.1.dylib + install_name_tool -add_rpath @executable_path native/scip-ruby + sed -i.bak "s|\['native/scip-ruby'\]|['native/scip-ruby', 'native/libunwind.1.dylib']|" "$GEMSPEC" + rm "$GEMSPEC.bak" + # Darwin 22 ~ macOS 13 (Ventura) was released in late-2022. # We can publish older releases if someone asks for them. - DARWIN_VERSIONS=($DARWIN_VERSIONS) + if [ "${CURRENT_PLATFORM_GEM_OUT:-}" ]; then + DARWIN_VERSIONS=("$(uname -r | cut -d. -f1)") + else + DARWIN_VERSIONS=($DARWIN_VERSIONS) + fi for i in "${DARWIN_VERSIONS[@]}"; do sed -i.bak "s/Gem::Platform::CURRENT/'arm64-darwin-$i'/" "$GEMSPEC" "$GEM_EXE" build "$GEMSPEC" @@ -53,4 +76,13 @@ fi popd -mv out/*.gem "$OUT_DIR/" +if [ "${CURRENT_PLATFORM_GEM_OUT:-}" ]; then + gems=(out/*.gem) + if [ "${#gems[@]}" -ne 1 ]; then + echo "Expected one current-platform gem, found ${#gems[@]}" + exit 1 + fi + mv "${gems[0]}" "$CURRENT_PLATFORM_GEM_OUT" +else + mv out/*.gem "$OUT_DIR/" +fi diff --git a/gems/scip-ruby/install_standalone_ruby.sh b/gems/scip-ruby/install_standalone_ruby.sh index 98f65aeebd..26de728072 100755 --- a/gems/scip-ruby/install_standalone_ruby.sh +++ b/gems/scip-ruby/install_standalone_ruby.sh @@ -2,8 +2,11 @@ set -euo pipefail +# Count available CPUs so compiling Ruby can use the machine efficiently. # Remove after https://github.com/rbenv/ruby-build/issues/2024 is fixed. NUM_CPUS="$(getconf _NPROCESSORS_ONLN)" + +# Make sure the caller supplied every path and tool this script needs. ENV_VARS=("SCIP_RUBY_CACHE_RUBY_DIR" "SCIP_RUBY_RBENV_EXE" "RUBY_VERSION_FILE" "OUT_TGZ_PATH" "NUM_CPUS") for ENV_VAR in "${ENV_VARS[@]}"; do if eval "[ -z \"$(printf '${%s:-}' $ENV_VAR)\" ]"; then @@ -11,8 +14,11 @@ for ENV_VAR in "${ENV_VARS[@]}"; do exit 1 fi done + +# Tell Ruby's build process how many parallel jobs it can run. export MAKE_OPTS="-j ${NUM_CPUS:-4}" +# Create the cache directory before installing Ruby or reading an existing copy. mkdir -p "$SCIP_RUBY_CACHE_RUBY_DIR" # Debugging tip: If there is a failure in this step, replace it with: @@ -31,9 +37,13 @@ mkdir -p "$SCIP_RUBY_CACHE_RUBY_DIR" if [[ "$SCIP_RUBY_RBENV_EXE" != "RUNNING_IN_CI_RBENV_NOT_NEEDED" ]]; then # Make ruby-build available to rbenv. export PATH="$(dirname "$SCIP_RUBY_RBENV_EXE"):$PATH" + + # Install the requested Ruby version unless it is already present in the cache. RBENV_ROOT="$SCIP_RUBY_CACHE_RUBY_DIR" "$SCIP_RUBY_RBENV_EXE" install --skip-existing fi +# Write a gzip archive with stable file order and metadata. That makes the +# output repeatable when the input files are the same. compress_deterministic() { if [[ "$(tar --version)" == *"GNU"* ]]; then tar -czf - -C "$1" . --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1993-05-16' @@ -44,7 +54,47 @@ compress_deterministic() { fi } +# Ensure the output directory exists and remove any stale archive at the target +# path before writing the new one. mkdir -p "$(dirname "$OUT_TGZ_PATH")" rm -f "$OUT_TGZ_PATH" -compress_deterministic "$SCIP_RUBY_CACHE_RUBY_DIR" > "$OUT_TGZ_PATH" \ No newline at end of file +# Read the Ruby version this archive should contain. +ruby_version="$(< "$RUBY_VERSION_FILE")" + +# This will be set to the directory that contains the Ruby executable and its +# supporting files. +ruby_install_root="" + +# Prefer the directory shape produced by local Ruby installs. +if [[ -x "$SCIP_RUBY_CACHE_RUBY_DIR/versions/$ruby_version/bin/ruby" ]]; then + ruby_install_root="$SCIP_RUBY_CACHE_RUBY_DIR/versions/$ruby_version" +elif [[ -d "$SCIP_RUBY_CACHE_RUBY_DIR/$ruby_version" ]]; then + # Some preinstalled Rubies put the files one directory deeper. Find the one + # child directory that actually contains a Ruby executable. + ruby_install_roots=() + for candidate in "$SCIP_RUBY_CACHE_RUBY_DIR/$ruby_version"/*; do + if [[ -x "$candidate/bin/ruby" ]]; then + ruby_install_roots+=("$candidate") + fi + done + if [[ ${#ruby_install_roots[@]} -eq 1 ]]; then + ruby_install_root="${ruby_install_roots[0]}" + fi +fi + +# Stop with a clear message if the cache does not contain the requested Ruby. +if [[ -z "$ruby_install_root" ]]; then + echo "Could not find Ruby $ruby_version under $SCIP_RUBY_CACHE_RUBY_DIR" + exit 1 +fi + +# Copy the selected Ruby install into a temporary directory with one predictable +# layout. Consumers of this archive can then always look in versions/. +normalized_root="$(mktemp -d)" +trap 'rm -rf "$normalized_root"' EXIT +mkdir -p "$normalized_root/versions" +cp -a "$ruby_install_root" "$normalized_root/versions/$ruby_version" + +# Compress the normalized directory into the requested output archive. +compress_deterministic "$normalized_root" > "$OUT_TGZ_PATH" diff --git a/test/scip/packaging/BUILD b/test/scip/packaging/BUILD new file mode 100644 index 0000000000..c86ec22ec9 --- /dev/null +++ b/test/scip/packaging/BUILD @@ -0,0 +1,22 @@ +sh_test( + name = "packaged_gem_runs", + size = "medium", + srcs = ["run_packaging_test.sh"], + data = [ + "fixture/sample.rb", + "//:.ruby-version", + "//gems/scip-ruby:scip-ruby-current-platform", + "//gems/scip-ruby:standalone-ruby", + ], + env = { + "RUBY_TGZ": "$(location //gems/scip-ruby:standalone-ruby)", + "RUBY_VERSION_FILE": "$(location //:.ruby-version)", + "SAMPLE_RB": "$(location fixture/sample.rb)", + "SCIP_RUBY_GEM": "$(location //gems/scip-ruby:scip-ruby-current-platform)", + }, +) + +test_suite( + name = "packaging", + tests = [":packaged_gem_runs"], +) diff --git a/test/scip/packaging/fixture/sample.rb b/test/scip/packaging/fixture/sample.rb new file mode 100644 index 0000000000..2803fc7442 --- /dev/null +++ b/test/scip/packaging/fixture/sample.rb @@ -0,0 +1,5 @@ +class PackagingSample + def hello + "hello" + end +end diff --git a/test/scip/packaging/run_packaging_test.sh b/test/scip/packaging/run_packaging_test.sh new file mode 100755 index 0000000000..94d4425966 --- /dev/null +++ b/test/scip/packaging/run_packaging_test.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Make sure the caller told us where to find every file this test needs. +required_env=("RUBY_TGZ" "RUBY_VERSION_FILE" "SAMPLE_RB" "SCIP_RUBY_GEM") +for env_var in "${required_env[@]}"; do + if [[ -z "${!env_var:-}" ]]; then + echo "Missing definition for $env_var environment variable" + exit 1 + fi +done + +# Turn a path into a full path so later directory changes do not break it. +abspath() { + local path="$1" + if [[ "$path" = /* ]]; then + printf '%s\n' "$path" + else + printf '%s/%s\n' "$PWD" "$path" + fi +} + +# Save full paths for each input before the test moves into its work directory. +RUBY_TGZ="$(abspath "$RUBY_TGZ")" +RUBY_VERSION_FILE="$(abspath "$RUBY_VERSION_FILE")" +SAMPLE_RB="$(abspath "$SAMPLE_RB")" +SCIP_RUBY_GEM="$(abspath "$SCIP_RUBY_GEM")" + +# Create a clean place to unpack Ruby and build a small test project. +workdir="${TEST_TMPDIR:-$(mktemp -d)}/scip-ruby-packaging-test" +rm -rf "$workdir" +mkdir -p "$workdir/ruby" "$workdir/project/lib" "$workdir/project/vendor/cache" + +# Unpack the Ruby archive that the packaging test should use. +tar -xzf "$RUBY_TGZ" -C "$workdir/ruby" + +# Find the unpacked Ruby directory. The archive is expected to use one stable +# directory layout no matter where the Ruby files originally came from. +ruby_root="$workdir/ruby/versions/$(< "$RUBY_VERSION_FILE")" + +# Point to the Ruby and Bundler programs inside the unpacked Ruby copy. +ruby_exe="$ruby_root/bin/ruby" +bundle_exe="$ruby_root/bin/bundle" + +# Fail early if the Ruby archive did not contain the programs we need. +for exe in "$ruby_exe" "$bundle_exe"; do + if [[ ! -x "$exe" ]]; then + echo "Expected executable at $exe" + exit 1 + fi +done + +# Read the packaged gem's name and version so the test project can install it. +gem_info="$( + "$ruby_exe" -rrubygems/package -e ' + spec = Gem::Package.new(ARGV.fetch(0)).spec + puts spec.name + puts spec.version + puts spec.full_name + ' "$SCIP_RUBY_GEM" +)" +gem_name="$(printf '%s\n' "$gem_info" | sed -n '1p')" +gem_version="$(printf '%s\n' "$gem_info" | sed -n '2p')" +gem_full_name="$(printf '%s\n' "$gem_info" | sed -n '3p')" + +# Stop if the gem file could not be read correctly. +if [[ -z "$gem_name" || -z "$gem_version" || -z "$gem_full_name" ]]; then + echo "Could not read gem metadata from $SCIP_RUBY_GEM" + exit 1 +fi + +# Put the packaged gem and sample Ruby file into the temporary test project. +cp "$SCIP_RUBY_GEM" "$workdir/project/vendor/cache/$gem_full_name.gem" +cp "$SAMPLE_RB" "$workdir/project/lib/sample.rb" + +# Create a Gemfile that asks for exactly the packaged gem under test. +cat > "$workdir/project/Gemfile" < >(tee stderr.log >&2); then - err="$(< stderr.log)" - while IFS= read -r line; do - if [[ "$line" == *"lib/ruby/gems"*"mkmf.log" ]]; then - echo "----------- Printing likely bad mkmf.log -----------" - cat "$line" - echo "----------------------------------------------------" - fi - done <<< "$err" - exit 1 - fi - set -e - git restore . - popd - compress_deterministic "$TEST_GEM_ZIP_PREFIX" > "$OUT_GEM_WITH_VENDOR_TGZ_PATH" -} - -for arg in "$@"; do - if [[ "$arg" =~ "zip="(.*)":prefix="(.*)":subdir="(.*)":out="(.*) ]]; then - TEST_GEM_ZIP="${BASH_REMATCH[1]}" - TEST_GEM_ZIP_PREFIX="${BASH_REMATCH[2]}" - TEST_GEM_SUBDIR="${BASH_REMATCH[3]}" - OUT_GEM_WITH_VENDOR_TGZ_PATH="${BASH_REMATCH[4]}" - bundle_cache_single_gem - else - echo 'error: Bazel-supplied arguments out-of-sync with expected pattern' - exit 1 - fi -done - -compress_deterministic "$SCIP_RUBY_CACHE_RUBY_DIR" > "$OUT_MODIFIED_TOOLCHAIN_TGZ_PATH" \ No newline at end of file diff --git a/test/scip/repos/index_gem.sh b/test/scip/repos/index_gem.sh deleted file mode 100755 index 1a2d7c4ed3..0000000000 --- a/test/scip/repos/index_gem.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# See NOTE[repo-test-structure] for more context. - -TEST_DIR="$PWD" -ENV_VARS=("SCIP_RUBY_CACHE_RUBY_DIR" "RUBY_VERSION_FILE" "SCIP_RUBY_GEMS" "CACHED_TGZS" "REPO_NAME" "PATCH_PATH") # "PREP_CMD" "RUN_CMD" ) -for ENV_VAR in "${ENV_VARS[@]}"; do - if eval "[ -z \"$(printf '${%s:-}' $ENV_VAR)\" ]"; then - echo "Missing definition for $ENV_VAR environment variable" - exit 1 - fi -done -TEST_NAME="$REPO_NAME" - -# TODO: Librarify this, the env var check, and the GITHUB_ACTIONS var and use it consistently. -get_date() { - date '+%s' -} -PREV_TIME="$(get_date)" -PREV_CMD="" -print_time_elapsed() { - CUR_TIME="$(get_date)" - local DELTA=$(( CUR_TIME - PREV_TIME )) - if [ "$DELTA" -ne 0 ]; then - echo "---------------------------" - echo "Ran in ${DELTA}s: $PREV_CMD" - echo "---------------------------" - fi - PREV_CMD="$BASH_COMMAND" - PREV_TIME="$CUR_TIME" -} -trap print_time_elapsed DEBUG - -if [ -n "${GITHUB_ACTIONS:-}" ]; then - echo "::group::$TEST_NAME" - trap "echo ::end-group::$TEST_NAME" EXIT -fi - -CACHED_TGZS_ARRAY=($CACHED_TGZS) -for CACHED_TGZ in "${CACHED_TGZS_ARRAY[@]}"; do - if [[ "$CACHED_TGZ" == *"/ruby-post-bundle-cache.tgz" ]]; then - rm -rf "$SCIP_RUBY_CACHE_RUBY_DIR" - mkdir -p "$SCIP_RUBY_CACHE_RUBY_DIR" - tar -xzf "$CACHED_TGZ" -C "$SCIP_RUBY_CACHE_RUBY_DIR" - FOUND_TOOLCHAIN_TGZ=1 - else [[ "$CACHED_TGZ" == *"/$REPO_NAME/"* ]]; - rm -rf repo - mkdir repo - tar -xzf "$CACHED_TGZ" -C repo - FOUND_REPO_TGZ=1 - fi -done - -if [[ -z "${FOUND_TOOLCHAIN_TGZ:-}" ]]; then - echo 'error: Did not find toolchain tgz in arguments; was it packaged?' - HAD_ERROR=1 -fi -if [[ -z "${FOUND_REPO_TGZ:-}" ]]; then - echo 'error: Did not find toolchain tgz in arguments; was it packaged?' - HAD_ERROR=1 -fi -if [[ -n "${HAD_ERROR:-}" ]]; then - exit 1 -fi - -SCIP_RUBY_GEMS_ARRAY=($SCIP_RUBY_GEMS) -for SCIP_RUBY_GEM in "${SCIP_RUBY_GEMS_ARRAY[@]}"; do - # NOTE: Keep in sync with scip_repos_test.bzl - if [[ "$SCIP_RUBY_GEM" != *"darwin"* || "$SCIP_RUBY_GEM" == *"20"* ]]; then - cp "$SCIP_RUBY_GEM" repo/vendor/cache/ - fi -done - -SCIP_RUBY_SPECIFIC_RUBY_ROOT="$SCIP_RUBY_CACHE_RUBY_DIR" -if [ -d "$SCIP_RUBY_SPECIFIC_RUBY_ROOT/versions" ]; then - # rbenv creates an extra versions subdirectory, which doesn't apply in CI. - # This is to avoid finding the 'gem' from shims/ - SCIP_RUBY_SPECIFIC_RUBY_ROOT="$SCIP_RUBY_SPECIFIC_RUBY_ROOT/versions" -fi -SCIP_RUBY_SPECIFIC_RUBY_ROOT="$SCIP_RUBY_SPECIFIC_RUBY_ROOT/$(< "$RUBY_VERSION_FILE")" - -# Little indirect because apparently there may be more bundle binaries inside. -GEM_EXE="$(find "$SCIP_RUBY_SPECIFIC_RUBY_ROOT" -name 'gem' -type f)" -BUNDLE_EXE="$(dirname "$GEM_EXE")/bundle" - -pushd repo -git diff --exit-code # No changes should've been made before applying the patch -git apply "../$PATCH_PATH" - -"$BUNDLE_EXE" --version >&2 -"$BUNDLE_EXE" exec 'echo $PATH' -"$BUNDLE_EXE" install --local - -set +e -_INFO="$("$BUNDLE_EXE" info scip-ruby-debug)" -if [ $? != 0 ]; then - set -e - _INFO="$("$BUNDLE_EXE" info scip-ruby)" -fi -set -e - -printf 'bundle info output:\n%s\n' "$_INFO" - -# Ideally, we'd write something like: -# -# "$BUNDLE_EXE" exec scip-ruby --index-file index.scip --gem-metadata "$REPO_NAME@99.99.99" \\ -# -# However, there is a discrepancy in paths between bundle install/info -# vs bundle exec (see https://github.com/rubygems/rubygems/issues/5838). -# Work around that by relying on 'bundle info` as the source of truth. -GEM_INSTALL_PATH="$(echo "$_INFO" | grep 'Path:' | sed -e 's/\s*Path: //')" -# From https://stackoverflow.com/a/3352015/2682729 -trim() { - local var="$*" - var="${var#"${var%%[![:space:]]*}"}" - var="${var%"${var##*[![:space:]]}"}" - printf '%s' "$var" -} -GEM_INSTALL_PATH="$(trim "$GEM_INSTALL_PATH")" - -{ - echo "Calling shim @ $GEM_INSTALL_PATH/bin/scip-ruby:" - echo "-----------------------------------" - cat "$GEM_INSTALL_PATH/bin/scip-ruby" - echo "-----------------------------------" - echo "This is for debugging/reproduction; I was seeing stale shims earlier, not sure why" -} >&2 - -# Call the shim, not the native binary, to test that the shim works. -DEBUG=1 "$BUNDLE_EXE" exec "$GEM_INSTALL_PATH/bin/scip-ruby" --index-file index.scip --gem-metadata "$REPO_NAME@99.99.99" -file index.scip - -popd \ No newline at end of file diff --git a/test/scip/repos/run_repo_test.sh b/test/scip/repos/run_repo_test.sh new file mode 100755 index 0000000000..33b98acafa --- /dev/null +++ b/test/scip/repos/run_repo_test.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +set -euo pipefail + +required_env=("GEM_METADATA" "INDEX_ARGS" "PROJECT_SUBDIR" "REPO_ARCHIVE" "REPO_NAME" "SCIP_RUBY" "STRIP_PREFIX") +for env_var in "${required_env[@]}"; do + if [[ -z "${!env_var:-}" ]]; then + echo "Missing definition for $env_var environment variable" + exit 1 + fi +done + +abspath() { + local path="$1" + if [[ "$path" = /* ]]; then + printf '%s\n' "$path" + else + printf '%s/%s\n' "$PWD" "$path" + fi +} + +REPO_ARCHIVE="$(abspath "$REPO_ARCHIVE")" +SCIP_RUBY="$(abspath "$SCIP_RUBY")" +export SORBET_SILENCE_DEV_MESSAGE=1 +if [[ -n "${LLVM_LIBUNWIND:-}" ]]; then + LLVM_LIBUNWIND="$(abspath "$LLVM_LIBUNWIND")" + export DYLD_LIBRARY_PATH="$(dirname "$LLVM_LIBUNWIND"):${DYLD_LIBRARY_PATH:-}" +fi + +workdir="${TEST_TMPDIR:-$(mktemp -d)}/scip-ruby-repo-test/$REPO_NAME" +rm -rf "$workdir" +mkdir -p "$workdir/unpack" + +echo "Unpacking $REPO_NAME from $REPO_ARCHIVE" +# Use Python instead of `unzip` because some real-world archives contain +# filenames that the macOS `unzip` command handles poorly. +python3 - "$REPO_ARCHIVE" "$workdir/unpack" <<'PY' +import sys +import zipfile + +archive, destination = sys.argv[1:] +with zipfile.ZipFile(archive) as zf: + zf.extractall(destination) +PY + +repo_root="$workdir/unpack/$STRIP_PREFIX" +if [[ "$PROJECT_SUBDIR" != "." ]]; then + repo_root="$repo_root/$PROJECT_SUBDIR" +fi + +if [[ ! -d "$repo_root" ]]; then + echo "Could not find repo root: $repo_root" + echo "Unpacked directories:" + find "$workdir/unpack" -maxdepth 2 -type d | sort + exit 1 +fi + +index_file="$workdir/index.scip" + +echo "Running scip-ruby for $REPO_NAME" +( + cd "$repo_root" + read -r -a index_args <<< "$INDEX_ARGS" + "$SCIP_RUBY" --index-file "$index_file" --gem-metadata "$GEM_METADATA" "${index_args[@]}" +) + +if [[ ! -s "$index_file" ]]; then + echo "Expected scip-ruby to create a non-empty index at $index_file" + exit 1 +fi + +index_size="$(wc -c < "$index_file")" +echo "Created non-empty SCIP index at $index_file ($index_size bytes)" diff --git a/test/scip/repos/scip_repos_test.bzl b/test/scip/repos/scip_repos_test.bzl index 81f35021d7..ab352d183d 100644 --- a/test/scip/repos/scip_repos_test.bzl +++ b/test/scip/repos/scip_repos_test.bzl @@ -1,126 +1,41 @@ load("//third_party:test_gem_data.bzl", "gem_build_info") -# For more context, see NOTE[repo-test-structure] - -def _assert(cond, msg): - if not cond: - fail(msg) - -def _scip_repo_test_cache_rule(ctx): - args = [] - inputs = [ctx.file._standalone_ruby_tgz] - toolchain_cache = ctx.actions.declare_file("cache/ruby-post-bundle-cache.tgz") - outputs = [toolchain_cache] - for target, gem_name in ctx.attr.target.items(): - target_zip_list = target.files.to_list() - _assert(len(target_zip_list) == 1, "Expected single element in target_zip_list but found: {}".format(target_zip_list)) - target_zip = target_zip_list[0] - inputs.append(target_zip) - strip_prefix = ctx.attr.strip_prefix[gem_name] - subdir = ctx.attr.subdir[gem_name] - gem_with_vendor_cache = ctx.actions.declare_file("cache/{}/gem-post-vendor.tgz".format(gem_name)) - outputs.append(gem_with_vendor_cache) - args.append("zip={}:prefix={}:subdir={}:out={}".format(target_zip.path, strip_prefix, subdir, gem_with_vendor_cache.path)) - - ctx.actions.run( - outputs = outputs, - inputs = inputs, - mnemonic = "AllBundleCache", - executable = ctx.file._bundle_cache_script, - arguments = args, - env = { - # Ideally, we would pass in a C compiler here too, but 🤷🏽 - "SCIP_RUBY_CACHE_RUBY_DIR": ctx.var["SCIP_RUBY_CACHE_RUBY_DIR"], - "RUBY_VERSION_FILE": ctx.file._ruby_version.path, - "PRISTINE_TOOLCHAIN_TGZ_PATH": ctx.file._standalone_ruby_tgz.path, - "OUT_MODIFIED_TOOLCHAIN_TGZ_PATH": toolchain_cache.path, - }, - ) - return [DefaultInfo(files = depset(outputs), runfiles = ctx.runfiles(files = outputs))] - -scip_repo_test_cache_rule = rule( - implementation = _scip_repo_test_cache_rule, - attrs = { - "_standalone_ruby_tgz": attr.label(default = "//gems/scip-ruby:standalone-ruby", allow_single_file = True), - "_bundle_cache_script": attr.label(default = ":bundle_cache.sh", allow_single_file = True), - "_ruby_version": attr.label(default = "//:.ruby-version", allow_single_file = True), - "target": attr.label_keyed_string_dict(mandatory = True), - "strip_prefix": attr.string_dict(mandatory = True), - "subdir": attr.string_dict(mandatory = True), - }, - doc = "Intermediate cache archives for gems after running 'bundle cache'.", -) - -def register_scip_repo_test_caches(): - scip_repo_test_cache_rule( - name = "cache_all_deps", - target = {"@{}_zip//file".format(g["repo_name"]): g["repo_name"] for g in gem_build_info}, - strip_prefix = {g["repo_name"]: g["strip_prefix"] for g in gem_build_info}, - subdir = {g["repo_name"]: g["gem_subdir"] for g in gem_build_info}, - ) - -def scip_repos_test_suite(name, patch_paths): - available_patches = {p: None for p in patch_paths} +def scip_repos_test_suite(name): test_names = [] - consumed = {} for gem_data in gem_build_info: gem_name = gem_data["repo_name"] - patch_basename = "{}-{}".format(gem_name, gem_data["ref"]) - extra_deps = {} - gem_dep = {} - patch_arg = {} - for os in ["//tools/config:linux", "//tools/config:darwin"]: - candidates = [patch_basename + ".patch"] - if "linux" in os: - candidates.append(patch_basename + "-linux.patch") - gem_dep[os] = "//gems/scip-ruby/scip-ruby-debug-1993.5.16-x86_64-linux.gem" - else: - candidates.append(patch_basename + "-darwin.patch") - - # TODO: Change to arm64-darwin - # NOTE: Keep in sync with index_gem.sh. - gem_dep[os] = "//gems/scip-ruby/scip-ruby-debug-1993.5.16-universal-darwin-20.gem" - extra_deps[os] = [] - for patch_path in candidates: - if patch_path in available_patches: - extra_deps[os].append(patch_path) - patch_arg[os] = "$(location {})".format(patch_path) - consumed[patch_path] = None - if "linux" in patch_path or "darwin" in patch_path: - available_patches.pop(patch_path, None) - - prep_target = ":cache_all_deps" - data = [prep_target, "//gems/scip-ruby", "//:.ruby-version"] + archive = "@{}_zip//file".format(gem_name) + project_subdir = gem_data.get("gem_subdir", ".") + gem_metadata = gem_data.get("gem_metadata", "{}@{}".format(gem_name, gem_data["ref"])) + index_args = gem_data.get("index_args", ["."]) + common_env = { + "GEM_METADATA": gem_metadata, + "INDEX_ARGS": " ".join(index_args), + "PROJECT_SUBDIR": project_subdir, + "REPO_ARCHIVE": "$(location {})".format(archive), + "REPO_NAME": gem_name, + "SCIP_RUBY": "$(location //main:scip-ruby)", + "STRIP_PREFIX": gem_data["strip_prefix"], + } + darwin_env = dict(common_env) + darwin_env["LLVM_LIBUNWIND"] = "$(location @llvm_toolchain_15_0_6_llvm//:lib/libunwind.1.dylib)" test_name = gem_name native.sh_test( name = test_name, - size = "medium", # Should finish in 5 minutes - srcs = ["index_gem.sh"], - data = data + select(extra_deps), - # Tests run serially since they share the same cache dir. - # For more context, see NOTE[repo-test-structure]. - tags = ["exclusive"], - env = select( - {os: { - "SCIP_RUBY_CACHE_RUBY_DIR": "$(SCIP_RUBY_CACHE_RUBY_DIR)", - "RUBY_VERSION_FILE": "$(location //:.ruby-version)", - "SCIP_RUBY_GEMS": "$(locations //gems/scip-ruby)", - "CACHED_TGZS": "$(locations {})".format(prep_target), - "REPO_NAME": gem_data["repo_name"], - "PATCH_PATH": pa, - } for os, pa in patch_arg.items()}, - ), + size = "medium", + srcs = ["run_repo_test.sh"], + data = [archive, "//main:scip-ruby"] + select({ + "@platforms//os:osx": ["@llvm_toolchain_15_0_6_llvm//:lib/libunwind.1.dylib"], + "//conditions:default": [], + }), + env = select({ + "@platforms//os:osx": darwin_env, + "//conditions:default": common_env, + }), ) test_names.append(test_name) - for p in consumed: - available_patches.pop(p, None) - - # if len(available_patches) != 0: - # fail("Patches {} were not used by any tests".format(available_patches)) - # FIXME(varun): Get the brew test working and turn this on. - native.test_suite( name = name, tests = test_names, diff --git a/test/scip/repos/shopify-api-ruby-v11.1.0-darwin.patch b/test/scip/repos/shopify-api-ruby-v11.1.0-darwin.patch deleted file mode 100644 index daab3b0582..0000000000 --- a/test/scip/repos/shopify-api-ruby-v11.1.0-darwin.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/Gemfile.lock b/Gemfile.lock -index 9fef6a6..4b720c0 100644 ---- a/Gemfile.lock -+++ b/Gemfile.lock -@@ -81,2 +81,3 @@ GEM - ruby-progressbar (1.11.0) -+ scip-ruby-debug (1993.5.16-universal-darwin-20) - securerandom (0.2.0) -@@ -125,2 +126,3 @@ PLATFORMS - arm64-darwin-21 -+ ruby - x86_64-linux -@@ -136,2 +138,3 @@ DEPENDENCIES - rubocop-sorbet -+ scip-ruby-debug - shopify_api! -diff --git a/shopify_api.gemspec b/shopify_api.gemspec -index da77b24..93fba5c 100644 ---- a/shopify_api.gemspec -+++ b/shopify_api.gemspec -@@ -51,2 +51,3 @@ Gem::Specification.new do |s| - s.add_development_dependency("tapioca") -+ s.add_development_dependency("scip-ruby-debug") - end diff --git a/test/scip/repos/shopify-api-ruby-v11.1.0-linux.patch b/test/scip/repos/shopify-api-ruby-v11.1.0-linux.patch deleted file mode 100644 index 8c70f8e7f8..0000000000 --- a/test/scip/repos/shopify-api-ruby-v11.1.0-linux.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/Gemfile.lock b/Gemfile.lock -index 9fef6a6..54db244 100644 ---- a/Gemfile.lock -+++ b/Gemfile.lock -@@ -81,2 +81,3 @@ GEM - ruby-progressbar (1.11.0) -+ scip-ruby-debug (1993.5.16-x86_64-linux) - securerandom (0.2.0) -@@ -125,2 +126,3 @@ PLATFORMS - arm64-darwin-21 -+ ruby - x86_64-linux -@@ -136,2 +138,3 @@ DEPENDENCIES - rubocop-sorbet -+ scip-ruby-debug - shopify_api! -diff --git a/shopify_api.gemspec b/shopify_api.gemspec -index da77b24..93fba5c 100644 ---- a/shopify_api.gemspec -+++ b/shopify_api.gemspec -@@ -51,2 +51,3 @@ Gem::Specification.new do |s| - s.add_development_dependency("tapioca") -+ s.add_development_dependency("scip-ruby-debug") - end diff --git a/third_party/test_gem_data.bzl b/third_party/test_gem_data.bzl index 750505434b..8360c1a8fa 100644 --- a/third_party/test_gem_data.bzl +++ b/third_party/test_gem_data.bzl @@ -1,41 +1,29 @@ gem_build_info = [ - # { - # "repo_name": "brew", - # # "kind": "self_sandboxing", - # "archive_url": "https://github.com/Homebrew/brew/archive/refs/tags/3.5.9.zip", - # "archive_sha256": "28a66005cc6f0f22a9a112ce84cedb833efe6926072dec2c68623195c008852f", - # "ref": "3.5.9", - # "strip_prefix": "brew-3.5.9", - # "gem_subdir": "Library/Homebrew", - # # "prep_cmd": """ - # # pushd Library/Homebrew \\ - # # && gem install bundler:1.17.3 \\ - # # && popd \\ - # # && ./bin/brew typecheck - # # """, - # # "run_cmd": """ - # # pushd Library/Homebrew \\ - # # && find . -name srb -type f -exec cp $${TEST_DIR}/$(location //main:scip-ruby) {} \\; \\ - # # && popd \\ - # # && ./bin/brew typecheck - # # """, - # }, { "repo_name": "shopify-api-ruby", - # "kind": "needs_sandboxing", "archive_url": "https://github.com/Shopify/shopify-api-ruby/archive/refs/tags/v11.1.0.zip", "archive_sha256": "95a209308d6479491ca282af66254bd6c4e1c5b6edb8e0409e2fe29424a51157", "ref": "v11.1.0", "strip_prefix": "shopify-api-ruby-11.1.0", - # "prep_cmd": """ - # bundle cache --all \\ - # && for p in $(locations //gems/scip-ruby); do cp $${TEST_DIR}/$$p vendor/cache/; done \\ - # """, - # "run_cmd": """ - # bundle install --local \\ - # && bundle exec scip-ruby --index-file index.scip --gem-metadata 'shopify-api-ruby@11.1.0' \\ - # && file index.scip - # """, "gem_subdir": ".", + "gem_metadata": "shopify-api-ruby@11.1.0", + }, + { + "repo_name": "faker", + "archive_url": "https://github.com/faker-ruby/faker/archive/refs/tags/v3.2.1.zip", + "archive_sha256": "19c56fdfc0a38d05b291620bee0ae35e441f88fbbb9af6dd6ff6441be3226590", + "ref": "v3.2.1", + "strip_prefix": "faker-3.2.1", + "gem_subdir": ".", + "gem_metadata": "faker@3.2.1", + }, + { + "repo_name": "graphql-ruby", + "archive_url": "https://github.com/rmosolgo/graphql-ruby/archive/refs/tags/v2.0.24.zip", + "archive_sha256": "7ebd06d8040adc066a057c0ef4194a78c72055d0a92f36ae01c0c5552e2ad5f2", + "ref": "v2.0.24", + "strip_prefix": "graphql-ruby-2.0.24", + "gem_subdir": ".", + "gem_metadata": "graphql-ruby@2.0.24", }, ]