Skip to content

Commit

Permalink
switched over to pnpm (#97)
Browse files Browse the repository at this point in the history
* switched over to pnpm
* fix workflows
* fix codeclimate dependency
* add default cypress setup
* add sha1sum
* update docs
  • Loading branch information
briangann authored Oct 20, 2023
1 parent 6b896c4 commit 55e4aed
Show file tree
Hide file tree
Showing 15 changed files with 11,939 additions and 17,180 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# pnpm action uses the packageManager field in package.json to
# understand which version to install.
- uses: pnpm/action-setup@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: yarn
cache-dependency-path: yarn.lock

cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile --prefer-offline

- name: Check types
run: yarn typecheck

run: pnpm run typecheck
- name: Lint
run: NODE_OPTIONS=--max_old_space_size=4096 yarn lint

run: pnpm run lint
- name: Unit tests
run: yarn test:ci

run: pnpm run test:ci
- name: Build frontend
run: yarn build
run: pnpm run build

- name: Check for backend
id: check-for-backend
Expand Down Expand Up @@ -80,7 +77,7 @@ jobs:
- name: Run e2e tests
id: run-e2e-tests
if: steps.check-for-e2e.outputs.has-e2e == 'true'
run: yarn e2e
run: pnpm run e2e

- name: Stop grafana docker
if: steps.check-for-e2e.outputs.has-e2e == 'true'
Expand All @@ -94,10 +91,6 @@ jobs:
path: cypress/videos
retention-days: 5

- name: E2E - Stop grafana docker
if: steps.check-for-e2e.outputs.has-e2e-frontend-tests == 'true'
run: docker-compose down

- name: Code Climate - Check environment
id: check-for-codeclimate
env:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/is-compatible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# pnpm action uses the packageManager field in package.json to
# understand which version to install.
- uses: pnpm/action-setup@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: yarn
cache-dependency-path: yarn.lock
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build plugin
run: yarn run build
run: pnpm run build
- name: Compatibility check
run: npx @grafana/levitate@latest is-compatible --path src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ jobs:
release:
runs-on: ubuntu-latest
env:
# usage of GRAFANA_API_KEY is deprecated
# GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
GRAFANA_ACCESS_POLICY_TOKEN: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
steps:
- uses: actions/checkout@v3
# pnpm action uses the packageManager field in package.json to
# understand which version to install.
- uses: pnpm/action-setup@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
check-latest: true
cache-dependency-path: yarn.lock
node-version: '18'
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile --prefer-offline

- name: Build and test frontend
run: yarn build
run: pnpm run build

- name: Check for backend
id: check-for-backend
Expand All @@ -55,12 +59,12 @@ jobs:

- name: Warn missing Grafana access policy token
run: |
echo Please generate a Grafana API key: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-an-api-key
echo Please generate a Grafana access policy token: https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
if: ${{ env.GRAFANA_ACCESS_POLICY_TOKEN == '' }}

- name: Sign plugin
run: yarn run sign
run: pnpm run sign
if: ${{ env.GRAFANA_ACCESS_POLICY_TOKEN != '' }}

- name: Get plugin metadata
Expand All @@ -73,12 +77,14 @@ jobs:
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
export GRAFANA_PLUGIN_ARTIFACT_SHA1SUM=${GRAFANA_PLUGIN_ARTIFACT}.sha1
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
echo "archive-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
Expand All @@ -89,23 +95,15 @@ jobs:
echo "path=release_notes.md" >> $GITHUB_OUTPUT
- name: Check package version
run: |
printf "Checking package version versus github tag";
printf "metadata version: v${{ steps.metadata.outputs.plugin-version }}";
printf "github-tag version: ${{ steps.metadata.outputs.github-tag }}";
if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then
printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n";
printf "metadata version: v${{ steps.metadata.outputs.plugin-version }}";
printf "github-tag version: ${{ steps.metadata.outputs.github-tag }}";
exit 1;
fi
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi

- name: Package plugin
id: package-plugin
run: |
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
sha1sum ${{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > ${{ steps.metadata.outputs.archive-sha1sum }}
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Validate plugin
Expand All @@ -124,6 +122,7 @@ jobs:
files: |
./${{ steps.metadata.outputs.archive }}
./${{ steps.metadata.outputs.archive-checksum }}
./${{ steps.metadata.outputs.archive-sha1sum }}
body: |
**This Github draft release has been created for your plugin.**
Expand All @@ -138,5 +137,6 @@ jobs:
- Fill in the Plugin Submission form:
- Paste this [.zip asset link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}) in the Plugin URL field
- Paste this [.zip.md5 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-checksum }}) in the MD5 field
- Paste this [.zip.sha1 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-sha1sum }}) in the SHA1 field
Once done please remove these instructions and publish this release.
36 changes: 33 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
.DS_Store
dist
node_modules
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

node_modules/

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Compiled binary addons (https://nodejs.org/api/addons.html)
dist/
artifacts/
work/
ci/
e2e-results/
**/cypress/videos
**/cypress/report.json

# Editor
.idea

.eslintcache
.yarn/install-state.gz
14 changes: 14 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is required for PNPM

# PNPM 8 changed the default resolution mode to "lowest-direct" which is not how we expect resolutions to work
resolution-mode="highest"

# Make sure the default patterns are still included (https://pnpm.io/npmrc#public-hoist-pattern)
public-hoist-pattern[]="*eslint*"
public-hoist-pattern[]="*prettier*"

# Hoist all types packages to the root for better TS support
public-hoist-pattern[]="@types/*"

# @grafana/e2e expects cypress to exist in the root of the node_modules directory
public-hoist-pattern[]="*cypress*"
Loading

0 comments on commit 55e4aed

Please sign in to comment.