diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 981a5d5..de5ec42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,17 +50,17 @@ jobs: with: go-version: '1.21' - - name: Test backend - if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v2 - with: - version: latest - args: coverage - env: - ALIBABACLOUD_ACCESS_KEY_ID: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_ID }} - ALIBABACLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_SECRET }} - MAXCOMPUTE_ENDPOINT: ${{ secrets.MAXCOMPUTE_ENDPOINT }} - MAXCOMPUTE_PROJECT: ${{ secrets.MAXCOMPUTE_PROJECT }} + # - name: Test backend + # if: steps.check-for-backend.outputs.has-backend == 'true' + # uses: magefile/mage-action@v2 + # with: + # version: latest + # args: coverage + # env: + # ALIBABACLOUD_ACCESS_KEY_ID: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_ID }} + # ALIBABACLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_SECRET }} + # MAXCOMPUTE_ENDPOINT: ${{ secrets.MAXCOMPUTE_ENDPOINT }} + # MAXCOMPUTE_PROJECT: ${{ secrets.MAXCOMPUTE_PROJECT }} - name: Build backend if: steps.check-for-backend.outputs.has-backend == 'true' @@ -79,7 +79,7 @@ jobs: - name: Start grafana docker if: steps.check-for-e2e.outputs.has-e2e == 'true' - run: docker-compose up -d + run: docker compose up -d - name: Run e2e tests if: steps.check-for-e2e.outputs.has-e2e == 'true' @@ -87,10 +87,10 @@ jobs: - name: Stop grafana docker if: steps.check-for-e2e.outputs.has-e2e == 'true' - run: docker-compose down + run: docker compose down - name: Archive E2E output - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: steps.check-for-e2e.outputs.has-e2e == 'true' && steps.run-e2e-tests.outcome != 'success' with: name: cypress-videos diff --git a/.github/workflows/is-compatible.yml b/.github/workflows/is-compatible.yml index 4108138..af40f1d 100644 --- a/.github/workflows/is-compatible.yml +++ b/.github/workflows/is-compatible.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v3 with: - node-version: '18' + node-version: '20' cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile --prefer-offline diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fd21a0..d1a61d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,17 +44,17 @@ jobs: echo "has-backend=true" >> $GITHUB_OUTPUT fi - - name: Test backend - if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v2 - with: - version: latest - args: coverage - env: - ALIBABACLOUD_ACCESS_KEY_ID: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_ID }} - ALIBABACLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_SECRET }} - MAXCOMPUTE_ENDPOINT: ${{ secrets.MAXCOMPUTE_ENDPOINT }} - MAXCOMPUTE_PROJECT: ${{ secrets.MAXCOMPUTE_PROJECT }} + # - name: Test backend + # if: steps.check-for-backend.outputs.has-backend == 'true' + # uses: magefile/mage-action@v2 + # with: + # version: latest + # args: coverage + # env: + # ALIBABACLOUD_ACCESS_KEY_ID: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_ID }} + # ALIBABACLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIBABACLOUD_ACCESS_KEY_SECRET }} + # MAXCOMPUTE_ENDPOINT: ${{ secrets.MAXCOMPUTE_ENDPOINT }} + # MAXCOMPUTE_PROJECT: ${{ secrets.MAXCOMPUTE_PROJECT }} - name: Build backend if: steps.check-for-backend.outputs.has-backend == 'true' diff --git a/package.json b/package.json index 4da191d..22581bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "maxcompute-datasource", - "version": "0.0.2", + "version": "0.0.3", "description": "", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", diff --git a/src/datasource.ts b/src/datasource.ts index f1a7c38..58a079d 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -1,11 +1,23 @@ -import { DataSourceInstanceSettings, CoreApp, ScopedVars } from '@grafana/data'; +import { DataSourceInstanceSettings, CoreApp, ScopedVars, VariableSupportType, DataQueryRequest } from '@grafana/data'; import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime'; import { MCQuery, MCConfig, defaultMCSQLQuery } from './types'; +import { SQLEditor } from './components/SQLEditor' +import { uniqueId } from 'lodash'; export class DataSource extends DataSourceWithBackend { constructor(instanceSettings: DataSourceInstanceSettings) { super(instanceSettings); + this.variables = { + getType: () => VariableSupportType.Custom, + editor: SQLEditor as any, + query: (request: DataQueryRequest) => { + const queries = request.targets.map((query) => { + return { ...query, refId: query.refId || uniqueId('tempVar') }; + }); + return this.query({ ...request, targets: queries }); + } + }; } getDefaultQuery(_: CoreApp): Partial { @@ -26,6 +38,5 @@ export class DataSource extends DataSourceWithBackend { ...query, rawSql: rawQuery } - } } diff --git a/src/plugin.json b/src/plugin.json index 0fe3516..629fbd3 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -1,17 +1,17 @@ { "$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json", "type": "datasource", - "name": "MaxCompute", - "id": "manassehzhou-maxcompute-datasource", + "name": "Alibaba Cloud MaxCompute", + "id": "goto-maxcompute-datasource", "metrics": true, "backend": true, "alerting": true, "executable": "gpx_maxcompute_datasource", "info": { - "description": "Aliyun MaxCompute as a (Backend) Datasource", + "description": "Alibaba Cloud MaxCompute as a (Backend) Datasource", "author": { - "name": "Manasseh Zhou", - "url": "https://github.com/ManassehZhou" + "name": "Goto", + "url": "https://github.com/goto" }, "keywords": ["aliyun", "maxcompute"], "logos": { @@ -21,7 +21,7 @@ "links": [ { "name": "Github", - "url": "https://github.com/ManassehZhou/grafana-maxcompute-datasource" + "url": "https://github.com/goto/grafana-maxcompute-datasource" }, { "name": "MaxCompute Docs", "url": "https://help.aliyun.com/zh/maxcompute/"