Skip to content

Commit

Permalink
workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yairgott committed Jan 23, 2025
1 parent 6db0751 commit c65a770
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
29 changes: 25 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ RUN apt-get install -y \
vim \
bash \
bash-completion \
entr \
coreutils \
sudo

RUN rm -rf /var/lib/apt/lists/*

RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN ./llvm.sh 17
RUN rm -f llvm.sh
RUN apt-get update && apt-get install -y clang-tidy-17 clang-format-17 && rm -rf /var/lib/apt/lists/*
Expand All @@ -50,21 +52,40 @@ RUN wget -O /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/r

# Add bazel/buildifier to PATH
ENV PATH="/usr/local/bin:$PATH"

RUN echo '#!/bin/bash\n\
set +e\n\
LOCKFILE="/tmp/rebuild_comp_db.lock"\n\
if [ -e "$LOCKFILE" ] && kill -0 "$(cat "$LOCKFILE")" 2>/dev/null; then\n\
echo "Script is already running. Exiting."\n\
exit 1\n\
fi\n\
echo $$ > "$LOCKFILE"\n\
trap "rm -f $LOCKFILE" EXIT\n\
if [ ! -d "/workspaces/valkey-search" ]; then\n\
echo "Error: Directory /workspaces/valkey-search does not exist."\n\
exit 1\n\
fi\n\
cd /workspaces/valkey-search\n\
while sleep 1; do\n\
find src testing vmsdk/src vmsdk/testing -type f \\( -iname \\*.cc -o -iname \\*.h -o -iname BUILD \\) | entr -d bazel run @hedron_compile_commands//:refresh_all &> /dev/null\n\
done' > /usr/local/bin/refresh_comp_db.sh && chmod +x /usr/local/bin/refresh_comp_db.sh
# Set working directory
WORKDIR /workspace

# Add non-root user for development
RUN useradd -m vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER vscode

# Add an alias for 'vi' to point to 'vim' if 'vi' doesn't exist
RUN echo 'if ! command -v vi &> /dev/null; then alias vi="vim"; fi' >> /home/vscode/.bashrc

RUN echo 'refresh_comp_db.sh &> /dev/null &' >> /home/vscode/.bashrc
# Ensure the history file exists and configure permissions
RUN touch /home/vscode/.bash_history && chmod 600 /home/vscode/.bash_history

ENV CC=clang
ENV CXX=clang++


# Default shell
SHELL ["/bin/bash", "-c"]
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
]
}
},
"postCreateCommand": "bazel build //... && bazel run @hedron_compile_commands//:refresh_all ",
"remoteUser": "vscode"
"remoteUser": "vscode",
"postCreateCommand": "./ci/entrypoint.sh && /bin/bash"
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"--compile-commands-dir=${workspaceFolder}/",
"--query-driver=**"
],
"bazel.buildifierFixOnFormat": true,
"bazel.buildifierFixOnFormat": false,
"clangd.inactiveRegions.useBackgroundHighlight": true,
"clangd.enableCodeCompletion": true
"clangd.enableCodeCompletion": true,
}
2 changes: 1 addition & 1 deletion ci/check_clang_format.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

set -e
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <file>" >&2
exit 1
Expand Down
4 changes: 4 additions & 0 deletions ci/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
bazel build //...
bazel run @hedron_compile_commands//:refresh_all
2 changes: 1 addition & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package(
)

# To include the symbol table, specific parameters are required:
# --strip=never --config=online_debug_backtraces
# --strip=never --config=online_debug_backtraces
# For a release build, add the following parameter: --config=release
redis_module_library(
name = "valkeysearch",
Expand Down
2 changes: 1 addition & 1 deletion vmsdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package(

license(
name = "license",
package_name = "vmsdk",
package_name = "vmsdk ",
)

licenses(["notice"])
Expand Down

0 comments on commit c65a770

Please sign in to comment.