mirror of https://github.com/grafana/grafana
commit
50de82d636
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@ |
||||
name: 'Setup Grafana Enterprise' |
||||
description: 'Clones and sets up Grafana Enterprise repository for testing' |
||||
|
||||
inputs: |
||||
github-app-name: |
||||
description: 'Name of the GitHub App in Vault' |
||||
required: false |
||||
default: 'grafana-ci-bot' |
||||
|
||||
runs: |
||||
using: "composite" |
||||
steps: |
||||
- name: Retrieve GitHub App secrets |
||||
id: get-secrets |
||||
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets-v1.0.1 |
||||
with: |
||||
repo_secrets: | |
||||
APP_ID=${{ inputs.github-app-name }}:app-id |
||||
APP_INSTALLATION_ID=${{ inputs.github-app-name }}:app-installation-id |
||||
PRIVATE_KEY=${{ inputs.github-app-name }}:private-key |
||||
|
||||
- name: Generate GitHub App token |
||||
id: generate_token |
||||
uses: actions/create-github-app-token@v1 |
||||
with: |
||||
app-id: ${{ env.APP_ID }} |
||||
private-key: ${{ env.PRIVATE_KEY }} |
||||
repositories: "grafana-enterprise" |
||||
owner: "grafana" |
||||
|
||||
- name: Setup Enterprise |
||||
shell: bash |
||||
env: |
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }} |
||||
run: | |
||||
git clone https://x-access-token:${GH_TOKEN}@github.com/grafana/grafana-enterprise.git ../grafana-enterprise; |
||||
|
||||
cd ../grafana-enterprise |
||||
|
||||
if git checkout ${GITHUB_HEAD_REF}; then |
||||
echo "checked out ${GITHUB_HEAD_REF}" |
||||
elif git checkout ${GITHUB_BASE_REF}; then |
||||
echo "checked out ${GITHUB_BASE_REF}" |
||||
else |
||||
git checkout main |
||||
fi |
||||
|
||||
./build.sh |
@ -0,0 +1,69 @@ |
||||
name: Coverage |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
push: |
||||
branches: |
||||
- main |
||||
paths-ignore: |
||||
- 'docs/**' |
||||
- '**/*.md' |
||||
|
||||
permissions: |
||||
contents: read |
||||
id-token: write |
||||
|
||||
env: |
||||
EDITION: 'oss' |
||||
WIRE_TAGS: 'oss' |
||||
|
||||
jobs: |
||||
main: |
||||
name: Backend Unit Tests |
||||
runs-on: ubuntu-latest-8-cores |
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
- name: Setup Go |
||||
uses: actions/setup-go@v5 |
||||
with: |
||||
go-version-file: go.mod |
||||
cache: true |
||||
- name: Install dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y build-essential shared-mime-info |
||||
go install github.com/mfridman/tparse@c1754a1f484ac5cd422697b0fec635177ddc8507 # v0.17.0 |
||||
- name: Generate Go code |
||||
run: make gen-go |
||||
- name: Run unit tests |
||||
run: COVER_OPTS="-coverprofile=be-unit.cov -coverpkg=github.com/grafana/grafana/..." GO_TEST_OUTPUT="/tmp/unit.log" make test-go-unit-cov |
||||
- name: Process and upload coverage |
||||
uses: ./.github/actions/test-coverage-processor |
||||
with: |
||||
test-type: 'be-unit' |
||||
# Needs to be named 'unit.cov' based on the Makefile command `make test-go-unit` |
||||
coverage-file: 'unit.cov' |
||||
codecov-token: ${{ secrets.CODECOV_TOKEN }} |
||||
codecov-flag: 'be-unit' |
||||
codecov-name: 'be-unit' |
||||
|
||||
- name: Install Grafana Bench |
||||
# We can't allow forks here, as we need secret access. |
||||
if: ${{ github.event_name != 'pull_request' }} |
||||
uses: ./.github/actions/setup-grafana-bench |
||||
|
||||
- name: Process output for Bench |
||||
if: ${{ github.event_name != 'pull_request' }} |
||||
run: | |
||||
grafana-bench report \ |
||||
--trigger pr-backend-unit-tests-oss \ |
||||
--report-input go \ |
||||
--report-output log \ |
||||
--grafana-version "$(git rev-parse HEAD)" \ |
||||
--suite-name grafana-oss-unit-tests \ |
||||
/tmp/unit.log |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: false |
@ -1,78 +1,104 @@ |
||||
name: Backend Unit Tests |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
push: |
||||
branches: |
||||
- main |
||||
paths-ignore: |
||||
- 'docs/**' |
||||
- '**/*.md' |
||||
pull_request: |
||||
paths-ignore: |
||||
- 'docs/**' |
||||
- '**/*.md' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
permissions: |
||||
contents: read |
||||
id-token: write |
||||
|
||||
env: |
||||
EDITION: 'oss' |
||||
WIRE_TAGS: 'oss' |
||||
|
||||
jobs: |
||||
backend-testing-coverage: |
||||
name: Backend Testing & Coverage |
||||
runs-on: ubuntu-latest |
||||
grafana: |
||||
# Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`, |
||||
# the `pr-backend-unit-tests-enterprise` workflow will run instead |
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true |
||||
name: Grafana |
||||
runs-on: ubuntu-latest-8-cores |
||||
continue-on-error: true |
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Setup Go |
||||
uses: actions/setup-go@v5 |
||||
with: |
||||
go-version-file: go.mod |
||||
cache: true |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y build-essential shared-mime-info |
||||
go install github.com/mfridman/tparse@c1754a1f484ac5cd422697b0fec635177ddc8507 # v0.17.0 |
||||
|
||||
- name: Restore GOCACHE |
||||
uses: actions/cache/restore@v4 |
||||
with: |
||||
key: go-test-cache-${{ github.ref_name }} |
||||
restore-keys: | |
||||
go-test-cache-${{ github.base_ref }} |
||||
go-test-cache-main |
||||
path: /home/runner/.cache/go-build |
||||
- name: Generate Go code |
||||
run: make gen-go |
||||
|
||||
- name: Run unit tests |
||||
run: COVER_OPTS="-coverprofile=be-unit.cov -coverpkg=github.com/grafana/grafana/..." GO_TEST_OUTPUT="/tmp/unit.log" make test-go-unit |
||||
|
||||
- name: Process and upload coverage |
||||
uses: ./.github/actions/test-coverage-processor |
||||
run: make test-go-unit |
||||
- name: "Generate token" |
||||
id: generate_token |
||||
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 |
||||
with: |
||||
test-type: 'be-unit' |
||||
# Needs to be named 'unit.cov' based on the Makefile command `make test-go-unit` |
||||
coverage-file: 'unit.cov' |
||||
codecov-token: ${{ secrets.CODECOV_TOKEN }} |
||||
codecov-flag: 'be-unit' |
||||
codecov-name: 'be-unit' |
||||
|
||||
- name: Install Grafana Bench |
||||
# We can't allow forks here, as we need secret access. |
||||
if: ${{ github.event_name != 'pull_request' }} |
||||
uses: ./.github/actions/setup-grafana-bench |
||||
|
||||
- name: Process output for Bench |
||||
if: ${{ github.event_name != 'pull_request' }} |
||||
run: | |
||||
grafana-bench report \ |
||||
--trigger pr-backend-unit-tests-oss \ |
||||
--report-input go \ |
||||
--report-output log \ |
||||
--grafana-version "$(git rev-parse HEAD)" \ |
||||
--suite-name grafana-oss-unit-tests \ |
||||
/tmp/unit.log |
||||
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }} |
||||
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }} |
||||
- name: Clear GOCACHE |
||||
run: gh cache delete go-test-cache-${{ github.ref_name }} |
||||
continue-on-error: true |
||||
env: |
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }} |
||||
- name: Save GOCACHE |
||||
uses: actions/cache/save@v4 |
||||
with: |
||||
key: go-test-cache-${{ github.ref_name }} |
||||
path: /home/runner/.cache/go-build |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
grafana-enterprise: |
||||
# Run this workflow for non-PR events (like pushes to `main` or `release-*`) OR for internal PRs (PRs not from forks) |
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false |
||||
name: Grafana Enterprise |
||||
runs-on: ubuntu-latest-8-cores |
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
- name: Setup Go |
||||
uses: actions/setup-go@v5 |
||||
with: |
||||
go-version-file: go.mod |
||||
- name: Restore GOCACHE |
||||
uses: actions/cache/restore@v4 |
||||
with: |
||||
key: go-test-cache-${{ github.ref_name }}-enterprise |
||||
restore-keys: | |
||||
go-test-cache-${{ github.base_ref }}-enterprise |
||||
go-test-cache-main-enterprise |
||||
path: /home/runner/.cache/go-build |
||||
- name: Setup Enterprise |
||||
uses: ./.github/actions/setup-enterprise |
||||
with: |
||||
github-app-name: 'grafana-ci-bot' |
||||
- name: Generate Go code |
||||
run: make gen-go |
||||
- name: Run unit tests |
||||
run: make test-go-unit |
||||
- name: "Generate token" |
||||
id: generate_token |
||||
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 |
||||
with: |
||||
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }} |
||||
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }} |
||||
- name: Clear GOCACHE |
||||
run: gh cache delete go-test-cache-${{ github.ref_name }}-enterprise |
||||
continue-on-error: true |
||||
env: |
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }} |
||||
- name: Save GOCACHE |
||||
uses: actions/cache/save@v4 |
||||
with: |
||||
key: go-test-cache-${{ github.ref_name }}-enterprise |
||||
path: /home/runner/.cache/go-build |
||||
|
@ -0,0 +1,40 @@ |
||||
name: Verify Storybook |
||||
|
||||
on: |
||||
pull_request: |
||||
paths: |
||||
- 'packages/grafana-ui/**' |
||||
- '.github/workflows/storybook-verification.yml' |
||||
- '!docs/**' |
||||
- '!*.md' |
||||
|
||||
jobs: |
||||
verify-storybook: |
||||
name: Verify Storybook |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Setup Node.js |
||||
uses: actions/setup-node@v4 |
||||
with: |
||||
node-version-file: 'package.json' |
||||
cache: 'yarn' |
||||
|
||||
- name: Install dependencies |
||||
run: yarn install --immutable |
||||
|
||||
- name: Run Storybook and E2E tests |
||||
uses: cypress-io/github-action@v6 |
||||
with: |
||||
browser: chrome |
||||
start: yarn storybook --quiet |
||||
wait-on: 'http://localhost:9001' |
||||
wait-on-timeout: 60 |
||||
command: yarn e2e:storybook |
||||
install: false |
||||
env: |
||||
HOST: localhost |
||||
PORT: 9001 |
@ -0,0 +1,105 @@ |
||||
/** |
||||
* This file is used to share internal grafana/ui code with Grafana core. |
||||
* Note that these exports are also used within Enterprise. |
||||
* |
||||
* Through the exports declared in package.json we can import this code in core Grafana and the grafana/ui |
||||
* package will continue to be able to access all code when it's published to npm as it's private to the package. |
||||
* |
||||
* During the yarn pack lifecycle the exports[./internal] property is deleted from the package.json |
||||
* preventing the code from being importable by plugins or other npm packages making it truly "internal". |
||||
* |
||||
*/ |
||||
|
||||
export { UPlotChart } from '../components/uPlot/Plot'; |
||||
export { type AxisProps, UPLOT_AXIS_FONT_SIZE, timeUnitSize } from '../components/uPlot/config/UPlotAxisBuilder'; |
||||
export { |
||||
type Renderers, |
||||
UPlotConfigBuilder, |
||||
type UPlotConfigPrepFn, |
||||
} from '../components/uPlot/config/UPlotConfigBuilder'; |
||||
export { type ScaleProps } from '../components/uPlot/config/UPlotScaleBuilder'; |
||||
export { |
||||
pluginLog, |
||||
preparePlotData2, |
||||
getStackingGroups, |
||||
getDisplayValuesForCalcs, |
||||
type StackingGroup, |
||||
} from '../components/uPlot/utils'; |
||||
export { hasVisibleLegendSeries, PlotLegend } from '../components/uPlot/PlotLegend'; |
||||
export { getScaleGradientFn } from '../components/uPlot/config/gradientFills'; |
||||
export { buildScaleKey } from '../components/uPlot/internal'; |
||||
export { CloseButton } from '../components/uPlot/plugins/CloseButton'; |
||||
export { type TimeRange2, TooltipHoverMode } from '../components/uPlot/plugins/TooltipPlugin2'; |
||||
export type { FacetedData, FacetSeries } from '../components/uPlot/types'; |
||||
|
||||
export { getResponsiveStyle, type ResponsiveProp } from '../components/Layout/utils/responsiveness'; |
||||
export { ColorSwatch } from '../components/ColorPicker/ColorSwatch'; |
||||
|
||||
export { FieldNamePicker } from '../components/MatchersUI/FieldNamePicker'; |
||||
export { comparisonOperationOptions } from '../components/MatchersUI/FieldValueMatcher'; |
||||
export { |
||||
frameHasName, |
||||
getFrameFieldsDisplayNames, |
||||
useFieldDisplayNames, |
||||
useSelectOptions, |
||||
} from '../components/MatchersUI/utils'; |
||||
export type { FieldMatcherUIRegistryItem } from '../components/MatchersUI/types'; |
||||
export { RefIDMultiPicker, RefIDPicker, stringsToRegexp } from '../components/MatchersUI/FieldsByFrameRefIdMatcher'; |
||||
export { allFieldTypeIconOptions } from '../components/MatchersUI/FieldTypeMatcherEditor'; |
||||
|
||||
export { getStyles as getSliderStyles } from '../components/Slider/styles'; |
||||
export { getSelectStyles } from '../components/Select/getSelectStyles'; |
||||
export type { Props as InputProps } from '../components/Input/Input'; |
||||
export type { ModalsContextState } from '../components/Modal/ModalsContext'; |
||||
export { getModalStyles } from '../components/Modal/getModalStyles'; |
||||
export { MultiValueRemove, type MultiValueRemoveProps } from '../components/Select/MultiValue'; |
||||
export { getSvgSize } from '../components/Icon/utils'; |
||||
export { LoadingIndicator } from '../components/PanelChrome/LoadingIndicator'; |
||||
export { type ButtonLinkProps, getButtonStyles } from '../components/Button'; |
||||
export { |
||||
type TableSortByFieldState, |
||||
type TableFieldOptions, |
||||
TableCellDisplayMode, |
||||
FILTER_FOR_OPERATOR, |
||||
FILTER_OUT_OPERATOR, |
||||
} from '../components/Table/types'; |
||||
export { defaultSparklineCellConfig } from '../components/Table/Cells/SparklineCell'; |
||||
export { TableCell } from '../components/Table/Cells/TableCell'; |
||||
export { useTableStyles } from '../components/Table/TableRT/styles'; |
||||
export { Trans } from '../utils/i18n'; |
||||
export { migrateTableDisplayModeToCellOptions } from '../components/Table/utils'; |
||||
export { type DataLinksContextMenuApi } from '../components/DataLinks/DataLinksContextMenu'; |
||||
export { MenuDivider } from '../components/Menu/MenuDivider'; |
||||
export { AbstractList } from '../components/List/AbstractList'; |
||||
export type { HttpSettingsBaseProps, AzureAuthSettings } from '../components/DataSourceSettings/types'; |
||||
export { TimeZoneOffset, formatUtcOffset } from '../components/DateTimePickers/TimeZonePicker/TimeZoneOffset'; |
||||
export { TimeZoneTitle } from '../components/DateTimePickers/TimeZonePicker/TimeZoneTitle'; |
||||
export type { CodeEditorProps } from '../components/Monaco/types'; |
||||
export { type Props as InlineFieldProps } from '../components/Forms/InlineField'; |
||||
export { DataLinkSuggestions } from '../components/DataLinks/DataLinkSuggestions'; |
||||
export { type Props as AlertProps } from '../components/Alert/Alert'; |
||||
export { type TooltipPlacement } from '../components/Tooltip'; |
||||
export { ConfirmContent, type ConfirmContentProps } from '../components/ConfirmModal/ConfirmContent'; |
||||
|
||||
export { EmotionPerfTest } from '../components/ThemeDemos/EmotionPerfTest'; |
||||
|
||||
export { VizTooltipContent } from '../components/VizTooltip/VizTooltipContent'; |
||||
export { VizTooltipFooter } from '../components/VizTooltip/VizTooltipFooter'; |
||||
export { VizTooltipHeader } from '../components/VizTooltip/VizTooltipHeader'; |
||||
export { VizTooltipWrapper } from '../components/VizTooltip/VizTooltipWrapper'; |
||||
export { VizTooltipRow } from '../components/VizTooltip/VizTooltipRow'; |
||||
export { getContentItems } from '../components/VizTooltip/utils'; |
||||
export { ColorIndicator, ColorPlacement, type VizTooltipItem } from '../components/VizTooltip/types'; |
||||
export { mapMouseEventToMode } from '../components/VizLegend/utils'; |
||||
|
||||
export { getFocusStyles, getMouseFocusStyles, getTooltipContainerStyles } from '../themes/mixins'; |
||||
|
||||
export { optsWithHideZeros } from '../options/builder/tooltip'; |
||||
export { StackingEditor } from '../options/builder/stacking'; |
||||
export { addHideFrom } from '../options/builder/hideSeries'; |
||||
export { ScaleDistributionEditor } from '../options/builder/axis'; |
||||
|
||||
export { useComponentInstanceId } from '../utils/useComponetInstanceId'; |
||||
export { closePopover } from '../utils/closePopover'; |
||||
|
||||
export { flattenTokens } from '../slate-plugins/slate-prism'; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@ |
||||
package converter |
||||
|
||||
import ( |
||||
"os" |
||||
"testing" |
||||
|
||||
jsoniter "github.com/json-iterator/go" |
||||
) |
||||
|
||||
// readTestData reads a JSON file from testdata directory
|
||||
func readTestData(t *testing.B, filename string) []byte { |
||||
// Can ignore gosec G304 here, because this is a constant defined below benchmark test
|
||||
// nolint:gosec
|
||||
data, err := os.ReadFile("testdata/" + filename) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
return data |
||||
} |
||||
|
||||
// BenchmarkReadPrometheusStyleResult_FromFile benchmarks processing different test files
|
||||
// go test -benchmem -run=^$ -bench=BenchmarkReadPrometheusStyleResult_FromFile$ github.com/grafana/grafana/pkg/promlib/converter/ -memprofile pmem.out -count 6 | tee pmem.0.txt
|
||||
func BenchmarkReadPrometheusStyleResult_FromFile(b *testing.B) { |
||||
testFiles := []string{ |
||||
"prom-query-range.json", |
||||
"prom-query-range-big.json", |
||||
"prom-matrix-histogram-partitioned.json", |
||||
} |
||||
|
||||
opt := Options{Dataplane: true} |
||||
|
||||
for _, tf := range testFiles { |
||||
testData := readTestData(b, tf) |
||||
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, testData) |
||||
|
||||
b.Run(tf, func(b *testing.B) { |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_ = ReadPrometheusStyleResult(iter, opt) |
||||
iter.ResetBytes(testData) |
||||
} |
||||
}) |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue