Skip to content
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
26 changes: 26 additions & 0 deletions .github/workflows/deprecate-archived-plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deprecate Archived Plugins

on:
push:
paths:
- '.github/archived-plugins.json'
branches:
- main

jobs:
deprecate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'

- name: Deprecate packages
run: ./scripts/ci/deprecate-archived-plugins.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.RHDH_NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org
59 changes: 59 additions & 0 deletions scripts/ci/deprecate-archived-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

# Get script directory and archived file path
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ARCHIVED_FILE="$(dirname "$(dirname "$SCRIPT_DIR")")/.github/archived-plugins.json"

# Check if dry run (first argument)
DRY_RUN=${1:-false}

if [[ "$DRY_RUN" == "--dry-run" ]]; then
DRY_RUN=true
echo "DRY RUN MODE"
else
DRY_RUN=false
fi

echo "Processing archived packages..."

# Extract unique plugins from archived-plugins.json file
# Format: package_name|workspace|plugin|reason
jq -r '
.archived
| unique_by(.pluginName)
| .[]
| "\(.pluginName)|\(.workspace)|\(.plugin)|\(.reason)"
' "$ARCHIVED_FILE" | while IFS='|' read -r package_name workspace plugin reason; do
Comment on lines +3 to +28

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Pipeline masks jq failure 🐞 Bug ☼ Reliability

scripts/ci/deprecate-archived-plugins.sh uses set -e but pipes jq into a while loop without
pipefail, so missing/invalid JSON (or a missing file) can cause jq to fail while the script
still exits successfully. This can make the workflow report success while performing zero
deprecations, hiding operational failures.
Agent Prompt
### Issue description
The deprecation script can silently succeed when `jq` fails (e.g., missing file, invalid JSON/query) because `set -e` does not catch failures inside a pipeline whose last command succeeds.

### Issue Context
The script currently does `jq ... "$ARCHIVED_FILE" | while ...; do ...; done`. In bash, without `set -o pipefail`, the pipeline status is the status of the `while` loop, not `jq`.

### Fix Focus Areas
- scripts/ci/deprecate-archived-plugins.sh[1-59]

### Suggested fix
- Switch to `set -euo pipefail`.
- Avoid piping into `while`; instead use process substitution:
  - `while ...; do ...; done < <(jq -r '...' "$ARCHIVED_FILE")`
- Optionally add an explicit file check before running jq:
  - `[[ -f "$ARCHIVED_FILE" ]] || { echo "Missing $ARCHIVED_FILE"; exit 1; }`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


# Check if already deprecated
if npm view "$package_name" deprecated 2>/dev/null | grep -q .; then
echo "Already deprecated: $package_name"
continue
fi
# Generate deprecation message
message="This package has been archived from the redhat-developer/rhdh-plugins repository"
[[ -n "$plugin" ]] && message="$message (plugin: $plugin)"
[[ -n "$reason" ]] && message="$message. Reason: $reason"
message="$message."

if [[ "$DRY_RUN" == "true" ]]; then
echo "Would deprecate: $package_name"
echo " Message: $message"
else
echo "Deprecating: $package_name"

# Validate package exists and is accessible before deprecating
if ! npm view "$package_name" version &>/dev/null; then
echo "Error: Cannot view package $package_name"

Check warning on line 49 in scripts/ci/deprecate-archived-plugins.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Redirect this error message to stderr (>&2).

See more on https://sonarcloud.io/project/issues?id=redhat-developer_rhdh-plugins&issues=AZ1JVxyXxDMSx2rFh2io&open=AZ1JVxyXxDMSx2rFh2io&pullRequest=2664
continue
fi

echo "Running: npm deprecate $package_name \"$message\""
npm deprecate "$package_name" "$message"
echo "Done: $package_name"
fi
done

echo "Complete!"
Loading