From 7b006e804c5b4aa5e894c13241bb034e401b5473 Mon Sep 17 00:00:00 2001 From: Augustin Husson Date: Thu, 30 Jun 2022 12:10:10 +0200 Subject: [PATCH] enable ui module publication (#10876) * enable ui module publication Signed-off-by: Augustin Husson * use main changelog of Prometheus to reflect the changes of the packages Signed-off-by: Augustin Husson * ignore changelog and license in the libs Signed-off-by: Augustin Husson * replace perses references Signed-off-by: Augustin Husson --- .github/workflows/ui_build_and_release.yml | 44 +++++++ Makefile | 6 + RELEASE.md | 6 + scripts/ui_release.sh | 104 +++++++++++++++++ web/ui/.nvmrc | 1 + web/ui/module/codemirror-promql/.gitignore | 3 + web/ui/module/codemirror-promql/CHANGELOG.md | 116 ------------------- web/ui/module/lezer-promql/.gitignore | 3 + web/ui/module/lezer-promql/.npmignore | 6 + 9 files changed, 173 insertions(+), 116 deletions(-) create mode 100644 .github/workflows/ui_build_and_release.yml create mode 100755 scripts/ui_release.sh create mode 100644 web/ui/.nvmrc delete mode 100644 web/ui/module/codemirror-promql/CHANGELOG.md create mode 100644 web/ui/module/lezer-promql/.npmignore diff --git a/.github/workflows/ui_build_and_release.yml b/.github/workflows/ui_build_and_release.yml new file mode 100644 index 0000000000..f3ca674189 --- /dev/null +++ b/.github/workflows/ui_build_and_release.yml @@ -0,0 +1,44 @@ +name: ui_build_and_release +on: + pull_request: + push: + branches: + - main + tags: + - "v0.[0-9]+.[0-9]+*" +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install nodejs + uses: actions/setup-node@v3 + with: + node-version-file: "web/ui/.nvmrc" + - uses: actions/cache@v3.0.4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Check libraries version + ## This step is verifying that the version of each package is matching the tag + if: ${{ github.event_name == 'push' && startsWith(github.ref_name, 'v') }} + run: ./scripts/ui_release.sh --check-package "${{ github.ref_name }}" + - name: build + run: make assets + - name: Copy files before publishing libs + run: ./scripts/ui_release.sh --copy + - name: Publish dry-run libraries + if: ${{ github.event_name == 'pull_request' || github.ref_name == 'main' }} + run: ./scripts/ui_release.sh --publish dry-run + - name: Publish libraries + if: ${{ github.event_name == 'push' && startsWith(github.ref_name, 'v') }} + run: ./scripts/ui_release.sh --publish + env: + # The setup-node action writes an .npmrc file with this env variable + # as the placeholder for the auth token + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/Makefile b/Makefile index 71d3e949e5..c4a9a06cfa 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,12 @@ upgrade-npm-deps: @echo ">> upgrading npm dependencies" ./scripts/npm-deps.sh "latest" +.PHONY: ui-bump-version +ui-bump-version: + version=$$(sed s/2/0/ < VERSION) && ./scripts/ui_release.sh --bump-version "$${version}" + cd web/ui && npm install + git add "./web/ui/package-lock.json" "./**/package.json" + .PHONY: ui-install ui-install: cd $(UI_PATH) && npm install diff --git a/RELEASE.md b/RELEASE.md index 077dabe476..88d85e8ace 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -144,6 +144,12 @@ Entries in the `CHANGELOG.md` are meant to be in this order: * `[ENHANCEMENT]` * `[BUGFIX]` +Then bump the UI module version: + +```bash +make ui-bump-version +``` + ### 2. Draft the new release Tag the new release via the following commands: diff --git a/scripts/ui_release.sh b/scripts/ui_release.sh new file mode 100755 index 0000000000..abc3583861 --- /dev/null +++ b/scripts/ui_release.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +## /!\ This file must be used at the root of the prometheus project +## This script provides utils method to help to release and verify the readiness of each libs under the folder ui/ + +set -e + +current=$(pwd) +root_ui_folder=${current}/web/ui + +cd "${root_ui_folder}" + +files=("../../LICENSE" "../../CHANGELOG.md") +workspaces=$(jq -r '.workspaces[]' < package.json) + +function copy() { + for file in "${files[@]}"; do + for workspace in ${workspaces}; do + if [ -f "${file}" ]; then + cp "${file}" "${workspace}"/"$(basename "${file}")" + fi + done + done +} + +function publish() { + dry_run="${1}" + cmd="npm publish --access public" + if [[ "${dry_run}" == "dry-run" ]]; then + cmd+=" --dry-run" + fi + for workspace in ${workspaces}; do + # package "app" is private so we shouldn't try to publish it. + if [[ "${workspace}" != "react-app" ]]; then + cd "${workspace}" + eval "${cmd}" + cd "${root_ui_folder}" + fi + done + +} + +function checkPackage() { + version=${1} + if [[ "${version}" == v* ]]; then + version="${version:1}" + fi + for workspace in ${workspaces}; do + cd "${workspace}" + package_version=$(npm run env | grep npm_package_version | cut -d= -f2-) + if [ "${version}" != "${package_version}" ]; then + echo "version of ${workspace} is not the correct one" + echo "expected one: ${version}" + echo "current one: ${package_version}" + echo "please use ./ui_release --bump-version ${version}" + exit 1 + fi + cd "${root_ui_folder}" + done +} + +function clean() { + for file in "${files[@]}"; do + for workspace in ${workspaces}; do + f="${workspace}"/"$(basename "${file}")" + if [ -f "${f}" ]; then + rm "${f}" + fi + done + done +} + +function bumpVersion() { + version="${1}" + if [[ "${version}" == v* ]]; then + version="${version:1}" + fi + # increase the version on all packages + npm version "${version}" --workspaces + # upgrade the @prometheus-io/* dependencies on all packages + for workspace in ${workspaces}; do + sed -E -i "" "s|(\"@prometheus-io/.+\": )\".+\"|\1\"\^${version}\"|" "${workspace}"/package.json + done +} + +if [[ "$1" == "--copy" ]]; then + copy +fi + +if [[ $1 == "--publish" ]]; then + publish "${@:2}" +fi + +if [[ $1 == "--check-package" ]]; then + checkPackage "${@:2}" +fi + +if [[ $1 == "--bump-version" ]]; then + bumpVersion "${@:2}" +fi + +if [[ $1 == "--clean" ]]; then + clean +fi diff --git a/web/ui/.nvmrc b/web/ui/.nvmrc new file mode 100644 index 0000000000..6276cf12fb --- /dev/null +++ b/web/ui/.nvmrc @@ -0,0 +1 @@ +v16.14.2 diff --git a/web/ui/module/codemirror-promql/.gitignore b/web/ui/module/codemirror-promql/.gitignore index 3a21141384..81fe29e56d 100644 --- a/web/ui/module/codemirror-promql/.gitignore +++ b/web/ui/module/codemirror-promql/.gitignore @@ -5,3 +5,6 @@ dist/ lib/ /.nyc_output + +LICENSE +CHANGELOG.md diff --git a/web/ui/module/codemirror-promql/CHANGELOG.md b/web/ui/module/codemirror-promql/CHANGELOG.md deleted file mode 100644 index ca9ceb1c12..0000000000 --- a/web/ui/module/codemirror-promql/CHANGELOG.md +++ /dev/null @@ -1,116 +0,0 @@ -0.19.0 / 2021-12-20 -=================== - -* **[Enhancement]**: Add a negative autocompletion boost to some trigonometric functions that can overlap with other more popular PromQL functions. -* **[BugFix]**: Improve checking of whether a `PrometheusConfig` object was passed to `newCompleteStrategy()`. - -0.18.0 / 2021-10-20 -=================== - -* **[Feature]**: Allow overriding the API prefix used to contact a remote Prometheus. -* **[Feature]**: Add linter and autocompletion support for trigonometric functions (like `sin`, `cos`) -* **[BreakingChange]**: The lib is now exposed under the `dist` folder. When importing `codemirror-promql`, it means you -will need to add `dist` in the import. For example `import { newCompleteStrategy } from 'codemirror-promql/cjs/complete';` -becomes `import { newCompleteStrategy } from 'codemirror-promql/dist/cjs/complete';` -* **[BreakingChange]**: lezer-promql has been migrated into codemirror-promql in the `grammar` folder -* **[BreakingChange]**: Support last version of Codemirror.next (v0.19.0). - -0.17.0 / 2021-08-10 -=================== - -* **[Feature]**: Support `present_over_time` -* **[Feature]**: HTTP method used to contact Prometheus is now configurable. - -0.16.0 / 2021-05-20 -=================== - -* **[Feature]**: Support partial PromQL language called `MetricName`. Can be used to autocomplete only the metric - name. (#142) -* **[Feature]**: Autocomplete `NaN` and `Inf` (#141) -* **[Enhancement]**: Fetch series using the HTTP `POST` method (#139) -* **[Enhancement]**: Upgrade lezer-promql that fixed the parsing of metric names starting with `Inf`/`NaN` like infra (#142) -* **[BreakingChange]**: The constant `promQLLanguage` has been changed to be a function. It takes a `LanguageType` as a - parameter (#142) - -0.15.0 / 2021-04-13 -=================== - -* **[Feature]**: Provide a way to inject an initial metric list for the autocompletion (#134) -* **[Enhancement]**: Autocomplete metrics/function/aggregation when the editor is empty (#133) -* **[Enhancement]**: Improve the documentation to reflect what the lib is providing. (#134) -* **[Change]**: Export the essential interface in the root index of the lib. (#132) -* **[Change]**: Downgrade the NodeJS version required (from 14 to 12) (#112) -* **[BreakingChange]**: Support CommonJS module. (#130) - -Note that this requires to change the import path if you are using something not exported by the root index of lib. For -example: `import { labelMatchersToString } from 'codemirror-promql/parser/matcher';` -becomes `import { labelMatchersToString } from 'codemirror-promql/esm/parser/matcher';` -or `import { labelMatchersToString } from 'codemirror-promql/cjs/parser/matcher';` - -0.14.1 / 2021-04-07 -=================== - -* **[Enhancement]**: Provide getter and setter to easily manipulate the different objects exposed by the lib -* **[BugFix]**: fix the autocompletion of the labels after a comma (in a label matcher list or in a grouping label list) - -0.14.0 / 2021-03-26 -=================== - -* **[Feature]**: Through the update of [lezer-promql](https://github.com/promlabs/lezer-promql/releases/tag/0.18.0) - support negative offset -* **[Enhancement]**: Add snippet to ease the usage of the aggregation `topk`, `bottomk` and `count_value` -* **[Enhancement]**: Autocomplete the 2nd hard of subquery time selector - -0.13.0 / 2021-03-22 -=================== -* **[Feature]**: Linter and Autocompletion support 3 new PromQL functions: `clamp` , `last_over_time`, `sgn` -* **[Feature]**: Linter and Autocompletion support the `@` expression. -* **[Enhancement]**: Signature of `CompleteStrategy.promQL` has been updated to support the type `Promise` -* **[BreakingChange]**: Support last version of Codemirror.next (v0.18.0) -* **[BreakingChange]**: Remove the function `enricher` - -0.12.0 / 2021-01-12 -=================== - -* **[Enhancement]**: Improve the parsing of `BinExpr` thanks to the changes provided by lezer-promql (v0.15.0) -* **[BreakingChange]**: Support the new version of codemirror v0.17.x - -0.11.0 / 2020-12-08 -=================== - -* **[Feature]**: Add the completion of the keyword `bool`. (#89) -* **[Feature]**: Add a function `enricher` that can be used to enrich the completion with a custom one. -* **[Feature]**: Add a LRU caching system. (#71) -* **[Feature]**: You can now configure the maximum number of metrics in Prometheus for which metadata is fetched. -* **[Feature]**: Allow the possibility to inject a custom `CompleteStrategy`. (#83) -* **[Feature]**: Provide the Matchers in the PrometheusClient for the method `labelValues` and `series`. (#84) -* **[Feature]**: Add the method `metricName` in the PrometheusClient that supports a prefix of the metric searched. (#84) -* **[Enhancement]**: Caching mechanism and PrometheusClient are splitted. (#71) -* **[Enhancement]**: Optimize the code of the PrometheusClient when no cache is used. -* **[Enhancement]**: General improvement of the code thanks to Codemirror.next v0.14.0 (for the new tree management) and v0.15.0 (for the new tags/highlight management) -* **[Enhancement]**: Improve the code coverage of the parser concerning the parsing of the function / aggregation. -* **[BugFix]**: In certain case, the linter didn't ignore the comments. (#78) -* **[BreakingChange]**: Use an object instead of a map when querying the metrics metadata. -* **[BreakingChange]**: Support last version of Codemirror.next (v0.15.0). -* **[BreakingChange]**: Change the way the completion configuration is structured. - -0.10.2 / 2020-10-18 -=================== - -* **[BugFix]**: Fixed missing autocompletion of binary operators after aggregations - -0.10.1 / 2020-10-16 -=================== - -* **[Enhancement]**: Caching of series label names and values for autocompletion is now optimized to be much faster -* **[BugFix]**: Fixed incorrect linter errors around binary operator arguments not separated from the operator by a space - -0.10.0 / 2020-10-14 -=================== - -* **[Enhancement]**: The Linter is now checking operation many-to-many, one-to-one, many-to-one and one-to-many -* **[Enhancement]**: The autocompletion is now showing the type of the metric if the type is same for every possible definition of the same metric -* **[Enhancement]**: The autocompletion is supporting the completion of the duration -* **[Enhancement]**: Descriptions have been added for the snippet, the binary operator modifier and the aggregation operator modifier -* **[Enhancement]**: Coverage of the code has been increased (a lot). -* **[BreakingChange]**: Removing LSP support diff --git a/web/ui/module/lezer-promql/.gitignore b/web/ui/module/lezer-promql/.gitignore index a7fef1550e..d4f11c6328 100644 --- a/web/ui/module/lezer-promql/.gitignore +++ b/web/ui/module/lezer-promql/.gitignore @@ -3,3 +3,6 @@ dist/ lib/ src/parser.js src/parser.terms.js + +LICENSE +CHANGELOG.md diff --git a/web/ui/module/lezer-promql/.npmignore b/web/ui/module/lezer-promql/.npmignore new file mode 100644 index 0000000000..2d3bc2bdfe --- /dev/null +++ b/web/ui/module/lezer-promql/.npmignore @@ -0,0 +1,6 @@ +build.sh +generate-types.sh +jest.config.cjs +rollup.config.js +/test/ +/src/