aksd: record telemetry consent changes and make opt-out immediate #1804
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| env: | |
| NODE_VERSION: "20" | |
| jobs: | |
| plugin-packaging: | |
| name: Test plugin packaging | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run plugin packaging tests | |
| run: npm run test:build | |
| find_changed_plugins: | |
| name: Find changed plugins | |
| runs-on: ubuntu-latest | |
| outputs: | |
| plugins: ${{ steps.detect.outputs.plugins }} | |
| has_translation_plugins: ${{ steps.detect.outputs.has_translation_plugins }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch base branch | |
| run: git fetch origin main | |
| - name: Detect changed plugins | |
| id: detect | |
| run: | | |
| changed_files=$(git diff --name-only origin/main...HEAD) | |
| echo "Changed files:" | |
| printf '%s\n' "$changed_files" | |
| if [ -z "$changed_files" ]; then | |
| echo "No changed files detected." | |
| changed_plugins="" | |
| # If any changed file is outside plugins/ or Localize/, run all plugins. | |
| # This includes .github/ and shared root-level files such as package.json, | |
| # lockfiles, common scripts, and repo-wide config. | |
| elif printf '%s\n' "$changed_files" | grep -qvE '^(plugins/|Localize/)'; then | |
| echo "Global-impact changes detected outside plugins/ or Localize/, running all plugins." | |
| changed_plugins=$(grep -lR 'headlamp-plugin' ./plugins/*/package.json | xargs -n1 dirname | xargs -n1 basename | sort -u) | |
| else | |
| # Extract changed plugin names (second path segment under plugins/) | |
| changed_plugins=$(printf '%s\n' "$changed_files" | grep '^plugins/' | awk -F/ '{print $2}' | sort -u) | |
| fi | |
| TRANSLATION_PLUGINS=(aks-desktop ai-assistant) | |
| plugin_dirs=() | |
| has_translation_plugins=false | |
| for dir in $changed_plugins; do | |
| pkg="plugins/$dir/package.json" | |
| if [ -f "$pkg" ] && grep -q 'headlamp-plugin' "$pkg"; then | |
| plugin_dirs+=("$dir") | |
| for tp in "${TRANSLATION_PLUGINS[@]}"; do | |
| if [ "$dir" = "$tp" ]; then | |
| has_translation_plugins=true | |
| fi | |
| done | |
| fi | |
| done | |
| # Also trigger translations if Localize/ changed directly | |
| if printf '%s\n' "$changed_files" | grep -q '^Localize/'; then | |
| has_translation_plugins=true | |
| fi | |
| if [ ${#plugin_dirs[@]} -eq 0 ]; then | |
| echo "No changed plugins found." | |
| final_json="[]" | |
| else | |
| echo "Changed plugins: ${plugin_dirs[*]}" | |
| final_json=$(printf '%s\n' "${plugin_dirs[@]}" | jq --raw-input --slurp --compact-output 'split("\n")[:-1]') | |
| fi | |
| echo "plugins=$final_json" >> "$GITHUB_OUTPUT" | |
| echo "has_translation_plugins=$has_translation_plugins" >> "$GITHUB_OUTPUT" | |
| test: | |
| name: Test (${{ matrix.plugin }}) | |
| needs: find_changed_plugins | |
| if: needs.find_changed_plugins.outputs.plugins != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| plugin: ${{ fromJson(needs.find_changed_plugins.outputs.plugins) }} | |
| defaults: | |
| run: | |
| working-directory: plugins/${{ matrix.plugin }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| cache-dependency-path: plugins/${{ matrix.plugin }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run type checking | |
| run: npm run tsc | |
| - name: Run build | |
| run: npm run build | |
| - name: Run tests | |
| run: npm test | |
| lint: | |
| name: Lint & Format (${{ matrix.plugin }}) | |
| needs: find_changed_plugins | |
| if: needs.find_changed_plugins.outputs.plugins != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| plugin: ${{ fromJson(needs.find_changed_plugins.outputs.plugins) }} | |
| defaults: | |
| run: | |
| working-directory: plugins/${{ matrix.plugin }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| cache-dependency-path: plugins/${{ matrix.plugin }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run ESLint | |
| run: npm run lint | |
| - name: Check Prettier formatting | |
| run: npm run format -- --check | |
| build: | |
| name: Build (${{ matrix.plugin }}) | |
| needs: [find_changed_plugins, test, lint] | |
| if: needs.find_changed_plugins.outputs.plugins != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| plugin: ${{ fromJson(needs.find_changed_plugins.outputs.plugins) }} | |
| defaults: | |
| run: | |
| working-directory: plugins/${{ matrix.plugin }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| cache-dependency-path: plugins/${{ matrix.plugin }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build plugin | |
| run: npm run build | |
| - name: Package plugin | |
| run: npm run package | |
| # - name: Upload build artifacts | |
| # uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
| # with: | |
| # name: build-artifacts | |
| # path: | | |
| # dist/ | |
| # *.tgz | |
| # retention-days: 90 | |
| translations: | |
| name: Translations | |
| needs: find_changed_plugins | |
| if: needs.find_changed_plugins.outputs.has_translation_plugins == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| cache-dependency-path: | | |
| plugins/aks-desktop/package-lock.json | |
| plugins/ai-assistant/package-lock.json | |
| - name: Install dependencies (aks-desktop) | |
| working-directory: plugins/aks-desktop | |
| run: npm ci | |
| - name: Install dependencies (ai-assistant) | |
| working-directory: plugins/ai-assistant | |
| run: npm ci | |
| - name: Generate English locale (aks-desktop) | |
| working-directory: plugins/aks-desktop | |
| run: npm run i18n | |
| - name: Generate English locale (ai-assistant) | |
| working-directory: plugins/ai-assistant | |
| run: npm run i18n | |
| - name: Collect translations | |
| run: npm run i18n:collect | |
| - name: Check translations are up to date | |
| run: | | |
| if [ -n "$(git status --porcelain Localize/)" ]; then | |
| echo "::error::Translation files are out of date. Run 'npm run i18n:collect' locally and commit the changes." | |
| git diff Localize/ | |
| exit 1 | |
| fi | |
| security: | |
| name: Security Scan (${{ matrix.plugin }}) | |
| needs: find_changed_plugins | |
| if: needs.find_changed_plugins.outputs.plugins != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| plugin: ${{ fromJson(needs.find_changed_plugins.outputs.plugins) }} | |
| defaults: | |
| run: | |
| working-directory: plugins/${{ matrix.plugin }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| cache-dependency-path: plugins/${{ matrix.plugin }}/package-lock.json | |
| - name: Run npm audit | |
| run: npm audit --audit-level=moderate | |
| continue-on-error: true |