Add shell check
Motivated by
MODIFY
.github/scripts/deadlock-detector.sh
.github/scripts/deadlock-detector.sh
@@ -6,14 +6,14 @@ do
file="/tmp/deadlock-detector-$(date +"%Y-%m-%d-%H-%M-%S").txt"
for pid in $(jps | grep -v Jps | awk '{ print $1 }')
do
- jcmd $pid VM.command_line >> $file
- jcmd $pid Thread.print >> $file
- if jcmd $pid Thread.print | grep -q SimpleLogger
+ jcmd "$pid" VM.command_line >> "$file"
+ jcmd "$pid" Thread.print >> "$file"
+ if jcmd "$pid" Thread.print | grep -q SimpleLogger
then
# check once more to eliminate most of the sporadic finds
- if jcmd $pid Thread.print | grep -q SimpleLogger
+ if jcmd "$pid" Thread.print | grep -q SimpleLogger
then
- jcmd $pid GC.heap_dump /tmp/deadlock-detector-$pid.hprof
+ jcmd "$pid" GC.heap_dump "/tmp/deadlock-detector-$pid.hprof"
fi
fi
done

MODIFY
.github/scripts/diff-suppression-keys-with-docs.sh
.github/scripts/diff-suppression-keys-with-docs.sh
-#!/usr/bin/env bash
+#!/bin/bash -e
# this script reports some false positives, but is helpful in comparing the keys listed
# in suppressing-instrumentation.md with the keys listed in the source files
@@ -9,6 +9,7 @@ curl https://raw.githubusercontent.com/open-telemetry/opentelemetry.io/main/cont
comm -3 \
<(
+ # shellcheck disable=SC2016 # "Expressions don't expand in single quotes"
sed -n '/----------------------/,${p;/^$/q}' agent-config.md \
| sed '1d;$d' \
| cut -d '|' -f 3 \

MODIFY
.github/scripts/generate-release-contributors.sh
.github/scripts/generate-release-contributors.sh
#!/bin/bash -e
-# shellcheck disable=SC2016
-# shellcheck disable=SC2086
-
# this should be run on the release branch
# NOTE if you need to run this script locally, you will need to first:
from_version=$1
# get the date of the first commit that was not in the from_version
-from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1)
+from=$(git log --reverse --pretty=format:"%cI" "$from_version..HEAD" | head -1)
# get the last commit on main that was included in the release
to=$(git merge-base origin/main HEAD | xargs git log -1 --pretty=format:"%cI")
+# shellcheck disable=SC2016 # "Expressions don't expand in single quotes"
contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
query($q: String!, $endCursor: String) {
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
@@ -55,6 +53,7 @@ query($q: String!, $endCursor: String) {
# this query captures authors of issues which have had PRs in the current range reference the issue
# but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue)
+# shellcheck disable=SC2016 # "Expressions don't expand in single quotes"
contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
query($q: String!, $endCursor: String) {
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
@@ -79,7 +78,7 @@ query($q: String!, $endCursor: String) {
| sed 's/^\["//' \
| sed 's/".*//')
-echo $contributors1 $contributors2 \
+echo "$contributors1" "$contributors2" \
| sed 's/ /\n/g' \
| sort -uf \
| grep -v linux-foundation-easycla \

MODIFY
.github/workflows/build-daily.yml
.github/workflows/build-daily.yml
@@ -24,6 +24,9 @@ jobs:
muzzle:
uses: ./.github/workflows/reusable-muzzle.yml
+ shell-script-check:
+ uses: ./.github/workflows/reusable-shell-script-check.yml
+
markdown-link-check:
uses: ./.github/workflows/reusable-markdown-link-check.yml

MODIFY
.github/workflows/build-pull-request.yml
.github/workflows/build-pull-request.yml
@@ -29,9 +29,17 @@ jobs:
with:
cache-read-only: true
+ # this is not a required check to avoid blocking pull requests if new shell checks are added
+ shell-script-check:
+ # release branches are excluded to avoid unnecessary maintenance if new shell checks are added
+ if: ${{ !startsWith(github.ref_name, 'release/') }}
+ uses: ./.github/workflows/reusable-shell-script-check.yml
+
# this is not a required check to avoid blocking pull requests if external links break
markdown-link-check:
- # release branches are excluded to avoid unnecessary maintenance
+ # release branches are excluded to avoid unnecessary maintenance if external links break
+ # (and also because the README.md javaagent download link has to be updated on release branches
+ # before the release download has been published)
if: ${{ !startsWith(github.ref_name, 'release/') }}
uses: ./.github/workflows/reusable-markdown-link-check.yml

MODIFY
.github/workflows/build.yml
.github/workflows/build.yml
@@ -33,6 +33,11 @@ jobs:
if: ${{ !startsWith(github.ref_name, 'release/') }}
uses: ./.github/workflows/reusable-muzzle.yml
+ shell-script-check:
+ # release branches are excluded to avoid unnecessary maintenance if new shell checks are added
+ if: ${{ !startsWith(github.ref_name, 'release/') }}
+ uses: ./.github/workflows/reusable-shell-script-check.yml
+
markdown-link-check:
# release branches are excluded to avoid unnecessary maintenance if external links break
# (and also because the README.md javaagent download link has to be updated on release branches

ADD
.github/workflows/reusable-shell-script-check.yml
+name: Reusable - Shell script check
+
+on:
+ workflow_call:
+
+jobs:
+ shell-script-check:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install shell check
+ run: wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv
+
+ - name: Run shellcheck
+ run: find -name '*.sh' | xargs shellcheck-stable/shellcheck --format=gcc

MODIFY
smoke-tests/src/test/resources/crashearlyjdk8/start.sh
smoke-tests/src/test/resources/crashearlyjdk8/start.sh
-#/bin/sh
+#!/bin/bash -e
echo "started"
while :

MODIFY
smoke-tests/src/test/resources/crashearlyjdk8/test.sh
smoke-tests/src/test/resources/crashearlyjdk8/test.sh
-#/bin/sh
+#!/bin/bash -e
echo "compiling"
javac CrashEarlyJdk8.java

Add shell check (#7125)

Motivated by @mateuszrzeszutek's
https://github.com/signalfx/splunk-otel-java/pull/992