From d075d44c4313136ffdf9ddc73b60b0e07f741a8a Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Fri, 14 Apr 2023 05:58:35 +0000 Subject: [PATCH] feat: Add --version flag with checks (#176) --- .github/workflows/release.yml | 18 ++++++++++++++---- CHANGELOG.md | 13 +++++++++++++ indexer/Driver.cc | 3 ++- indexer/Version.h | 2 +- indexer/main.cc | 7 ++++++- tools/version_check.sh | 31 +++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md create mode 100755 tools/version_check.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e2ff966..b04b3d46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..eb6eee36 --- /dev/null +++ b/CHANGELOG.md @@ -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. \ No newline at end of file diff --git a/indexer/Driver.cc b/indexer/Driver.cc index 9cb4fa6d..e22ed343 100644 --- a/indexer/Driver.cc +++ b/indexer/Driver.cc @@ -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; @@ -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); } diff --git a/indexer/Version.h b/indexer/Version.h index a720236a..d9db1bc0 100644 --- a/indexer/Version.h +++ b/indexer/Version.h @@ -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 diff --git a/indexer/main.cc b/indexer/main.cc index 1eac2560..1f0933b9 100644 --- a/indexer/main.cc +++ b/indexer/main.cc @@ -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[]) { @@ -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(cliOptions.showClangDiagnostics)); + parser.add_options("")("version", "Show the version", cxxopts::value()); parser.add_options("")("h,help", "Show help text", cxxopts::value()); - // TODO(def: add-version): Add a --version flag parser.add_options("Advanced")( "print-statistics-path", "Print indexing related statistics in JSON format." @@ -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()); diff --git a/tools/version_check.sh b/tools/version_check.sh new file mode 100755 index 00000000..63b7b934 --- /dev/null +++ b/tools/version_check.sh @@ -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 \ No newline at end of file