Skip to content
Open
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
20 changes: 7 additions & 13 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,10 @@ on:

# Build options.
plugin-directory:
description: Directory of the plugin, if not in the root of the repository. If provided, package-manager must also be provided.
description: Directory of the plugin, if not in the root of the repository.
type: string
required: false
default: .
package-manager:
description: The package manager to use.
type: string
required: false
default: ""
npm-registry-auth:
description: |
Whether to authenticate to the npm registry in Google Artifact Registry.
Expand Down Expand Up @@ -346,13 +341,12 @@ jobs:

ci:
name: CI
uses: grafana/plugin-ci-workflows/.github/workflows/ci.yml@main
uses: grafana/plugin-ci-workflows/.github/workflows/ci.yml@jackw/pm-detect # zizmor: ignore[unpinned-uses]
needs:
- setup
with:
branch: ${{ inputs.branch }}
plugin-directory: ${{ inputs.plugin-directory }}
package-manager: ${{ inputs.package-manager }}
npm-registry-auth: ${{ inputs.npm-registry-auth }}
go-version: ${{ inputs.go-version }}
go-setup-caching: ${{ inputs.go-setup-caching }}
Expand Down Expand Up @@ -563,7 +557,7 @@ jobs:
ENVIRONMENT: ${{ matrix.environment }}

- name: Check and create stub
uses: grafana/plugin-ci-workflows/actions/plugins/publish/check-and-create-stub@main
uses: grafana/plugin-ci-workflows/actions/plugins/publish/check-and-create-stub@jackw/pm-detect # zizmor: ignore[unpinned-uses]
if: ${{ matrix.environment != 'prod' }}
with:
plugin-id: ${{ fromJSON(needs.ci.outputs.plugin).id }}
Expand All @@ -572,13 +566,13 @@ jobs:
gcloud-auth-token: ${{ steps.gcloud.outputs.id_token }}

- name: Check artifact ZIP(s)
uses: grafana/plugin-ci-workflows/actions/plugins/publish/check-artifacts@main
uses: grafana/plugin-ci-workflows/actions/plugins/publish/check-artifacts@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
zips: ${{ needs.upload-to-gcs-release.outputs.gcs-zip-urls }}
plugin-id: ${{ fromJSON(needs.ci.outputs.plugin).id }}

- name: Publish to catalog
uses: grafana/plugin-ci-workflows/actions/plugins/publish/publish@main
uses: grafana/plugin-ci-workflows/actions/plugins/publish/publish@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
zips: ${{ needs.upload-to-gcs-release.outputs.gcs-zip-urls }}
environment: ${{ matrix.environment }}
Expand Down Expand Up @@ -883,7 +877,7 @@ jobs:
owner: ${{ github.repository_owner }}

- name: Publish docs
uses: grafana/plugin-ci-workflows/actions/plugins/docs/publish@main
uses: grafana/plugin-ci-workflows/actions/plugins/docs/publish@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
id: ${{ fromJSON(needs.ci.outputs.plugin).id }}
version: ${{ fromJSON(needs.ci.outputs.plugin).version }}
Expand Down Expand Up @@ -920,7 +914,7 @@ jobs:

- name: Parse changelog
id: changelog
uses: grafana/plugin-ci-workflows/actions/plugins/changelog@main
uses: grafana/plugin-ci-workflows/actions/plugins/changelog@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
changelog-path: ${{ inputs.plugin-directory }}/CHANGELOG.md

Expand Down
26 changes: 10 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,10 @@ on:

# Build options.
plugin-directory:
description: Directory of the plugin, if not in the root of the repository. If provided, package-manager must also be provided.
description: Directory of the plugin, if not in the root of the repository.
type: string
required: false
default: .
package-manager:
description: The package manager to use.
type: string
required: false
default: ""
frontend-secrets:
description: The secrets to use within frontend steps
type: string
Expand Down Expand Up @@ -277,7 +272,7 @@ jobs:
return o

- name: Setup
uses: grafana/plugin-ci-workflows/actions/plugins/setup@main
uses: grafana/plugin-ci-workflows/actions/plugins/setup@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
go-version: ${{ inputs.go-version || env.DEFAULT_GO_VERSION }}
node-version: ${{ inputs.node-version || env.DEFAULT_NODE_VERSION }}
Expand Down Expand Up @@ -339,24 +334,23 @@ jobs:
working-directory: ${{ inputs.plugin-directory }}

- name: Test and build frontend
uses: grafana/plugin-ci-workflows/actions/plugins/frontend@main
uses: grafana/plugin-ci-workflows/actions/plugins/frontend@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
package-manager: ${{ inputs.package-manager }}
plugin-directory: ${{ inputs.plugin-directory }}
secrets: ${{ (fromJson(steps.workflow-context.outputs.result).isTrusted && inputs.frontend-secrets != '') && inputs.frontend-secrets || '' }}
npm-registry-auth: ${{ inputs.npm-registry-auth }}

- name: Test and build backend
if: ${{ steps.check-for-backend.outputs.has-backend == 'true' }}
uses: grafana/plugin-ci-workflows/actions/plugins/backend@main
uses: grafana/plugin-ci-workflows/actions/plugins/backend@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
github-token: ${{ steps.generate-github-token.outputs.token }}
plugin-directory: ${{ inputs.plugin-directory }}
secrets: ${{ (fromJson(steps.workflow-context.outputs.result).isTrusted && inputs.backend-secrets != '') && inputs.backend-secrets || '' }}

- name: Package universal ZIP
id: universal-zip
uses: grafana/plugin-ci-workflows/actions/plugins/package@main
uses: grafana/plugin-ci-workflows/actions/plugins/package@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
universal: "true"
dist-folder: dist
Expand All @@ -366,7 +360,7 @@ jobs:

- name: Package os/arch ZIPs
id: os-arch-zips
uses: grafana/plugin-ci-workflows/actions/plugins/package@main
uses: grafana/plugin-ci-workflows/actions/plugins/package@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
universal: "false"
dist-folder: dist
Expand All @@ -376,7 +370,7 @@ jobs:

- name: Trufflehog secrets scanning
if: ${{ inputs.run-trufflehog == true }}
uses: grafana/plugin-ci-workflows/actions/plugins/trufflehog@main
uses: grafana/plugin-ci-workflows/actions/plugins/trufflehog@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
trufflehog-version: ${{ inputs.trufflehog-version || env.DEFAULT_TRUFFLEHOG_VERSION }}
folder: dist-artifacts
Expand Down Expand Up @@ -446,11 +440,11 @@ jobs:
shell: bash

- name: Test docs
uses: grafana/plugin-ci-workflows/actions/plugins/docs/test@main
uses: grafana/plugin-ci-workflows/actions/plugins/docs/test@jackw/pm-detect # zizmor: ignore[unpinned-uses]

playwright:
name: Playwright E2E tests
uses: grafana/plugin-ci-workflows/.github/workflows/playwright.yml@main
uses: grafana/plugin-ci-workflows/.github/workflows/playwright.yml@jackw/pm-detect # zizmor: ignore[unpinned-uses]
if: ${{ inputs.run-playwright == true }}
needs:
- test-and-build
Expand All @@ -472,7 +466,7 @@ jobs:

playwright-docker:
name: Plugins - Dockerized Playwright E2E tests
uses: grafana/plugin-ci-workflows/.github/workflows/playwright-docker.yml@main
uses: grafana/plugin-ci-workflows/.github/workflows/playwright-docker.yml@jackw/pm-detect # zizmor: ignore[unpinned-uses]
if: ${{ inputs.run-playwright-docker == true }}
needs:
- test-and-build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/playwright-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- name: Resolve Grafana E2E versions
id: resolve-versions
uses: grafana/plugin-actions/e2e-version@main
uses: grafana/plugin-actions/e2e-version@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
skip-grafana-dev-image: ${{ inputs.skip-grafana-dev-image }}
version-resolver-type: ${{ inputs.version-resolver-type }}
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
DOCKER_COMPOSE_FILE: ${{ inputs.grafana-compose-file }}

- name: Wait for Grafana to start
uses: grafana/plugin-actions/wait-for-grafana@main
uses: grafana/plugin-actions/wait-for-grafana@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
url: "${{ inputs.grafana-url }}"

Expand Down
30 changes: 19 additions & 11 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:

- name: Resolve Grafana E2E versions
id: resolve-versions
uses: grafana/plugin-actions/e2e-version@main
uses: grafana/plugin-actions/e2e-version@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
skip-grafana-dev-image: ${{ inputs.skip-grafana-dev-image }}
version-resolver-type: ${{ inputs.version-resolver-type }}
Expand All @@ -110,11 +110,24 @@ jobs:
with:
persist-credentials: false

- name: Detect package manager
id: package-manager
# TODO: Fix this once we have a version of the package-manager-detect action
uses: grafana/plugin-actions/package-manager-detect@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
working-directory: ${{ inputs.plugin-directory }}

- name: Install pnpm
if: steps.package-manager.outputs.name == 'pnpm'
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Setup Node.js environment
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ inputs.node-version }}
node-version-file: ${{ inputs.plugin-directory }}/.nvmrc
cache: ${{ steps.package-manager.outputs.name }}
cache-dependency-path: ${{ steps.package-manager.outputs.lockFilePath }}

- name: Login to Google Cloud
if: inputs.npm-registry-auth == true
Expand All @@ -131,13 +144,7 @@ jobs:
run: GOOGLE_APPLICATION_CREDENTIALS=${{ env.GOOGLE_APPLICATION_CREDENTIALS }} npx google-artifactregistry-auth --credential-config ./.npmrc

- name: Install npm dependencies
# TODO: find a better way
run: |
if [ -f yarn.lock ]; then
yarn install --frozen-lockfile
else
npm ci
fi
run: ${{ steps.package-manager.outputs.frozenInstallCmd }}
shell: bash
working-directory: ${{ inputs.plugin-directory }}

Expand Down Expand Up @@ -173,7 +180,8 @@ jobs:
key: playwright-${{ steps.version.outputs.version }}

- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
run: ${{ steps.package-manager.outputs.execCmd }} playwright install --with-deps chromium
shell: bash

- name: Download GitHub artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
Expand Down Expand Up @@ -222,13 +230,13 @@ jobs:
DOCKER_COMPOSE_FILE: ${{ inputs.docker-compose-file }}

- name: Wait for Grafana to start
uses: grafana/plugin-actions/wait-for-grafana@main
uses: grafana/plugin-actions/wait-for-grafana@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
url: "${{ inputs.grafana-url }}"

- name: Run Playwright tests
id: run-tests
run: npx playwright test --config "${PLAYWRIGHT_CONFIG}"
run: ${{ steps.package-manager.outputs.execCmd }} playwright test --config "${PLAYWRIGHT_CONFIG}"
env:
PLAYWRIGHT_CONFIG: ${{ inputs.playwright-config }}
GRAFANA_VERSION: ${{ matrix.GRAFANA_IMAGE.VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion actions/plugins/backend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
description: GitHub token for downloading dependencies from private repos, if necessary
required: true
plugin-directory:
description: Directory of the plugin, if not in the root of the repository. If provided, package-manager must also be provided.
description: Directory of the plugin, if not in the root of the repository.
required: false
default: .
secrets:
Expand Down
33 changes: 13 additions & 20 deletions actions/plugins/frontend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ description: Tests, lints, typechecks and builds the frontend.

inputs:
plugin-directory:
description: Directory of the plugin, if not in the root of the repository. If provided, package-manager must also be provided.
description: Directory of the plugin, if not in the root of the repository.
required: false
default: .
package-manager:
description: The package manager to use.
required: false
default: ""
secrets:
required: false
type: string
Expand Down Expand Up @@ -45,40 +41,37 @@ runs:
working-directory: ${{ inputs.plugin-directory }}
run: GOOGLE_APPLICATION_CREDENTIALS=${{ env.GOOGLE_APPLICATION_CREDENTIALS }} npx google-artifactregistry-auth --credential-config ./.npmrc

- name: Detect package manager
id: package-manager
# TODO: Fix this once we have a version of the package-manager-detect action
uses: grafana/plugin-actions/package-manager-detect@jackw/pm-detect # zizmor: ignore[unpinned-uses]
with:
working-directory: ${{ inputs.plugin-directory }}

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.plugin-directory }}
run: ${{ github.action_path }}/pm.sh install
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: ${{ steps.package-manager.outputs.frozenInstallCmd }}

- name: Lint
shell: bash
working-directory: ${{ inputs.plugin-directory }}
run: ${{ github.action_path }}/pm.sh lint
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: ${{ steps.package-manager.outputs.runCmd }} lint

- name: Typecheck
shell: bash
working-directory: ${{ inputs.plugin-directory }}
run: ${{ github.action_path }}/pm.sh typecheck
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: ${{ steps.package-manager.outputs.runCmd }} typecheck

- name: Test
shell: bash
working-directory: ${{ inputs.plugin-directory }}
run: ${{ github.action_path }}/pm.sh test:ci
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: ${{ steps.package-manager.outputs.runCmd }} test:ci

- name: Build
shell: bash
working-directory: ${{ inputs.plugin-directory }}
run: ${{ github.action_path }}/pm.sh build
env:
PACKAGE_MANAGER: ${{ inputs.package-manager }}
run: ${{ steps.package-manager.outputs.runCmd }} build

# The action should end up with a dist/ folder, but if the working directory is not the root of the repo,
# we need to copy the dist/ folder to the root of the repo.
Expand Down
39 changes: 0 additions & 39 deletions actions/plugins/frontend/pm.sh

This file was deleted.

Loading