Skip to content

Commit

Permalink
chore: Switch to pnpm + adjust to IRM (#4969)
Browse files Browse the repository at this point in the history
# What this PR does
- switch to pnpm
- adjust to IRM

## Which issue(s) this PR closes

Related to:
grafana/irm#12
grafana/irm#11
grafana/irm#66

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
brojd authored Sep 2, 2024
1 parent 4376207 commit 9bbd2c4
Show file tree
Hide file tree
Showing 19 changed files with 13,664 additions and 13,076 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build-sign-and-package-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ runs:
GRAFANA_ACCESS_POLICY_TOKEN: ${{ inputs.grafana_access_policy_token }}
run: |
jq --arg v "${{ inputs.plugin_version_number }}" '.version=$v' package.json > package.new && mv package.new package.json && jq '.version' package.json;
yarn build
pnpm build
mage buildAll || true
yarn sign
pnpm sign
if [ ! -f dist/MANIFEST.txt ]; then echo "Sign failed, MANIFEST.txt not created, aborting." && exit 1; fi
mv dist grafana-oncall-app
zip -r grafana-oncall-app.zip ./grafana-oncall-app
Expand Down
42 changes: 11 additions & 31 deletions .github/actions/install-frontend-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
name: "Install frontend dependencies"
description: "Setup node + install frontend dependencies"
inputs:
working-directory:
description: "Relative path to oncall/grafana-plugin directory"
required: false
default: "."
name: Install frontend dependencies
description: Setup node/pnpm + install frontend dependencies
runs:
using: "composite"
using: composite
steps:
- name: Determine grafana-plugin directory location
id: grafana-plugin-directory
shell: bash
run: echo "grafana-plugin-directory=${{ inputs.working-directory }}/grafana-plugin" >> $GITHUB_OUTPUT
- name: Determine yarn.lock location
id: yarn-lock-location
shell: bash
# yamllint disable rule:line-length
run: echo "yarn-lock-location=${{ steps.grafana-plugin-directory.outputs.grafana-plugin-directory }}/yarn.lock" >> $GITHUB_OUTPUT
# yamllint enable rule:line-length
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.4
- uses: actions/setup-node@v4
with:
node-version: 20.15.1
cache: "yarn"
cache-dependency-path: ${{ steps.yarn-lock-location.outputs.yarn-lock-location }}
- name: Use cached frontend dependencies
id: cache-frontend-dependencies
uses: actions/cache@v4
with:
path: ${{ inputs.working-directory }}/grafana-plugin/node_modules
# yamllint disable rule:line-length
key: ${{ runner.os }}-frontend-node-modules-${{ hashFiles(steps.yarn-lock-location.outputs.yarn-lock-location) }}
# yamllint enable rule:line-length
cache: pnpm
cache-dependency-path: grafana-plugin/pnpm-lock.yaml
- name: Install frontend dependencies
if: steps.cache-frontend-dependencies.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ steps.grafana-plugin-directory.outputs.grafana-plugin-directory }}
run: yarn install --frozen-lockfile --prefer-offline --network-timeout 500000
working-directory: grafana-plugin
run: pnpm install --frozen-lockfile --prefer-offline
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jobs:
uses: actions/cache@v4
with:
path: grafana-plugin/dist
key: ${{ runner.os }}-plugin-frontend-${{ hashFiles('grafana-plugin/src/**/*', 'grafana-plugin/yarn.lock') }}
key: ${{ runner.os }}-plugin-frontend-${{ hashFiles('grafana-plugin/src/**/*', 'grafana-plugin/pnpm.lock') }}

- name: Build plugin frontend
if: steps.cache-plugin-frontend.outputs.cache-hit != 'true'
working-directory: grafana-plugin
run: yarn build:dev
run: pnpm build:dev

# helpful reference for properly caching the playwright binaries/dependencies
# https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/
Expand All @@ -107,7 +107,7 @@ jobs:
- name: Install Playwright deps
shell: bash
working-directory: grafana-plugin
run: yarn playwright install
run: pnpm playwright install

# ---------- Expensive e2e tests steps start -----------
- name: Install Go
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
if: inputs.run-expensive-tests
shell: bash
env:
E2E_TESTS_CMD: "cd ../../grafana-plugin && yarn test:e2e-expensive"
E2E_TESTS_CMD: "cd ../../grafana-plugin && pnpm test:e2e-expensive"
GRAFANA_VERSION: ${{ inputs.grafana_version }}
GF_FEATURE_TOGGLES_ENABLE: "externalServiceAccounts"
ONCALL_API_URL: "http://oncall-dev-engine:8080"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: ./.github/actions/install-frontend-dependencies
- name: Build, lint and test frontend
working-directory: grafana-plugin
run: yarn lint && yarn type-check && yarn test && yarn build
run: pnpm lint && pnpm type-check && pnpm test && pnpm build

test-technical-documentation:
name: "Test technical documentation"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ venv
.DS_Store
.env

yarn.lock
pnpm.lock
node_modules

test-results
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
rev: v8.25.0
hooks:
- id: eslint
entry: bash -c "cd grafana-plugin && eslint --max-warnings=0 --fix ${@/grafana-plugin\//}" --
entry: bash -c "cd grafana-plugin && eslint --max-warnings=20 --fix ${@/grafana-plugin\//}" --
types: [file]
files: ^grafana-plugin/src/(?:(?!autogenerated).)*\.(js|jsx|ts|tsx)$
additional_dependencies:
Expand Down
6 changes: 3 additions & 3 deletions .tilt/plugin/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if is_ci:
"build-ui",
labels=[label],
dir=grafana_plugin_dir,
cmd="yarn build",
cmd="pnpm build",
allow_parallel=True,
)

Expand All @@ -19,9 +19,9 @@ if not is_ci:
"build-ui",
labels=[label],
dir=grafana_plugin_dir,
cmd="yarn install",
cmd="pnpm install",
serve_dir=grafana_plugin_dir,
serve_cmd="yarn watch",
serve_cmd="pnpm watch",
allow_parallel=True,
)

Expand Down
8 changes: 4 additions & 4 deletions .tilt/tests/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ label = "OnCall.AllTests"

load('ext://uibutton', 'cmd_button', 'location', 'text_input', 'bool_input')

e2e_tests_cmd=os.getenv("E2E_TESTS_CMD", "cd ../../grafana-plugin && yarn test:e2e")
e2e_tests_cmd=os.getenv("E2E_TESTS_CMD", "cd ../../grafana-plugin && pnpm test:e2e")
is_ci=config.tilt_subcommand == "ci"

local_resource(
Expand All @@ -16,7 +16,7 @@ local_resource(

cmd_button(
name="E2E Tests - headless run",
argv=["sh", "-c", "yarn --cwd ./grafana-plugin test:e2e $STOP_ON_FIRST_FAILURE $TESTS_FILTER"],
argv=["sh", "-c", "pnpm --dir ./grafana-plugin test:e2e $STOP_ON_FIRST_FAILURE $TESTS_FILTER"],
text="Restart headless run",
resource="e2e-tests",
icon_name="replay",
Expand All @@ -29,15 +29,15 @@ cmd_button(

cmd_button(
name="E2E Tests - open watch mode",
argv=["sh", "-c", "yarn --cwd grafana-plugin test:e2e:watch"],
argv=["sh", "-c", "pnpm --dir grafana-plugin test:e2e:watch"],
text="Open watch mode",
resource="e2e-tests",
icon_name="visibility",
)

cmd_button(
name="E2E Tests - show report",
argv=["sh", "-c", "yarn --cwd grafana-plugin playwright show-report"],
argv=["sh", "-c", "pnpm --dir grafana-plugin playwright show-report"],
text="Show last HTML report",
resource="e2e-tests",
icon_name="assignment",
Expand Down
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends: default

ignore: |
helm/oncall/templates/**/*.yaml
pnpm-lock.yaml
rules:
line-length:
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ init: ## build the frontend plugin code then run make start
# this makes sure that it will be available when the grafana container starts up without the need to
# restart the grafana container initially
ifeq ($(findstring $(UI_PROFILE),$(COMPOSE_PROFILES)),$(UI_PROFILE))
$(call run_ui_docker_command,yarn install && yarn build:dev)
$(call run_ui_docker_command,pnpm install && pnpm build:dev)
endif

stop: # stop all of the docker containers
Expand All @@ -168,7 +168,7 @@ install-pre-commit:
fi

lint: install-pre-commit ## run both frontend and backend linters
## may need to run `yarn install` from within `grafana-plugin`
## may need to run `pnpm install` from within `grafana-plugin`
## to install several `pre-commit` dependencies
pre-commit run --all-files

Expand Down Expand Up @@ -203,25 +203,25 @@ engine-manage: ## run Django's `manage.py` script, inside of a docker container
$(call run_engine_docker_command,python manage.py $(CMD))

test-e2e: ## run the e2e tests in headless mode
yarn --cwd grafana-plugin test:e2e
pnpm --dir grafana-plugin test:e2e

test-e2e-watch: ## start e2e tests in watch mode
yarn --cwd grafana-plugin test:e2e:watch
pnpm --dir grafana-plugin test:e2e:watch

test-e2e-show-report: ## open last e2e test report
yarn --cwd grafana-plugin playwright show-report
pnpm --dir grafana-plugin playwright show-report

ui-test: ## run the UI tests
$(call run_ui_docker_command,yarn test)
$(call run_ui_docker_command,pnpm test)

ui-lint: ## run the UI linter
$(call run_ui_docker_command,yarn lint)
$(call run_ui_docker_command,pnpm lint)

ui-build: ## build the UI
$(call run_ui_docker_command,yarn build)
$(call run_ui_docker_command,pnpm build)

ui-command: ## run any command, inside of a UI docker container, passing `$CMD` as arguments.
## e.g. `make ui-command CMD="yarn test"`
## e.g. `make ui-command CMD="pnpm test"`
$(call run_ui_docker_command,$(CMD))

exec-engine: ## exec into engine container's bash
Expand Down
4 changes: 2 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Related: [How to develop integrations](/engine/config_integrations/README.md)
- [tilt-dev/ctlptl: Making local Kubernetes clusters fun and easy to set up](https://github.com/tilt-dev/ctlptl)
- [Kind](https://kind.sigs.k8s.io)
- [Node.js v20.x](https://nodejs.org/en/download)
- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable)
- [pnpm](https://pnpm.io/installation)

### Launch the environment

Expand Down Expand Up @@ -519,7 +519,7 @@ In order to automate types creation and prevent API usage pitfalls, OnCall proje
### Instruction
1. Whenever API contract changes, run `yarn generate-types` from `grafana-plugin` directory
1. Whenever API contract changes, run `pnpm generate-types` from `grafana-plugin` directory
2. Then you can start consuming types and you can use fully typed http client:
```ts
Expand Down
4 changes: 2 additions & 2 deletions grafana-plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/dist

npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
pnpm-error.log*

# This file is generated
grafana-plugin.yml
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM node:20.15.1-alpine
WORKDIR /etc/app
ENV PATH /etc/app/node_modules/.bin:$PATH

CMD ["yarn", "start"]
CMD ["pnpm", "start"]
28 changes: 14 additions & 14 deletions grafana-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
"stylelint:fix": "stylelint --fix ./src/**/*.{css,scss,module.css,module.scss}",
"build": "NODE_ENV=production webpack -c ./webpack.config.ts --env production",
"build:dev": "NODE_ENV=development webpack -c ./webpack.config.ts --env development",
"labels:link": "yarn --cwd ../../gops-labels/frontend link && yarn link \"@grafana/labels\" && yarn --cwd ../../gops-labels/frontend watch",
"labels:unlink": "yarn --cwd ../../gops-labels/frontend unlink",
"labels:link": "pnpm --dir ../../gops-labels/frontend link && pnpm link \"@grafana/labels\" && pnpm --dir ../../gops-labels/frontend watch",
"labels:unlink": "pnpm --dir ../../gops-labels/frontend unlink",
"mage:build-dev": "go mod download && mage -v build:debug",
"mage:watch": "go mod download && mage -v watch",
"test-utc": "TZ=UTC jest --verbose --testNamePattern '^((?!@london-tz).)*$'",
"test-london-tz": "TZ=Europe/London jest --verbose --testNamePattern '@london-tz'",
"test": "PLUGIN_ID=grafana-oncall-app yarn test-utc && yarn test-london-tz",
"test": "PLUGIN_ID=grafana-oncall-app pnpm test-utc && pnpm test-london-tz",
"test:ci": "PLUGIN_ID=grafana-oncall-app pnpm test-utc && pnpm test-london-tz",
"test:report": "HTML_REPORT_ENABLED=true yarn test",
"test:silent": "yarn test --silent",
"test:e2e": "PLUGIN_ID=grafana-oncall-app yarn playwright test --grep-invert @expensive",
"test:e2e-expensive": "PLUGIN_ID=grafana-oncall-app yarn playwright test --grep @expensive",
"test:e2e:watch": "yarn test:e2e --ui",
"test:e2e-expensive:watch": "yarn test:e2e-expensive --ui",
"test:e2e:gen": "yarn playwright codegen http://localhost:3000",
"e2e-show-report": "yarn playwright show-report --port 31000",
"generate-types": "cd ./src/network/oncall-api/types-generator && yarn generate",
"test:report": "HTML_REPORT_ENABLED=true pnpm test",
"test:silent": "pnpm test --silent",
"test:e2e": "PLUGIN_ID=grafana-oncall-app pnpm playwright test --grep-invert @expensive",
"test:e2e-expensive": "PLUGIN_ID=grafana-oncall-app pnpm playwright test --grep @expensive",
"test:e2e:watch": "pnpm test:e2e --ui",
"test:e2e-expensive:watch": "pnpm test:e2e-expensive --ui",
"test:e2e:gen": "pnpm playwright codegen http://localhost:3000",
"e2e-show-report": "pnpm playwright show-report --port 31000",
"generate-types": "cd ./src/network/oncall-api/types-generator && pnpm generate",
"watch": "NODE_ENV=development webpack -w -c ./webpack.config.ts --env development",
"sign": "npx --yes @grafana/sign-plugin@latest",
"start": "yarn watch",
"start": "pnpm watch",
"setversion": "setversion",
"type-check": "tsc --noEmit",
"type-check:watch": "yarn type-check --watch --preserveWatchOutput false",
"type-check:watch": "pnpm type-check --watch --preserveWatchOutput false",
"find-dead-code": "knip"
},
"repository": {
Expand Down
Loading

0 comments on commit 9bbd2c4

Please sign in to comment.