Skip to content

Commit

Permalink
feat: Add --version flag with checks (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src authored Apr 14, 2023
1 parent 3d92804 commit d075d44
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 7 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v3
- name: '📝 Check version'
run: |
set -euo pipefail
if [[ "${TAG:-}" == v* ]]; then
TAG_LIKE="$TAG"
else
TAG_LIKE="$(grep '## v' CHANGELOG.md | head -n 1 | cut -d ' ' -f 2)"
fi
NEW_VERSION="${TAG_LIKE/v/}" ./tools/version_check.sh
- name: '🐍 Install Bazelisk'
run: |
if ! command -v bazelisk; then
Expand Down Expand Up @@ -82,13 +91,14 @@ jobs:
} > ci.bazelrc
# Comment out the 'upload log' bit below for debugging
bazel build //indexer:scip-clang --config="$CONFIG" # --execution_log_binary_file=log
if [ "$RUNNER_OS" == "Linux" ]; then
echo "--- GLIBC VERSIONS ---"
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
echo "----------------------"
fi
env:
CONFIG: ${{ matrix.config }}
CI_BAZEL_REMOTE_CACHE: 'https://storage.googleapis.com/sourcegraph_bazel_cache'
- name: '🔎 Identify glibc'
if: ${{ matrix.container }} != ''
run: |
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
- name: '🔎 Identify OS'
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
# - name: '🪵 Upload log'
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# scip-clang ChangeLog

## v0.0.1 (testing)

- Symbols without hover docs will explicitly show "No documentation available".
- Published binaries should work on Debian Buster and Ubuntu 18.04,
instead of requiring Debian Bullseye / Ubuntu 20.04 or newer.

## v0.0.0 (testing)

- Initial release with code nav support for various
language features like macros, #include pragmas, types,
functions, methods, local variables etc.
3 changes: 2 additions & 1 deletion indexer/Driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "indexer/ScipExtras.h"
#include "indexer/Statistics.h"
#include "indexer/Timer.h"
#include "indexer/Version.h"

namespace boost_ip = boost::interprocess;

Expand Down Expand Up @@ -697,7 +698,7 @@ class Driver {

scip::ToolInfo toolInfo;
toolInfo.set_name("scip-clang");
toolInfo.set_version("0.0.0"); // See TODO(ref: add-version)
toolInfo.set_version(scip_clang::version);
for (auto &arg : this->options.originalArgv) {
toolInfo.add_arguments(arg);
}
Expand Down
2 changes: 1 addition & 1 deletion indexer/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ constexpr bool debugMode = true;
constexpr bool debugMode = false;
#endif

#define VERSION "0.0.0"
#define VERSION "0.0.1"
#define LLVM_COMMIT \
"b6e344ce91c8796331fca7644eb8c748ac5391ec" // Keep in sync with setup.bzl

Expand Down
7 changes: 6 additions & 1 deletion indexer/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "indexer/CliOptions.h"
#include "indexer/Driver.h"
#include "indexer/Enforce.h"
#include "indexer/Version.h"
#include "indexer/Worker.h"

static scip_clang::CliOptions parseArguments(int argc, char *argv[]) {
Expand Down Expand Up @@ -53,8 +54,8 @@ static scip_clang::CliOptions parseArguments(int argc, char *argv[]) {
"Show Clang diagnostics triggered when running semantic analysis."
" Useful for debugging issues related to missing headers.",
cxxopts::value<bool>(cliOptions.showClangDiagnostics));
parser.add_options("")("version", "Show the version", cxxopts::value<bool>());
parser.add_options("")("h,help", "Show help text", cxxopts::value<bool>());
// TODO(def: add-version): Add a --version flag
parser.add_options("Advanced")(
"print-statistics-path",
"Print indexing related statistics in JSON format."
Expand Down Expand Up @@ -137,6 +138,10 @@ static scip_clang::CliOptions parseArguments(int argc, char *argv[]) {
fmt::print("{}\n", parser.help());
std::exit(EXIT_SUCCESS);
}
if (result.count("version")) {
fmt::print("{}", scip_clang::full_version_string);
std::exit(EXIT_SUCCESS);
}

if (!result.unmatched().empty()) {
fmt::print(stderr, "error: unknown argument(s) {}\n", result.unmatched());
Expand Down
31 changes: 31 additions & 0 deletions tools/version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Inputs:
# NEW_VERSION should be a string M.N.P

PROJECT_ROOT="$(dirname "${BASH_SOURCE[0]}")/.."
cd "$PROJECT_ROOT"

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

if ! grep -q "#define VERSION \"$NEW_VERSION\"" indexer/Version.h; then
echo "error: VERSION in Version.h doesn't match NEW_VERSION=$NEW_VERSION"
exit 1
fi

if ! grep -q "_LLVM_COMMIT" fetch_deps.bzl; then
echo "error: Missing _LLVM_COMMIT in fetch_deps.bzl"
exit 1
fi

LLVM_COMMIT_STRING="$(grep "_LLVM_COMMIT = " fetch_deps.bzl | cut -d ' ' -f 3)"

if ! grep -q "$LLVM_COMMIT_STRING" indexer/Version.h; then
echo "info: Found LLVM_COMMIT $LLVM_COMMIT_STRING"
echo "error: LLVM_COMMIT in Version.h doesn't match fetch_deps.bzl"
exit 1
fi

0 comments on commit d075d44

Please sign in to comment.