Skip to content

Commit

Permalink
Clean up shell scripts (#1269)
Browse files Browse the repository at this point in the history
* Clean up shell scripts
* Add shellcheck CI step
  • Loading branch information
johnbley authored Apr 2, 2024
1 parent bb9eb40 commit e44f5a9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Shellcheck

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

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 | xargs shellcheck --severity=warning
4 changes: 3 additions & 1 deletion script/proto_gen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e

DESTINATION_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")/../proto/otel
GPBMETA_DIR="GPBMetadata"
OTEL_DIR="Opentelemetry"
Expand All @@ -12,7 +14,7 @@ git clone https://github.com/open-telemetry/${REPO_DIR}
cd ${REPO_DIR}
git config --add advice.detachedHead false
TAG=$(
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
TAG=$(git describe --tags "`git rev-list --tags --max-count=1`")
git checkout "${TAG}"
Expand Down
11 changes: 6 additions & 5 deletions script/semantic-conventions/semconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Source repositories:
# - https://github.com/open-telemetry/semantic-conventions/releases
# - https://github.com/open-telemetry/build-tools/releases
set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../../"
Expand All @@ -21,18 +22,18 @@ SPEC_VERSION=v$SEMCONV_VERSION
SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION
GENERATOR_VERSION=0.23.0

cd "${SCRIPT_DIR}" || exit
cd "${SCRIPT_DIR}"

rm -rf "${SPEC_DIR}" || true
rm -rf "${SPEC_DIR}"
mkdir "${SPEC_DIR}"
cd "${SPEC_DIR}" || exit
cd "${SPEC_DIR}"

git init -b main
git remote add origin https://github.com/open-telemetry/semantic-conventions.git
git fetch origin "$SPEC_VERSION"
git reset --hard FETCH_HEAD

cd "${SCRIPT_DIR}" || exit
cd "${SCRIPT_DIR}"

mkdir -p "${CODE_DIR}"
find "${CODE_DIR}" -name "*.php" -exec rm -f {} \;
Expand Down Expand Up @@ -101,4 +102,4 @@ docker run --rm \
-Dclass="Resource" \
-DschemaUrl=$SCHEMA_URL

rm -rf "${SPEC_DIR}" || true
rm -rf "${SPEC_DIR}"
3 changes: 2 additions & 1 deletion tests/TraceContext/W3CTestService/trace-context-test.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash
set -x
set -e

function install_symfony() {
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.alpine.sh' | bash >/dev/null
apk add symfony-cli
}

cd "tests/TraceContext/W3CTestService" || { echo "error: could not cd into the W3CTestService directory."; exit 1; }
cd "tests/TraceContext/W3CTestService"

# Install Symfony: we will use the Symfony server as the built-in PHP server doesn't play well with duplicate headers
install_symfony
Expand Down

0 comments on commit e44f5a9

Please sign in to comment.