Skip to content

Commit

Permalink
react updates (#199)
Browse files Browse the repository at this point in the history
* detect go version from file
* bump pnpm version
* update to latest create-plugin
  • Loading branch information
briangann authored Jun 13, 2024
1 parent 52f4178 commit 79452f7
Show file tree
Hide file tree
Showing 11 changed files with 6,025 additions and 4,828 deletions.
2 changes: 1 addition & 1 deletion .config/.cprc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.2.3"
"version": "4.10.3"
}
38 changes: 37 additions & 1 deletion .config/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ ARG grafana_image=grafana-enterprise

FROM grafana/${grafana_image}:${grafana_version}

ARG development=true


ENV DEV "${development}"

# Make it as simple as possible to access the grafana instance for development purposes
# Do NOT enable these settings in a public facing / production grafana instance
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
Expand All @@ -11,6 +16,37 @@ ENV GF_AUTH_BASIC_ENABLED "false"
# Set development mode so plugins can be loaded without the need to sign
ENV GF_DEFAULT_APP_MODE "development"

# Inject livereload script into grafana index.html

LABEL maintainer="Grafana Labs <[email protected]>"

ENV GF_PATHS_HOME="/usr/share/grafana"
WORKDIR $GF_PATHS_HOME

USER root

# Installing supervisor and inotify-tools
RUN if [ "${development}" = "true" ]; then \
if grep -i -q alpine /etc/issue; then \
apk add supervisor inotify-tools git; \
elif grep -i -q ubuntu /etc/issue; then \
DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y supervisor inotify-tools git && \
rm -rf /var/lib/apt/lists/*; \
else \
echo 'ERROR: Unsupported base image' && /bin/false; \
fi \
fi

COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf



# Inject livereload script into grafana index.html
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html


COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
18 changes: 18 additions & 0 deletions .config/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

if [ "${DEV}" = "false" ]; then
echo "Starting test mode"
exec /run.sh
fi

echo "Starting development mode"

if grep -i -q alpine /etc/issue; then
exec /usr/bin/supervisord -c /etc/supervisord.conf
elif grep -i -q ubuntu /etc/issue; then
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
else
echo 'ERROR: Unsupported base image'
exit 1
fi

3 changes: 3 additions & 0 deletions .config/jest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

import '@testing-library/jest-dom';
import { TextEncoder, TextDecoder } from 'util';

Object.assign(global, { TextDecoder, TextEncoder });

// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Object.defineProperty(global, 'matchMedia', {
Expand Down
15 changes: 15 additions & 0 deletions .config/supervisord/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[supervisord]
nodaemon=true
user=root

[program:grafana]
user=root
directory=/var/lib/grafana
command=/run.sh
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
killasgroup=true
stopasgroup=true
autostart=true

2 changes: 2 additions & 0 deletions .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import LiveReloadPlugin from 'webpack-livereload-plugin';
import path from 'path';
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
import { Configuration } from 'webpack';
import { GrafanaPluginMetaExtractor } from '@grafana/plugin-meta-extractor';

import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils';
import { SOURCE_DIR, DIST_DIR } from './constants';
Expand Down Expand Up @@ -140,6 +141,7 @@ const config = async (env): Promise<Configuration> => {
},

plugins: [
new GrafanaPluginMetaExtractor(),
new CopyWebpackPlugin({
patterns: [
// If src/README.md exists use it; otherwise the root README
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ jobs:
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: go.mod
check-latest: true

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

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

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

Expand All @@ -43,6 +38,13 @@ jobs:
echo "has-backend=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go environment
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v4
Expand Down
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
"test:ci": "jest --passWithNoTests --maxWorkers 4",
"typecheck": "tsc --noEmit",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
"lint:fix": "pnpm run lint -- --fix",
"lint:fix": "pnpm run lint --fix",
"server": "docker-compose up --build",
"sign": "npx --yes @grafana/sign-plugin@latest",
"spellcheck": "cspell -c cspell.config.json \"**/*.{ts,tsx,js,go,md,mdx,yml,yaml,json,scss,css}\""
"spellcheck": "cspell -c cspell.config.json \"**/*.{ts,tsx,js,go,md,mdx,yml,yaml,json,scss,css}\"",
"e2e": "playwright test"
},
"repository": {
"type": "git",
Expand All @@ -34,7 +35,7 @@
"devDependencies": {
"@babel/core": "^7.23.2",
"@grafana/eslint-config": "^7.0.0",
"@grafana/plugin-e2e": "^0.25.1",
"@grafana/plugin-e2e": "1.2.0",
"@grafana/tsconfig": "^1.3.0-rc1",
"@playwright/test": "^1.42.1",
"@swc/core": "^1.3.90",
Expand Down Expand Up @@ -72,17 +73,18 @@
"typescript": "4.8.4",
"webpack": "^5.86.0",
"webpack-cli": "^5.1.4",
"webpack-livereload-plugin": "^3.0.2"
"webpack-livereload-plugin": "^3.0.2",
"@grafana/plugin-meta-extractor": "^0.0.2"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"@emotion/css": "11.10.6",
"@grafana/data": "10.3.3",
"@grafana/runtime": "10.3.3",
"@grafana/schema": "10.4.1",
"@grafana/ui": "10.3.3",
"@grafana/data": "10.3.5",
"@grafana/runtime": "10.3.5",
"@grafana/schema": "10.4.2",
"@grafana/ui": "10.3.5",
"@types/jquery": "^3.5.29",
"datatables.net": "^1.13.11",
"jquery": "^3.7.1",
Expand All @@ -94,5 +96,5 @@
"volta": {
"node": "20.11.1"
},
"packageManager": "pnpm@8.15.5"
"packageManager": "pnpm@9.1.1"
}
Loading

0 comments on commit 79452f7

Please sign in to comment.