fix(deprecate): echo ::set-output is deprecated, use environment files

GitHub deprecated the `set-output` (and `set-state`, which we did not
use) commands in Actions scripts due to trust issues.

This patch moves the output management to the new format involving
_"Environment files"_.
This commit is contained in:
Whisperity
2022-10-15 16:55:56 +02:00
parent dd6bc71195
commit 149e5f70f9
12 changed files with 49 additions and 42 deletions

View File

@@ -171,7 +171,11 @@ runs:
IN_VERSION: ${{ inputs.version }}
shell: bash
run: |
set -x
echo "Creating a CodeChecker package..."
if [[ ! -z "$CODECHECKER_ACTION_DEBUG" ]]; then
set -x
fi
if [[ "$IN_INSTALL_CUSTOM" == "true" ]]; then
${{ github.action_path }}/src/build-codechecker.sh
else
@@ -227,16 +231,19 @@ runs:
id: analyze-or-report
shell: bash
run: |
echo "(Executing GitHub Actions technical detail...)"
echo "::group::(Technical detail, forwarding result of analysis...)"
if [[ ! -z "$CODECHECKER_ACTION_DEBUG" ]]; then
set -x
fi
if [[ "${{ inputs.report-converter }}" != "true" ]]
then
echo "::set-output name=OUTPUT_DIR::${{ steps.analyze.outputs.OUTPUT_DIR }}"
echo "OUTPUT_DIR=${{ steps.analyze.outputs.OUTPUT_DIR }}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=OUTPUT_DIR::${{ steps.report-convert.outputs.OUTPUT_DIR }}"
echo "OUTPUT_DIR=${{ steps.report-convert.outputs.OUTPUT_DIR }}" >> "$GITHUB_OUTPUT"
fi
echo "::endgroup::"
- name: "Parse and convert results to HTML"
id: parse

View File

@@ -38,8 +38,8 @@ else
echo "CodeChecker 'web' package not built."
fi
echo "::set-output name=PATH::$(readlink -f ./build/CodeChecker/bin)"
echo "::set-output name=VERSION::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=GITSEVEN::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"
echo "PATH=$(readlink -f ./build/CodeChecker/bin)" >> "$GITHUB_OUTPUT"
echo "VERSION=$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')" >> "$GITHUB_OUTPUT"
echo "GITSEVEN=$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)" >> "$GITHUB_OUTPUT"
popd

View File

@@ -23,27 +23,27 @@ fi
if [[ ! -z "$IN_DIFF_RUN_NAME" && "$IN_DIFF_RUN_NAME" != "__DEFAULT__" ]]; then
echo "Using user-requested run name."
echo "::set-output name=RUN_NAME::$IN_DIFF_RUN_NAME"
echo "::set-output name=DIFF_CONFIGURED::true"
echo "RUN_NAME=$IN_DIFF_RUN_NAME" >> "$GITHUB_OUTPUT"
echo "DIFF_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo "Auto-generating run name for a PULL REQUEST's target (base)."
echo "::set-output name=RUN_NAME::$GITHUB_REPOSITORY\: $GITHUB_BASE_REF"
echo "::set-output name=DIFF_CONFIGURED::true"
echo "RUN_NAME=$GITHUB_REPOSITORY\: $GITHUB_BASE_REF" >> "$GITHUB_OUTPUT"
echo "DIFF_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
elif [[ "$GITHUB_REF_TYPE" == "branch" ]]; then
echo "Auto-generating run name for a BRANCH."
echo "::set-output name=RUN_NAME::$GITHUB_REPOSITORY\: $GITHUB_REF_NAME"
echo "::set-output name=DIFF_CONFIGURED::true"
echo "RUN_NAME=$GITHUB_REPOSITORY\: $GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
echo "DIFF_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
elif [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
echo "Auto-generating run name for a TAG."
echo "::set-output name=RUN_NAME::$GITHUB_REPOSITORY tags"
echo "::set-output name=DIFF_CONFIGURED::true"
echo "RUN_NAME=$GITHUB_REPOSITORY tags" >> "$GITHUB_OUTPUT"
echo "DIFF_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "::notice title=Preparation for diff::Failed to generate a run name. Implementation error?"
echo "::set-output name=DIFF_CONFIGURED::false"
echo "DIFF_CONFIGURED=false" >> "$GITHUB_OUTPUT"

View File

@@ -40,7 +40,7 @@ echo "::group::Generating HTML results from diff"
--output html \
--export "$OUTPUT_DIR" \
|| true
echo "::set-output name=HTML_DIR::$OUTPUT_DIR"
echo "HTML_DIR=$OUTPUT_DIR" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo "::group::Printing diff results to log"
@@ -54,17 +54,17 @@ echo "::group::Printing diff results to log"
EXIT_CODE=$?
cat "$OUTPUT_LOG"
echo "::set-output name=OUTPUT_LOG::$OUTPUT_LOG"
echo "OUTPUT_LOG=$OUTPUT_LOG" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
if [[ $EXIT_CODE -eq 2 ]]; then
echo "::set-output name=HAS_NEW_FINDINGS::true"
echo "HAS_NEW_FINDINGS=true" >> "$GITHUB_OUTPUT"
# Let the job continue. If there were new results, the script may be breaking
# the build in a later step. (After a potential upload to server.)
EXIT_CODE=0
elif [[ $EXIT_CODE -eq 0 ]]; then
echo "::set-output name=HAS_NEW_FINDINGS::false"
echo "HAS_NEW_FINDINGS=false" >> "$GITHUB_OUTPUT"
fi
# Exit code 1 is internal error of executing the step.

View File

@@ -49,5 +49,5 @@ if [[ $EXIT_CODE -ne 0 && "$IN_IGNORE_CRASHES" == "true" ]]; then
EXIT_CODE=0
fi
echo "::set-output name=OUTPUT_DIR::$OUTPUT_DIR"
echo "OUTPUT_DIR=$OUTPUT_DIR" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE

View File

@@ -33,4 +33,4 @@ update-alternatives --query clang
update-alternatives --query clang-tidy
echo "::endgroup::"
echo "::set-output name=REAL_VERSION::$(clang --version | head -n 1 | cut -d' ' -f4-)"
echo "REAL_VERSION=$(clang --version | head -n 1 | cut -d' ' -f4-)" >> "$GITHUB_OUTPUT"

View File

@@ -29,5 +29,5 @@ else
exit 1
fi
echo "::set-output name=COMPILATION_DATABASE::$OUT_FILE"
echo "COMPILATION_DATABASE=$OUT_FILE" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE

View File

@@ -32,7 +32,7 @@ echo "::group::Generating HTML results from analysis"
--output "$OUTPUT_DIR" \
--trim-path-prefix "$PROJECT_PATH" \
|| true
echo "::set-output name=HTML_DIR::$OUTPUT_DIR"
echo "HTML_DIR=$OUTPUT_DIR" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
echo "::group::Printing analysis results to log"
@@ -43,17 +43,17 @@ echo "::group::Printing analysis results to log"
EXIT_CODE=$?
cat "$OUTPUT_LOG"
echo "::set-output name=OUTPUT_LOG::$OUTPUT_LOG"
echo "OUTPUT_LOG=$OUTPUT_LOG" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
if [[ $EXIT_CODE -eq 2 ]]; then
echo "::set-output name=HAS_FINDINGS::true"
echo "HAS_FINDINGS=true" >> "$GITHUB_OUTPUT"
# Let the jobs continue. If there were findings, the script may be breaking
# the build in a later step. (After a potential upload to server.)
EXIT_CODE=0
elif [[ $EXIT_CODE -eq 0 ]]; then
echo "::set-output name=HAS_FINDINGS::false"
echo "HAS_FINDINGS=false" >> "$GITHUB_OUTPUT"
fi
# Exit code 1 is internal error of executing the step.

View File

@@ -18,6 +18,6 @@ which CodeChecker
CodeChecker analyzer-version
CodeChecker web-version
echo "::set-output name=PATH::$(dirname $(which CodeChecker))"
echo "::set-output name=VERSION::$(CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=GITSEVEN::$(CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"
echo "PATH=$(dirname $(which CodeChecker))" >> "$GITHUB_OUTPUT"
echo "VERSION=$(CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')" >> "$GITHUB_OUTPUT"
echo "GITSEVEN=$(CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)" >> "$GITHUB_OUTPUT"

View File

@@ -44,5 +44,5 @@ if [[ $EXIT_CODE -ne 0 && "$IN_IGNORE_CRASHES" == "true" ]]; then
EXIT_CODE=0
fi
echo "::set-output name=OUTPUT_DIR::$OUTPUT_DIR"
echo "OUTPUT_DIR=$OUTPUT_DIR" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE

View File

@@ -23,25 +23,25 @@ fi
if [[ ! -z "$IN_STORE_RUN_NAME" && "$IN_STORE_RUN_NAME" != "__DEFAULT__" ]]; then
echo "Using user-requested run name."
echo "::set-output name=RUN_NAME::$IN_STORE_RUN_NAME"
echo "::set-output name=RUN_TAG::"
echo "::set-output name=STORE_CONFIGURED::true"
echo "RUN_NAME=$IN_STORE_RUN_NAME" >> "$GITHUB_OUTPUT"
echo "RUN_TAG=" >> "$GITHUB_OUTPUT"
echo "STORE_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$GITHUB_REF_TYPE" == "branch" ]]; then
echo "Auto-generating run name for a BRANCH."
echo "::set-output name=RUN_NAME::$GITHUB_REPOSITORY: $GITHUB_REF_NAME"
echo "::set-output name=RUN_TAG::$GITHUB_SHA"
echo "::set-output name=STORE_CONFIGURED::true"
echo "RUN_NAME=$GITHUB_REPOSITORY: $GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
echo "RUN_TAG=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
echo "STORE_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
elif [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
echo "Auto-generating run name for a TAG."
echo "::set-output name=RUN_NAME::$GITHUB_REPOSITORY tags"
echo "::set-output name=RUN_TAG::$GITHUB_REF_NAME"
echo "::set-output name=STORE_CONFIGURED::true"
echo "RUN_NAME=$GITHUB_REPOSITORY tags" >> "$GITHUB_OUTPUT"
echo "RUN_TAG=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
echo "STORE_CONFIGURED=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "::notice title=Preparation for store::Failed to generate a run name. Implementation error?"
echo "::set-output name=STORE_CONFIGURED::false"
echo "STORE_CONFIGURED=false" >> "$GITHUB_OUTPUT"

View File

@@ -51,9 +51,9 @@ echo "::endgroup::"
if [[ $SUCCESS -ne 0 ]]; then
echo "::warning title=Storing results failed::Executing 'CodeChecker store' to upload analysis results to the server has failed. The logs usually provide more information."
echo "::set-output name=SUCCESS::false"
echo "SUCCESS=false" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=SUCCESS::true"
echo "SUCCESS=true" >> "$GITHUB_OUTPUT"
fi
# Always return 0 from this step. The user can decide if storage is mandatory