Skip to content

Commit

Permalink
Modify shell scripts to pass shellcheck --severity=warning (open-tele…
Browse files Browse the repository at this point in the history
…metry#3371)

* Pass shellcheck --severity=warning and add CI to ensure such

* Also include *.sh.template files for shellcheck

---------

Co-authored-by: Piotr Kiełkowicz <[email protected]>
  • Loading branch information
johnbley and Kielek authored Apr 18, 2024
1 parent 0a06af3 commit e822c33
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Shellcheck

on:
push:
branches: [ main ]
pull_request:
merge_group:
workflow_dispatch:

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install shellcheck
run: sudo apt update && sudo apt install --assume-yes shellcheck

- name: Run shellcheck
run: find . -name \*.sh -o -name \*.sh.template | xargs shellcheck --severity=warning
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function FirstJsonValue {

# If dotnet CLI is installed globally and it matches requested version, use for execution
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
export DOTNET_EXE="$(command -v dotnet)"
DOTNET_EXE="$(command -v dotnet)"
export DOTNET_EXE
else
# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
Expand Down
2 changes: 1 addition & 1 deletion instrument.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ if [ "$ENABLE_PROFILING" = "true" ]; then
fi
fi

$@
exec "$@"
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/bin/sh

BASE_PATH="$(cd $(dirname "$0") && pwd)"
BASE_PATH="$(cd "$(dirname "$0")" && pwd)"

# Settings for .NET
export ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper
export CORECLR_ENABLE_PROFILING=1
export CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"
export CORECLR_PROFILER_PATH=$(ls ${BASE_PATH}/OpenTelemetry.AutoInstrumentation.Native.*)
CORECLR_PROFILER_PATH="$(ls ${BASE_PATH}/OpenTelemetry.AutoInstrumentation.Native.*)"
export CORECLR_PROFILER_PATH
export DOTNET_STARTUP_HOOKS=${BASE_PATH}/OpenTelemetry.AutoInstrumentation.StartupHook.dll

# Settings for OpenTelemetry
export OTEL_DOTNET_AUTO_HOME=${BASE_PATH}
export OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED=false

$@
exec "$@"
5 changes: 3 additions & 2 deletions scripts/format-native.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/bin/bash
set -e

SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
cd $SCRIPT_DIR/..
Expand Down Expand Up @@ -31,7 +32,7 @@ else
fi

# files to format
NATIVE_FILES=$(find . -iname *.cpp -o -iname *.hpp -iname *.h -iname *.inc | grep -v ./packages | grep -v ./src/OpenTelemetry.AutoInstrumentation.Native/lib)
NATIVE_FILES=$(find . -iname "*.cpp" -o -iname "*.hpp" -iname "*.h" -iname "*.inc" | grep -v ./packages | grep -v ./src/OpenTelemetry.AutoInstrumentation.Native/lib)

# clang-format
echo "$NATIVE_FILES" | xargs "./bin/artifacts/clang-format$EXT" -style=file -i
Expand Down

0 comments on commit e822c33

Please sign in to comment.