Add Radius plugin #1552
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Headlamp plugin linting, type checking, and testing | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| env: | |
| HEADLAMP_PLUGIN_VERSION: latest | |
| jobs: | |
| # Get list of folders containing changed headlamp plugins | |
| # We need a separate step to be able to pass the list to the matrix of the build job | |
| find_changed_plugin_dirs: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| dirs: ${{ steps.dirs.outputs.dirs }} | |
| steps: | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| fetch-depth: 0 # Fetch all history | |
| - name: Fetch base branch | |
| run: git fetch origin main | |
| - name: Find changed Headlamp plugin directories | |
| id: dirs | |
| run: | | |
| # Get all top-level directories that had changes | |
| changed_dirs=$(git diff --name-only origin/main...HEAD | awk -F/ '{print $1}' | sort -u) | |
| echo "Changed directories: $changed_dirs" | |
| # If .github/ changed, run all plugins | |
| if echo "$changed_dirs" | tr ' ' '\n' | grep -q '^\.github$'; then | |
| echo "Changes detected in .github/ directory, running all plugins." | |
| changed_dirs=$(grep -lR 'headlamp-plugin' ./*/package.json | xargs -n1 dirname | sort -u) | |
| echo "Changed directories: $changed_dirs" | |
| fi | |
| plugin_dirs=() | |
| for dir in $changed_dirs; do | |
| pkg="$dir/package.json" | |
| if [ -f "$pkg" ] && grep -q 'headlamp-plugin' "$pkg"; then | |
| plugin_dirs+=("$dir") | |
| fi | |
| done | |
| # Output as JSON array for matrix | |
| if [ ${#plugin_dirs[@]} -eq 0 ]; then | |
| echo "No changed Headlamp plugins found." | |
| final_json="[]" | |
| else | |
| echo "Changed Headlamp plugin directories: ${plugin_dirs[*]}" | |
| final_json=$(printf '%s\n' "${plugin_dirs[@]}" | jq --raw-input --slurp --compact-output 'split("\n")[:-1]') | |
| fi | |
| echo "Final plugin_dirs JSON: $final_json" | |
| echo "dirs=$final_json" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: find_changed_plugin_dirs | |
| if: needs.find_changed_plugin_dirs.outputs.dirs != '[]' | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./${{ matrix.dir }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [22.x] | |
| dir: ${{ fromJson(needs.find_changed_plugin_dirs.outputs.dirs) }} | |
| steps: | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "npm" | |
| cache-dependency-path: ${{ matrix.dir }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build ${{ matrix.dir }} | |
| run: npm run build | |
| - name: Typecheck ${{ matrix.dir }} | |
| run: npm run tsc | |
| - name: Lint ${{ matrix.dir }} | |
| run: npm run lint | |
| - name: Check formatting ${{ matrix.dir }} | |
| run: npm run format -- --check | |
| - name: Test ${{ matrix.dir }} | |
| run: npm run test |