Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support functions for future CLI ⚡ #405

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ is_debug () {
return ${result}
}

# Function to check if the script is run in GitHub Actions environment
# GITHUB_ACTIONS is set when Differential ShellCheck is running in GitHub Actions
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
is_github_actions () {
if [[ -z "${GITHUB_ACTIONS}" ]]; then
return 1
fi

return 0
}

# Function to upload the SARIF report to GitHub
# Source: https://github.com/github/codeql-action/blob/dbe6f211e66b3aa5e9a5c4731145ed310ed54e28/lib/upload-lib.js#L104-L106
# Parameters: https://github.com/github/codeql-action/blob/69e09909dc219ed3374913e41c167490fc57202a/lib/upload-lib.js#L211-L224
Expand Down
2 changes: 2 additions & 0 deletions src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# shellcheck source=functions.sh
. "${SCRIPT_DIR="${CURRENT_DIR}/"}functions.sh"
# shellcheck source=setup.sh
. "${SCRIPT_DIR=}setup.sh"

Check warning

Code scanning / shellcheck

SC1091 Warning

Not following: setup.sh: openBinaryFile: does not exist (No such file or directory)

WORK_DIR="${WORK_DIR-../}"

Expand Down
12 changes: 12 additions & 0 deletions src/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# shellcheck shell=bash

# TODO set up required variables

# Set required variables based on the environment
if is_github_actions; then
is_debug && echo "Running in GitHub Actions"
else
is_debug && \
echo "Running in non GitHub Actions environment" && \
echo "Functionality is limited"
fi