Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions docs/scip-ruby/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ see the [Design Decisions doc][].
- [Debugging Bazel](#debugging-bazel)
- [Debugging on Linux](#debugging-on-linux)
- [Creating PRs](#creating-prs)
- [Syncing Sorbet upstream](#syncing-sorbet-upstream)
- [Cutting a release](#cutting-a-release)
- Troubleshooting
- [Known build issues][]
Expand Down Expand Up @@ -322,10 +323,30 @@ gh pr create -R sourcegraph/scip-ruby

This will correctly use the `scip-ruby/master` branch as the target.

## Syncing Sorbet upstream

1. Create a temporary branch and perform a merge. It doesn't matter
if the code compiles or not, only try to fix conflicts reasonably.
Do NOT modify existing commits/rewrite history here.
2. Create a new commit updating the `scip_ruby_sync_upstream_sorbet_sha` value.
3. If there are compilation/test failures, fix them in a single follow-up commit.
In total, we will have N+1 or N+2 commits in the PR, with N from Sorbet.
4. Once tests are passing, temporarily turn on 'Allow merge commits' in the admin settings.
Merge the PR and turn off merging in the admin settings.

## Cutting a release

Push a tag matching `scip-ruby-v*` to `scip-ruby/master`.
A CI job should automatically trigger a release.
1. Add release notes to the [CHANGELOG](/CHANGELOG.md).
2. Bump `scip_ruby_version` in `SCIPIndexer.cc`.

Run the release script:

```bash
NEW_VERSION=M.N.P ./tools/scripts/publish-scip-ruby.sh
```

If there are any errors, fix those and re-run.
A CI job will be kicked off to trigger a release.
See the [release workflow](/.github/workflows/release.yml) for details.

## Troubleshooting
Expand Down
18 changes: 17 additions & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "ast/Trees.h"
#include "ast/treemap/treemap.h"
#include "cfg/CFG.h"
#include "common/EarlyReturnWithCode.h"
#include "common/common.h"
#include "common/sort.h"
#include "core/Error.h"
Expand Down Expand Up @@ -58,6 +59,11 @@ static uint32_t fnv1a_32(const string &s) {
return h;
}

const char scip_ruby_version[] = "0.1.2";

// Last updated: https://github.com/sourcegraph/scip-ruby/pull/104
const char scip_ruby_sync_upstream_sorbet_sha[] = "bb35f6d1d075b27c3296c2eee85cba5c2de8c60f";

namespace sorbet::scip_indexer {

// TODO(varun): This is an inline workaround for https://github.com/sorbet/sorbet/issues/5925
Expand Down Expand Up @@ -1157,7 +1163,7 @@ class SCIPSemanticExtension : public SemanticExtension {
}
scip::ToolInfo toolInfo;
toolInfo.set_name("scip-ruby");
toolInfo.set_version(sorbet_version);
toolInfo.set_version(scip_ruby_version);
*toolInfo.add_arguments() = "FIXME"; // FIXME(varun): GlobalState doesn't have access to CLI arguments. 🙁

scip::Metadata metadata;
Expand Down Expand Up @@ -1263,6 +1269,16 @@ class SCIPSemanticExtensionProvider : public SemanticExtensionProvider {
cxxopts::value<string>());
};
unique_ptr<SemanticExtension> readOptions(cxxopts::ParseResult &providedOptions) const override {
if (providedOptions.count("version") > 0) {
// HACK: Just modify the version in place instead of duplicating the logic in sorbet_version.c
// There is some 'sed' replacement going on in that file.
fmt::print("scip-ruby {}\nBased on Sorbet {} {}\n",
absl::StrReplaceAll(sorbet_full_version_string,
{{sorbet_version, scip_ruby_version},
{fmt::format(".{}", sorbet_build_scm_commit_count), ""}}),
sorbet_version, scip_ruby_sync_upstream_sorbet_sha);
throw sorbet::EarlyReturnWithCode(0);
}
if (providedOptions.count("index-file") > 0) {
return make_unique<SCIPSemanticExtension>(
providedOptions["index-file"].as<string>(),
Expand Down
48 changes: 48 additions & 0 deletions tools/scripts/publish-scip-ruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

set -euo pipefail

{

if [ -z "${NEW_VERSION:-}" ]; then
echo "error: Missing value for environment variable NEW_VERSION"
echo "hint: Invoke this script as NEW_VERSION=M.N.P ./tools/scripts/publish-scip-ruby.sh"
exit 1
fi

if ! grep -q "## v$NEW_VERSION" CHANGELOG.md; then
echo "error: Missing CHANGELOG entry for v$NEW_VERSION"
echo "note: CHANGELOG entries are required for publishing releases"
exit 1
fi

if ! grep -q "const char scip_ruby_version\[\] = \"$NEW_VERSION\"" scip_indexer/SCIPIndexer.cc; then
echo "error: SCIP_RUBY_VERSION in SCIPIndexer.cc doesn't match NEW_VERSION=$NEW_VERSION"
exit 1
fi

if ! git diff --quiet; then
echo "error: Found unstaged changes; aborting."
exit 1
fi

if ! git diff --quiet --cached; then
echo "error: Found staged-but-uncommitted changes; aborting."
exit 1
fi

if ! git remote -v | grep "origin" | grep -q "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/sourcegraph/scip-ruby.git"; then
echo "error: remote 'origin' doesn't point to sourcegraph/scip-ruby"
exit 1
fi

if ! git rev-parse --abbrev-ref HEAD | grep -q "scip-ruby/master"; then
echo "error: Releases should be published from scip-ruby/master but HEAD is on a different branch" >&2
exit 1
fi

} >&2

TAG="scip-ruby-v$NEW_VERSION"
git tag "$TAG"
git push origin "$TAG"