open-vault/scripts/deprecations-checker.sh

39 lines
1.5 KiB
Bash
Raw Normal View History

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# This script is sourced into the shell running in a Github Actions workflow.
# Usage:
# To check deprecations locally using the script, follow these steps:
# From the repository root or within a package folder, execute deprecations-checker.sh
# Optionally: to only show deprecations in changed files between the current branch and
# a specific branch, pass the other branch name as an argument to the script.
#
# For example:
# ./scripts/deprecations-checker.sh (or) make deprecations
# ./scripts/deprecations-checker.sh main (or) make ci-deprecations
#
# If no branch name is specified, the command will show all usage of deprecations in the code.
#
# GitHub Actions runs this against the PR's base ref branch.
# Staticcheck uses static analysis to finds bugs and performance issues, offers simplifications,
# and enforces style rules.
# Here, it is used to check if a deprecated function, variable, constant or field is used.
# Run staticcheck
set -e
echo "Performing deprecations check: running staticcheck"
# If no compare branch name is specified, output all deprecations
# Else only output the deprecations from the changes added
if [ -z $1 ]
then
staticcheck -checks="SA1019" -tags="$BUILD_TAGS"
else
# GitHub Actions will use this to find only changes wrt PR's base ref branch
# revgrep CLI tool will return an exit status of 1 if any issues match, else it will return 0
Backport of Limit number of tests in CI comment into release/1.14.x (#21971) * backport of commit dc104898f700447f7764919445c7559baeb7e987 (#21853) * fix multiline * shellcheck, and success message for builds * add full path * cat the summary * fix and faster * fix if condition * base64 in a separate step * echo * check against empty string * add echo * only use matrix ids * only id * echo matrix * remove wrapping array * tojson * try echo again * use jq to get packages * don't quote * only run binary tests once * only run binary tests once * test what's wrong with the binary * separate file * use matrix file * failed test * update comment on success * correct variable name * bae64 fix * output to file * use multiline * fix * fix formatting * fix newline * fix whitespace * correct body, remove comma * small fixes * shellcheck * another shellcheck fix * fix deprecation checker * only run comments for prs * Update .github/workflows/test-go.yml Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com> * Update .github/workflows/test-go.yml Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com> * fixes --------- Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com> * backport of commit 3b00dde1ba4d479fbd67b1d0767e421e495d8cce (#21936) * limit test comments * remove unecessary tee * fix go test condition * fix * fail test * remove ailways entirely * fix columns * make a bunch of tests fail * separate line * include Failures: * remove test fails * fix whitespace * backport of commit 245430215c00d80a38283020fca114bade022e0f (#21973) * only add binary tests if they exist * shellcheck --------- Co-authored-by: miagilepner <mia.epner@hashicorp.com> Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com>
2023-07-20 13:07:20 +00:00
staticcheck -checks="SA1019" -tags="$BUILD_TAGS" 2>&1 | revgrep origin/"$1"
fi