From 138703d83fd59e61c9e1bd624ce0c3d5b9761d37 Mon Sep 17 00:00:00 2001 From: Andrii Chubatiuk Date: Mon, 16 Dec 2024 18:20:40 +0200 Subject: [PATCH] makefile cleanup --- .github/workflows/docs.yaml | 12 +- ...hecks-golang.yml => pr-checks-backend.yml} | 43 +++--- .github/workflows/pr-checks-frontend.yml | 42 ++++++ .github/workflows/pr-checks-typescript.yml | 67 --------- .../workflows/pr-codeql-analize-golang.yml | 90 ------------ .github/workflows/pr-codeql-backend.yml | 54 +++++++ ...-typescript.yml => pr-codeql-frontend.yml} | 19 +-- .github/workflows/release.yaml | 71 +++++----- .gitignore | 1 + CHANGELOG.md | 2 + Makefile | 133 +++++++----------- README.md | 6 +- compose.yaml | 13 ++ deployment/docker/Makefile | 45 +++--- docker-compose.yaml | 50 ------- package.json | 14 +- pkg/Makefile | 23 --- 17 files changed, 261 insertions(+), 424 deletions(-) rename .github/workflows/{pr-checks-golang.yml => pr-checks-backend.yml} (68%) create mode 100644 .github/workflows/pr-checks-frontend.yml delete mode 100644 .github/workflows/pr-checks-typescript.yml delete mode 100644 .github/workflows/pr-codeql-analize-golang.yml create mode 100644 .github/workflows/pr-codeql-backend.yml rename .github/workflows/{pr-codeql-analysis-typescript.yml => pr-codeql-frontend.yml} (58%) create mode 100644 compose.yaml delete mode 100644 docker-compose.yaml delete mode 100644 pkg/Makefile diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 67dee29..476fa2e 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -1,13 +1,13 @@ -name: Update docs +name: update docs on: push: branches: - main paths: - - ".github/workflows/docs.yaml" - - "README.md" - - "docs/**" + - .github/workflows/docs.yaml + - README.md + - docs/** jobs: update-docs: @@ -22,7 +22,7 @@ jobs: repository: VictoriaMetrics/victorialogs-datasource ref: main token: ${{ secrets.VM_BOT_GH_TOKEN }} - path: "__vm-datasource-repo" + path: "__vl-datasource-repo" - name: Check out VM code uses: actions/checkout@v4 @@ -63,7 +63,7 @@ jobs: sed -i 's|docs/assets/||g' ../__vm-docs-repo/docs/VictoriaLogs/victorialogs-datasource.md cp docs/assets/* ../__vm-docs-repo/docs/VictoriaLogs/ - working-directory: "__vm-datasource-repo" + working-directory: "__vl-datasource-repo" - name: Commit and push changes run: | diff --git a/.github/workflows/pr-checks-golang.yml b/.github/workflows/pr-checks-backend.yml similarity index 68% rename from .github/workflows/pr-checks-golang.yml rename to .github/workflows/pr-checks-backend.yml index 1e9fc8f..3d7fe64 100644 --- a/.github/workflows/pr-checks-golang.yml +++ b/.github/workflows/pr-checks-backend.yml @@ -1,17 +1,22 @@ -name: main +name: check / backend on: push: branches: - main - paths-ignore: - - "src/**" - - "**.md" + paths: + - .github/workflows/pr-checks-backend.yml + - go.* + - vendor/** + - pkg/** pull_request: branches: - main - paths-ignore: - - "src/**" - - "**.md" + paths: + - .github/workflows/pr-checks-backend.yml + - go.* + - vendor/** + - pkg/** + permissions: contents: read @@ -25,10 +30,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Code checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.21.6 check-latest: true @@ -48,10 +53,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Code checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.21.6 check-latest: true @@ -59,7 +64,7 @@ jobs: - name: run tests run: | - make ${{ matrix.scenario}} + make ${{ matrix.scenario }} build: needs: test @@ -67,21 +72,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Code checkout - uses: actions/checkout@v3 - - - name: Setup Go - id: go - uses: actions/setup-go@v3 - with: - go-version: 1.21.6 - check-latest: true - cache: true + uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: gocache-for-docker key: gocache-docker-${{ runner.os }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod') }} - name: Build run: | - make victorialogs-backend-plugin-build + make vl-backend-plugin-build diff --git a/.github/workflows/pr-checks-frontend.yml b/.github/workflows/pr-checks-frontend.yml new file mode 100644 index 0000000..d9512fc --- /dev/null +++ b/.github/workflows/pr-checks-frontend.yml @@ -0,0 +1,42 @@ +name: check / frontend + +on: + push: + branches: [main] + paths: + - '.github/workflow/pr-checks-frontend.yml' + - '**/*.ts' + - '**/*.tsx' + - '**/yarn.lock' + - '**/package.json' + pull_request: + branches: [main] + paths: + - '.github/workflow/pr-checks-frontend.yml' + - '**/*.ts' + - '**/*.tsx' + - '**/yarn.lock' + - '**/package.json' + +jobs: + run-check: + name: check + runs-on: ubuntu-latest + strategy: + matrix: + scenario: ["make vl-frontend-plugin-build", "yarn test"] + steps: + - name: Code checkout + uses: actions/checkout@v4 + + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20.9.0 + + - name: Install all dependencies + run: yarn install + + - name: Run + run: | + ${{ matrix.scenario }} diff --git a/.github/workflows/pr-checks-typescript.yml b/.github/workflows/pr-checks-typescript.yml deleted file mode 100644 index a98793b..0000000 --- a/.github/workflows/pr-checks-typescript.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Name of this action -name: check frontend - -# Event triggers on pull request event -# For more detail visit https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on -on: - push: - branches: [ main ] - paths: - - '**/*.ts' - - '**/*.tsx' - pull_request: - branches: [main] - paths: - - '**/*.ts' - - '**/*.tsx' - -# The jobs this action will run. You can write as many jobs as you want. -# For more detail on this section visit https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobs -jobs: - # ID of the job - run-jest-tests: - # Name of the job as it will be displayed in GitHub - name: Jest Tests - # Machine which this action will be run on. For a list of all the machines available/how to run on self hosted machine visit - # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - runs-on: ubuntu-latest - - # Steps this job must take to complete - steps: - # Reference the main branch. For more information visit https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses - - name: Checkout under $GITHUB_WORKSPACE - uses: actions/checkout@main - - # Specify which version of Node this project is using. For more information visit. - # https://docs.github.com/en/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version - - name: Set up node - uses: actions/setup-node@v1 - with: - node-version: 20.9.0 - - - name: Install all dependencies - run: yarn install - - - name: Run Jest Tests - run: npm run test - - run-build: - needs: run-jest-tests - name: build - runs-on: ubuntu-latest - steps: - - name: Code checkout - uses: actions/checkout@v3 - - - name: Set up node - uses: actions/setup-node@v1 - with: - node-version: 20.9.0 - - - name: Install all dependencies - run: yarn install - - - name: Build - shell: 'script -q -e -c "bash {0}"' - run: | - make victorialogs-frontend-plugin-build diff --git a/.github/workflows/pr-codeql-analize-golang.yml b/.github/workflows/pr-codeql-analize-golang.yml deleted file mode 100644 index 51a1142..0000000 --- a/.github/workflows/pr-codeql-analize-golang.yml +++ /dev/null @@ -1,90 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL for PR / golang" - -on: - push: - branches: [main] - paths-ignore: - - "src/**" - - "**.md" - - "**.txt" - - "**.js" - pull_request: - # The branches below must be a subset of the branches above - branches: [main] - paths-ignore: - - "src/**" - - "**.md" - - "**.txt" - - "**.js" - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ["go"] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.21.6 - check-latest: true - cache: true - if: ${{ matrix.language == 'go' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/pr-codeql-backend.yml b/.github/workflows/pr-codeql-backend.yml new file mode 100644 index 0000000..de7b7c2 --- /dev/null +++ b/.github/workflows/pr-codeql-backend.yml @@ -0,0 +1,54 @@ +name: codeql / backend + +on: + push: + branches: [main] + paths: + - .github/workflows/pr-checks-backend.yml + - go.* + - vendor/** + - pkg/** + pull_request: + # The branches below must be a subset of the branches above + branches: [main] + paths: + - .github/workflows/pr-checks-backend.yml + - go.* + - vendor/** + - pkg/** + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.6 + check-latest: true + cache: true + if: ${{ matrix.language == 'go' }} + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: go + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/pr-codeql-analysis-typescript.yml b/.github/workflows/pr-codeql-frontend.yml similarity index 58% rename from .github/workflows/pr-codeql-analysis-typescript.yml rename to .github/workflows/pr-codeql-frontend.yml index 2bd07b6..efc1a2b 100644 --- a/.github/workflows/pr-codeql-analysis-typescript.yml +++ b/.github/workflows/pr-codeql-frontend.yml @@ -1,20 +1,26 @@ -name: "CodeQL for PR / javascript" +name: codeql / frontend on: push: - branches: [ main ] + branches: [main] paths: + - '.github/workflow/pr-codeql-frontend.yml' - '**/*.ts' - '**/*.tsx' - '!**/*.test.ts' - '!**/*.test.tsx' + - '**/yarn.lock' + - '**/package.json' pull_request: branches: [main] paths: + - '.github/workflow/pr-codeql-frontend.yml' - '**/*.ts' - '**/*.tsx' - '!**/*.test.ts' - '!**/*.test.tsx' + - '**/yarn.lock' + - '**/package.json' jobs: analyze: @@ -23,17 +29,14 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. fetch-depth: 2 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: "javascript" - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ae314f5..d5b203a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,47 +1,42 @@ -name: Release +name: release on: - release: - types: - - created + push: + tags: + - 'v*' env: - NAME: victorialogs-datasource - TAG: ${{ github.event.release.tag_name }} + PKG_TAG: ${{ github.ref_name }} jobs: release: name: Release on GitHub - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + pages: write steps: - name: Check out code - uses: actions/checkout@v2 - - name: Build Project - run: | - yarn install - npm run build - - name: Build ZIP - run: | - cp -r ./dist ./${{ env.NAME }} && zip ${{ env.NAME }}-${{ env.TAG }}.zip ${{ env.NAME }} -r && rm -rf ${{ env.NAME }} - sha1sum ./${{ env.NAME }}-${{ env.TAG }}.zip >${{ env.NAME }}-${{ env.TAG }}.zip.sha1 - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/checkout@v4 + - name: Setup golang caches with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./${{ env.NAME }}-${{ env.TAG }}.zip - asset_name: ${{ env.NAME }}-${{ env.TAG }}.zip - asset_content_type: application/zip - - name: Upload Release SHA - id: upload-release-sha - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + path: | + ${{ github.workspace }}/gocache-for-docker + key: ${{ runner.os }}-golang-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-golang- + - name: Setup node caches + uses: actions/cache@v4 with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./${{ env.NAME }}-${{ env.TAG }}.zip.sha1 - asset_name: ${{ env.NAME }}-${{ env.TAG }}.zip.sha1 - asset_content_type: application/zip - - name: Update version package.json - uses: pocket-apps/action-update-version@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + path: | + ${{ github.workspace }}/.cache + key: ${{ runner.os }}-yarn-${{ hashFiles('package.json') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Build plugin + run: | + yq -iP '.version="${{ env.PKG_TAG }}"' package.json -o json + make vl-plugin-release + - name: Upload release assets + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create ${{ env.PKG_TAG }} ./dist/* diff --git a/.gitignore b/.gitignore index 6054f64..45a5897 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ e2e-results/ # Editor .idea +.npm .eslintcache # Docker diff --git a/CHANGELOG.md b/CHANGELOG.md index cf55fec..dd55144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## tip +## v0.12.0 + * FEATURE: add compatibility for Grafana `v10.x.x` to ensure `/select/logs/hits` displays precise logs volume on the Explore page. See [this comment](https://github.com/VictoriaMetrics/victorialogs-datasource/pull/146#issuecomment-2533419498). * BUGFIX: properly parse timestamps with milliseconds precision in datasource response. See [this issue](https://github.com/VictoriaMetrics/victorialogs-datasource/issues/147). diff --git a/Makefile b/Makefile index 906393f..c2b3c4d 100644 --- a/Makefile +++ b/Makefile @@ -9,104 +9,79 @@ ifeq ($(PKG_TAG),) PKG_TAG := $(BUILDINFO_TAG) endif -GO_BUILDINFO = -X 'github.com/grafana/grafana-plugin-sdk-go/build.buildInfoJSON={\"time\":${DATEINFO_TAG},\"id\":\"victorialogs-datasource\",\"version\":\"${BUILDINFO_TAG}\",\"branch\":\"${PKG_TAG}\"}' +PLUGIN_ID=victorialogs-datasource +APP_NAME=victorialogs_backend_plugin + +GO_BUILDINFO = -X 'github.com/grafana/grafana-plugin-sdk-go/build.buildInfoJSON={\"time\":${DATEINFO_TAG},\"id\":\"${PLUGIN_ID}\",\"version\":\"${BUILDINFO_TAG}\",\"branch\":\"${PKG_TAG}\"}' .PHONY: $(MAKECMDGOALS) -include pkg/Makefile include deployment/*/Makefile -app-local-goos-goarch: - CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(RACE) -ldflags "$(GO_BUILDINFO)" -o victorialogs-datasource/$(APP_NAME)_$(GOOS)_$(GOARCH)$(RACE) pkg/ - -app-via-docker-goos-goarch: - APP_SUFFIX='_$(GOOS)_$(GOARCH)' \ - DOCKER_OPTS='--env CGO_ENABLED=$(CGO_ENABLED) --env GOOS=$(GOOS) --env GOARCH=$(GOARCH)' \ - $(MAKE) app-via-docker - -app-via-docker-windows-goarch: - APP_SUFFIX='_$(GOOS)_$(GOARCH)' \ - DOCKER_OPTS='--env CGO_ENABLED=$(CGO_ENABLED) --env GOOS=$(GOOS) --env GOARCH=$(GOARCH)' \ - $(MAKE) app-via-docker-windows - app-via-docker-linux-amd64: - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 $(MAKE) app-via-docker-goos-goarch + CGO_ENABLED=1 GOOS=linux GOARCH=amd64 $(MAKE) app-via-docker app-via-docker-linux-arm: - CGO_ENABLED=0 GOOS=linux GOARCH=arm $(MAKE) app-via-docker-goos-goarch + CGO_ENABLED=0 GOOS=linux GOARCH=arm $(MAKE) app-via-docker app-via-docker-linux-386: - CGO_ENABLED=0 GOOS=linux GOARCH=386 $(MAKE) app-via-docker-goos-goarch + CGO_ENABLED=0 GOOS=linux GOARCH=386 $(MAKE) app-via-docker app-via-docker-linux-arm64: -ifeq ($(APP_NAME),vmagent) - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(MAKE) app-via-docker-goos-goarch -else - APP_SUFFIX='_linux_arm64' \ - DOCKER_OPTS='--env CGO_ENABLED=1 --env GOOS=linux --env GOARCH=arm64 --env CC=/opt/cross-builder/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc' \ - $(MAKE) app-via-docker -endif + DOCKER_OPTS='--env CC=/opt/cross-builder/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc' CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(MAKE) app-via-docker app-via-docker-darwin-amd64: - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(MAKE) app-via-docker-goos-goarch + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(MAKE) app-via-docker app-via-docker-darwin-arm64: - CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(MAKE) app-via-docker-goos-goarch + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(MAKE) app-via-docker + +app-via-docker-windows-arm64: + CGO_ENABLED=0 GOOS=windows GOARCH=arm64 $(MAKE) app-via-docker app-via-docker-windows-amd64: - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(MAKE) app-via-docker-windows-goarch - -victorialogs-backend-plugin-build: \ - victorialogs-backend-plugin-amd64-prod \ - victorialogs-backend-plugin-linux-amd64-prod \ - victorialogs-backend-plugin-linux-arm-prod \ - victorialogs-backend-plugin-linux-arm64-prod \ - victorialogs-backend-plugin-linux-386-prod \ - victorialogs-backend-plugin-arm64-prod \ - victorialogs-backend-plugin-windows-prod - -victorialogs-frontend-plugin-build: \ - frontend-build - -victorialogs-datasource-plugin-build: \ - victorialogs-frontend-plugin-build \ - victorialogs-backend-plugin-build - -victorialogs-datasource-plugin-pack-tar: - cd plugins && \ - tar -czf ../victorialogs-datasource-$(PKG_TAG).tar.gz ./victorialogs-datasource \ - && sha256sum ../victorialogs-datasource-$(PKG_TAG).tar.gz \ - > ../victorialogs-datasource-$(PKG_TAG)_checksums_tar.txt && cd .. - -victorialogs-datasource-plugin-pack-zip: - cd plugins && \ - zip -r ../victorialogs-datasource-$(PKG_TAG).zip ./victorialogs-datasource \ - && sha256sum ../victorialogs-datasource-$(PKG_TAG).zip \ - > ../victorialogs-datasource-$(PKG_TAG)_checksums_zip.txt && cd .. - -victorialogs-datasource-frontend-plugin-pack: \ - frontend-pack - -victorialogs-datasource-frontend-plugin-release: \ - victorialogs-frontend-plugin-build \ - victorialogs-datasource-plugin-pack-tar \ - victorialogs-datasource-plugin-pack-zip - -victorialogs-datasource-plugin-release: \ - victorialogs-frontend-plugin-build \ - victorialogs-backend-plugin-build \ - victorialogs-datasource-plugin-pack-tar \ - victorialogs-datasource-plugin-pack-zip \ - victorialogs-datasource-plugin-remove - -victorialogs-datasource-plugin-remove: - rm -rf ./plugins + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(MAKE) app-via-docker + +app-via-docker-local: + $(eval OS := $(shell docker run $(GO_BUILDER_IMAGE) go env GOOS)) + $(eval ARCH := $(shell docker run $(GO_BUILDER_IMAGE) go env GOARCH)) + $(MAKE) app-via-docker-$(OS)-$(ARCH) + +vl-backend-plugin-build: \ + app-via-docker-linux-amd64 \ + app-via-docker-linux-arm \ + app-via-docker-linux-arm64 \ + app-via-docker-linux-386 \ + app-via-docker-darwin-amd64 \ + app-via-docker-darwin-arm64 \ + app-via-docker-windows-amd64 \ + app-via-docker-windows-arm64 + +vl-frontend-plugin-build: frontend-build + +vl-plugin-build-local: vl-frontend-plugin-build app-via-docker-local + +vl-plugin-build: vl-frontend-plugin-build vl-backend-plugin-build + +vl-plugin-pack: vl-plugin-build + mkdir -p dist && \ + $(eval PACKAGE_NAME := $(PLUGIN_ID)-$(PKG_TAG)) \ + cd plugins/ && \ + tar -czf ../dist/$(PACKAGE_NAME).tar.gz ./$(PLUGIN_ID) && \ + zip -q -r ../dist/$(PACKAGE_NAME).zip ./$(PLUGIN_ID) && \ + cd - && \ + sha256sum dist/$(PACKAGE_NAME).zip > dist/$(PACKAGE_NAME)_checksums_zip.txt && \ + sha256sum dist/$(PACKAGE_NAME).tar.gz > dist/$(PACKAGE_NAME)_checksums_tar.gz.txt + +vl-plugin-cleanup: + rm -rf ./victorialogs-datasource plugins + +vl-plugin-release: \ + vl-plugin-pack \ + vl-plugin-cleanup build-release: - git checkout $(TAG) && $(MAKE) victorialogs-datasource-plugin-release - -frontend-build-release: - git checkout $(TAG) && $(MAKE) victorialogs-datasource-frontend-plugin-release + git checkout $(TAG) && $(MAKE) vl-plugin-release golang-test: go test ./pkg/... @@ -118,7 +93,7 @@ golang-ci-lint: install-golang-ci-lint golangci-lint run ./pkg/... install-golang-ci-lint: - which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.60.3 + which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.62.2 fmt: gofmt -l -w -s ./pkg diff --git a/README.md b/README.md index 4a2329a..8971e6f 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Please find the example of provisioning Grafana instance with VictoriaLogs datas grafana: image: grafana/grafana:11.0.0 environment: - - GF_INSTALL_PLUGINS=https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.11.1/victorialogs-datasource-v0.11.1.zip;victorialogs-datasource + - GF_INSTALL_PLUGINS=https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.12.0/victorialogs-datasource-v0.12.0.zip;victorialogs-datasource - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=victorialogs-datasource ports: - 3000:3000/tcp @@ -95,7 +95,7 @@ Option 1. Using Grafana provisioning: ``` yaml env: - GF_INSTALL_PLUGINS: "https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.11.1/victorialogs-datasource-v0.11.1.zip;victorialogs-datasource" + GF_INSTALL_PLUGINS: "https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.12.0/victorialogs-datasource-v0.12.0.zip;victorialogs-datasource" GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: "victorialogs-datasource" ``` @@ -103,7 +103,7 @@ Option 2. Using Grafana plugins section in `values.yaml`: ``` yaml plugins: - - https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.11.1/victorialogs-datasource-v0.11.1.zip;victorialogs-datasource + - https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/v0.12.0/victorialogs-datasource-v0.12.0.zip;victorialogs-datasource ``` Option 3. Using init container: diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..41d888c --- /dev/null +++ b/compose.yaml @@ -0,0 +1,13 @@ +services: + grafana: + image: grafana/grafana:11.3.1 + ports: + - 3000:3000/tcp + environment: + GF_AUTH_ANONYMOUS_ORG_ROLE: Admin + GF_AUTH_ANONYMOUS_ENABLED: "true" + GF_AUTH_BASIC_ENABLED: "false" + GF_DEFAULT_APP_MODE: development + volumes: + - ./plugins/victorialogs-datasource:/var/lib/grafana/plugins/victorialogs-datasource + - ./provisioning:/etc/grafana/provisioning diff --git a/deployment/docker/Makefile b/deployment/docker/Makefile index e9d1f65..b1f3550 100644 --- a/deployment/docker/Makefile +++ b/deployment/docker/Makefile @@ -35,43 +35,30 @@ app-via-docker: package-builder -v "$(shell pwd):/usr/local/go/src/victorialogs-datasource" \ -w /usr/local/go/src/victorialogs-datasource \ -v "$(shell pwd)/gocache-for-docker:/gocache" \ + --user $(shell id -u):$(shell id -g) \ --env GOCACHE=/gocache \ + --env GOOS=$(GOOS) \ + --env GOARCH=$(GOARCH) \ $(DOCKER_OPTS) \ $(BUILDER_IMAGE) \ go build $(RACE) -trimpath -buildvcs=false \ -ldflags "-extldflags '-static' $(GO_BUILDINFO)" \ -tags 'netgo osusergo nethttpomithttp2 musl' \ - -o ./plugins/victorialogs-datasource/$(APP_NAME)$(APP_SUFFIX) ./pkg/ - -app-via-docker-windows: package-builder - mkdir -p gocache-for-docker - docker run --rm \ - -v "$(shell pwd):/usr/local/go/src/victorialogs-datasource" \ - -w /usr/local/go/src/victorialogs-datasource \ - -v "$(shell pwd)/gocache-for-docker:/gocache" \ - --env GOCACHE=/gocache \ - $(DOCKER_OPTS) \ - $(BUILDER_IMAGE) \ - go build $(RACE) -trimpath -buildvcs=false \ - -ldflags "-s -w -extldflags '-static' $(GO_BUILDINFO)" \ - -tags 'netgo osusergo nethttpomithttp2' \ - -o ./plugins/victorialogs-datasource/$(APP_NAME)$(APP_SUFFIX).exe ./pkg/ + -o ./plugins/$(PLUGIN_ID)/$(APP_NAME)_$(GOOS)_$(GOARCH)$(if$ (findstring windows,$(GOOS)),.exe,) ./pkg/ frontend-package-base-image: docker build -t frontent-builder-image -f deployment/docker/web/Dockerfile ./deployment/docker/web frontend-build: frontend-package-base-image - docker run --rm -ti \ - -v "$(shell pwd):/victorialogs-datasource" \ - -w /victorialogs-datasource \ - -v "$(shell pwd)/node_modules:/victorialogs-datasource/node_modules" \ - -v "$(shell pwd)/.cache:/victorialogs-datasource/.cache" \ - --entrypoint=/bin/bash \ - frontent-builder-image -c "yarn install --cache-folder /victorialogs-datasource/.cache --omit=dev && yarn run build" - -frontend-pack: frontend-package-base-image - docker run --rm -ti \ - -v "$(shell pwd):/victorialogs-datasource" \ - -w /victorialogs-datasource \ - --entrypoint=/bin/bash \ - frontent-builder-image -c "yarn run zip" + mkdir -p .npm .cache && \ + chown -R $(shell id -u):$(shell id -g) .npm .cache && \ + docker run --rm \ + -v "$(shell pwd):/victorialogs-datasource" \ + -v "$(shell pwd)/.yarn:/.yarn" \ + -v "$(shell pwd)/.npm:/.npm" \ + -v "$(shell pwd)/.cache:/.cache" \ + -w /victorialogs-datasource \ + --user $(shell id -u):$(shell id -g) \ + --env YARN_CACHE_FOLDER="/victorialogs-datasource/.cache" \ + --entrypoint=/bin/bash \ + frontent-builder-image -c "yarn install --omit=dev && yarn build" diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 751fd9d..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,50 +0,0 @@ -version: '3.0' - -services: - backend_builder: - image: golang:1.19 - working_dir: /go/src/victorialogs-datasource - volumes: - - ./:/go/src/victorialogs-datasource - - ./.cache:/go/pkg/mod - - ./.cache:/go-cache - environment: - CGO_ENABLED: "0" - command: | - bash -xec " - GOOS=linux GOARCH=amd64 go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_linux_amd64 ./pkg/ && \ - GOOS=linux GOARCH=arm64 go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_linux_arm64 ./pkg/ && \ - GOOS=linux GOARCH=arm go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_linux_arm ./pkg/ && \ - GOOS=linux GOARCH=386 go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_linux_386 ./pkg/ && \ - GOOS=darwin GOARCH=arm64 go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_darwin_arm64 ./pkg/ && \ - GOOS=darwin GOARCH=amd64 go build -o ./victorialogs-datasource/victorialogs_datasource_plugin_darwin_amd64 ./pkg/ && \ - chmod +x ./victorialogs-datasource/victorialogs_datasource_plugin* - " - - frontend_builder: - image: node:18.13.0 - working_dir: /victorialogs-datasource - volumes: - - ./:/victorialogs-datasource - # for speedup yarn install - - "node_modules:/victorialogs-datasource/node_modules" - command: | - bash -xec " - if [[ "3" == `ls -la ./node_modules/ | wc -l` ]]; then yarn install --omit=dev; fi && \ - yarn run build - " - - grafana: - container_name: 'victorialogs-datasource' - build: - context: ./.config - args: - grafana_version: ${GRAFANA_VERSION:-9.1.2} - ports: - - 3000:3000/tcp - volumes: - - ./victorialogs-datasource:/var/lib/grafana/plugins/grafana-datasource, - - ./provisioning:/etc/grafana/provisioning - -volumes: - node_modules: diff --git a/package.json b/package.json index 1801f41..6860665 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "victorialogs-datasource", - "version": "0.11.1", + "version": "0.12.0", "description": "VictoriaLogs datasource plugin for grafana", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", @@ -11,13 +11,11 @@ "test:coverage": "jest --collectCoverage", "typecheck": "tsc --noEmit", "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .", - "lint:fix": "npm run lint -- --fix", - "e2e": "npm exec cypress install && npm exec grafana-e2e run", - "e2e:update": "npm exec cypress install && npm exec grafana-e2e run --update-screenshots", - "server": "docker-compose up --build", - "sign": "npx --yes @grafana/sign-plugin@latest", - "tar": "tar -czf $npm_package_name-v$npm_package_version.tar.gz $npm_package_name && sha1sum ./$npm_package_name-v$npm_package_version.tar.gz >$npm_package_name-v$npm_package_version.tar.gz.sha1", - "zip": "zip $npm_package_name-v$npm_package_version.zip $npm_package_name -r && sha1sum ./$npm_package_name-v$npm_package_version.zip >$npm_package_name-v$npm_package_version.zip.sha1" + "lint:fix": "yarn lint -- --fix", + "e2e": "yarn cypress install && yarn grafana-e2e run", + "e2e:update": "yarn cypress install && yarn grafana-e2e run --update-screenshots", + "server": "docker compose up", + "sign": "npx --yes @grafana/sign-plugin@latest" }, "author": "VictoriaMetrics", "license": "Apache-2.0", diff --git a/pkg/Makefile b/pkg/Makefile deleted file mode 100644 index 882d393..0000000 --- a/pkg/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -victorialogs-backend-plugin-prod: - APP_NAME=victoriametrics_backend_plugin $(MAKE) app-via-docker - -victorialogs-backend-plugin-linux-amd64-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-linux-amd64 - -victorialogs-backend-plugin-linux-arm-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-linux-arm - -victorialogs-backend-plugin-linux-arm64-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-linux-arm64 - -victorialogs-backend-plugin-linux-386-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-linux-386 - -victorialogs-backend-plugin-amd64-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-darwin-amd64 - -victorialogs-backend-plugin-arm64-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-darwin-arm64 - -victorialogs-backend-plugin-windows-prod: - APP_NAME=victorialogs_backend_plugin $(MAKE) app-via-docker-windows-amd64