Skip to content

Commit d075d44

Browse files
feat: Add --version flag with checks (#176)
1 parent 3d92804 commit d075d44

File tree

6 files changed

+67
-7
lines changed

6 files changed

+67
-7
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ jobs:
4646
shell: bash
4747
steps:
4848
- uses: actions/checkout@v3
49+
- name: '📝 Check version'
50+
run: |
51+
set -euo pipefail
52+
if [[ "${TAG:-}" == v* ]]; then
53+
TAG_LIKE="$TAG"
54+
else
55+
TAG_LIKE="$(grep '## v' CHANGELOG.md | head -n 1 | cut -d ' ' -f 2)"
56+
fi
57+
NEW_VERSION="${TAG_LIKE/v/}" ./tools/version_check.sh
4958
- name: '🐍 Install Bazelisk'
5059
run: |
5160
if ! command -v bazelisk; then
@@ -82,13 +91,14 @@ jobs:
8291
} > ci.bazelrc
8392
# Comment out the 'upload log' bit below for debugging
8493
bazel build //indexer:scip-clang --config="$CONFIG" # --execution_log_binary_file=log
94+
if [ "$RUNNER_OS" == "Linux" ]; then
95+
echo "--- GLIBC VERSIONS ---"
96+
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
97+
echo "----------------------"
98+
fi
8599
env:
86100
CONFIG: ${{ matrix.config }}
87101
CI_BAZEL_REMOTE_CACHE: 'https://storage.googleapis.com/sourcegraph_bazel_cache'
88-
- name: '🔎 Identify glibc'
89-
if: ${{ matrix.container }} != ''
90-
run: |
91-
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
92102
- name: '🔎 Identify OS'
93103
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
94104
# - name: '🪵 Upload log'

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# scip-clang ChangeLog
2+
3+
## v0.0.1 (testing)
4+
5+
- Symbols without hover docs will explicitly show "No documentation available".
6+
- Published binaries should work on Debian Buster and Ubuntu 18.04,
7+
instead of requiring Debian Bullseye / Ubuntu 20.04 or newer.
8+
9+
## v0.0.0 (testing)
10+
11+
- Initial release with code nav support for various
12+
language features like macros, #include pragmas, types,
13+
functions, methods, local variables etc.

indexer/Driver.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "indexer/ScipExtras.h"
4848
#include "indexer/Statistics.h"
4949
#include "indexer/Timer.h"
50+
#include "indexer/Version.h"
5051

5152
namespace boost_ip = boost::interprocess;
5253

@@ -697,7 +698,7 @@ class Driver {
697698

698699
scip::ToolInfo toolInfo;
699700
toolInfo.set_name("scip-clang");
700-
toolInfo.set_version("0.0.0"); // See TODO(ref: add-version)
701+
toolInfo.set_version(scip_clang::version);
701702
for (auto &arg : this->options.originalArgv) {
702703
toolInfo.add_arguments(arg);
703704
}

indexer/Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ constexpr bool debugMode = true;
1515
constexpr bool debugMode = false;
1616
#endif
1717

18-
#define VERSION "0.0.0"
18+
#define VERSION "0.0.1"
1919
#define LLVM_COMMIT \
2020
"b6e344ce91c8796331fca7644eb8c748ac5391ec" // Keep in sync with setup.bzl
2121

indexer/main.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "indexer/CliOptions.h"
1616
#include "indexer/Driver.h"
1717
#include "indexer/Enforce.h"
18+
#include "indexer/Version.h"
1819
#include "indexer/Worker.h"
1920

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

141146
if (!result.unmatched().empty()) {
142147
fmt::print(stderr, "error: unknown argument(s) {}\n", result.unmatched());

tools/version_check.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Inputs:
4+
# NEW_VERSION should be a string M.N.P
5+
6+
PROJECT_ROOT="$(dirname "${BASH_SOURCE[0]}")/.."
7+
cd "$PROJECT_ROOT"
8+
9+
if ! grep -q "## v$NEW_VERSION" CHANGELOG.md; then
10+
echo "error: Missing CHANGELOG entry for $NEW_VERSION"
11+
echo "note: CHANGELOG entries are required for publishing releases"
12+
exit 1
13+
fi
14+
15+
if ! grep -q "#define VERSION \"$NEW_VERSION\"" indexer/Version.h; then
16+
echo "error: VERSION in Version.h doesn't match NEW_VERSION=$NEW_VERSION"
17+
exit 1
18+
fi
19+
20+
if ! grep -q "_LLVM_COMMIT" fetch_deps.bzl; then
21+
echo "error: Missing _LLVM_COMMIT in fetch_deps.bzl"
22+
exit 1
23+
fi
24+
25+
LLVM_COMMIT_STRING="$(grep "_LLVM_COMMIT = " fetch_deps.bzl | cut -d ' ' -f 3)"
26+
27+
if ! grep -q "$LLVM_COMMIT_STRING" indexer/Version.h; then
28+
echo "info: Found LLVM_COMMIT $LLVM_COMMIT_STRING"
29+
echo "error: LLVM_COMMIT in Version.h doesn't match fetch_deps.bzl"
30+
exit 1
31+
fi

0 commit comments

Comments
 (0)