Actions: Introduce Shellcheck action (#106843)

This commit is contained in:
Mariell Hoversholm
2025-06-17 21:15:03 +02:00
committed by GitHub
parent 689cafc1fa
commit 18fc0bc878
8 changed files with 35 additions and 100 deletions

View File

@ -24,10 +24,6 @@ load(
"scripts/drone/pipelines/lint_backend.star",
"lint_backend_pipeline",
)
load(
"scripts/drone/pipelines/shellcheck.star",
"shellcheck_pipeline",
)
load(
"scripts/drone/pipelines/swagger_gen.star",
"swagger_gen",
@ -136,7 +132,6 @@ def pr_pipelines():
prefix = ver_mode,
),
docs_pipelines(ver_mode, trigger_docs_pr()),
shellcheck_pipeline(),
swagger_gen(
ver_mode,
),

View File

@ -1,49 +0,0 @@
"""
This module returns a Drone step and pipeline for linting with shellcheck.
"""
load(
"scripts/drone/utils/images.star",
"images",
)
load(
"scripts/drone/utils/utils.star",
"pipeline",
)
trigger = {
"event": [
"pull_request",
],
"paths": {
"exclude": [
"*.md",
"docs/**",
"latest.json",
],
"include": ["scripts/**/*.sh"],
},
}
def shellcheck_step():
return {
"name": "shellcheck",
"image": images["ubuntu"],
"commands": [
"apt-get update -yq && apt-get install shellcheck",
"shellcheck -e SC1071 -e SC2162 scripts/**/*.sh",
],
}
def shellcheck_pipeline():
environment = {"EDITION": "oss"}
steps = [
shellcheck_step(),
]
return pipeline(
name = "pr-shellcheck",
trigger = trigger,
services = [],
steps = steps,
environment = environment,
)

View File

@ -33,7 +33,6 @@ images = {
"docs": "grafana/docs-base:latest",
"cypress": "cypress/included:14.3.2",
"dockerize": "jwilder/dockerize:0.6.1",
"shellcheck": "koalaman/shellcheck:stable",
"rocky": "rockylinux:9",
"wine": "scottyhardy/docker-wine:stable-9.0",
"github_app_secret_writer": "us-docker.pkg.dev/grafanalabs-global/docker-deployment-tools-prod/github-app-secret-writer:2024-11-05-v11688112090.1-83920c59",

View File

@ -47,14 +47,14 @@ done
# Check if any files in packages/grafana-e2e-selectors were changed. If so, add a 'modified' tag to the package
CHANGES_COUNT=$(git diff HEAD~1..HEAD --name-only -- packages/grafana-e2e-selectors | awk 'END{print NR}')
if (( $CHANGES_COUNT > 0 )); then
if (( CHANGES_COUNT > 0 )); then
# Wait a little bit to allow the package to be published to the registry
sleep 5s
regex_pattern="canary: ([0-9.-]+)"
TAGS=$(npm dist-tag ls @grafana/e2e-selectors)
if [[ $TAGS =~ $regex_pattern ]]; then
echo "$CHANGES_COUNT file(s) in packages/grafana-e2e-selectors were changed. Adding 'modified' tag to @grafana/e2e-selectors@${BASH_REMATCH[1]}"
npm dist-tag add @grafana/e2e-selectors@${BASH_REMATCH[1]} modified
npm dist-tag add @grafana/e2e-selectors@"${BASH_REMATCH[1]}" modified
fi
fi

View File

@ -61,7 +61,7 @@ echo " Date: $(git log -1 --format="%ad" --date=iso "$COMMIT_HASH")"
# Extract original PR number and create link
PR_NUMBER=$(git log -1 --pretty=format:"%B" "$COMMIT_HASH" | grep -o '#[0-9]\+' | head -n1 | tr -d '#')
if [ ! -z "$PR_NUMBER" ]; then
if [ -n "$PR_NUMBER" ]; then
# Extract PR title (first line of commit message)
PR_TITLE=$(git log -1 --pretty=format:"%s" "$COMMIT_HASH")
echo " PR: #$PR_NUMBER - $PR_TITLE"
@ -104,7 +104,7 @@ done
if [ ${#direct_tags[@]} -gt 0 ] || [ ${#included_tags[@]} -gt 0 ]; then
echo "This commit has been included in these PREVIOUS on-prem releases:"
# Get all tags sorted
all_tags=($(printf "%s\n" "${direct_tags[@]}" "${included_tags[@]}" | sort -V))
readarray -t all_tags < <(printf "%s\n" "${direct_tags[@]}" "${included_tags[@]}" | sort -V)
# Get the first release
first_release="${all_tags[0]}"
# Print all tags with annotation for the first release