Skip to content

HIQ-1374 Update Grafana to version 12.3.0 #1

HIQ-1374 Update Grafana to version 12.3.0

HIQ-1374 Update Grafana to version 12.3.0 #1

name: Integration Tests
on:
push:
branches:
- main
- release-*.*.*
pull_request:
types:
- opened
- synchronize
- reopened
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
permissions: {}
jobs:
detect-changes:
# Run on `grafana/grafana` main branch, or on pull requests to prevent double-running on mirrors
if: (github.event_name == 'pull_request' || (github.event_name == 'push' && github.repository == 'grafana/grafana'))
name: Detect whether code changed
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
changed: ${{ steps.detect-changes.outputs.backend }}
steps:
- uses: actions/checkout@v5
with:
persist-credentials: true # required to get more history in the changed-files action
fetch-depth: 2
- name: Detect changes
id: detect-changes
uses: ./.github/actions/change-detection
with:
self: .github/workflows/pr-test-integration.yml
sqlite:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
strategy:
matrix:
# We don't need more than this since it has to wait for the other tests.
shard: [
1/4, 2/4, 3/4, 4/4,
]
fail-fast: false
name: Sqlite (${{ matrix.shard }})
runs-on: ubuntu-x64-large-io
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: go.mod
cache: true
- name: Run tests
env:
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
readarray -t PACKAGES <<< "$(./scripts/ci/backend-tests/pkgs-with-tests-named.sh -b TestIntegration | ./scripts/ci/backend-tests/shard.sh -N"$SHARD" -d-)"
go test -tags=sqlite -timeout=8m -run '^TestIntegration' "${PACKAGES[@]}"
sqlite_nocgo:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
strategy:
matrix:
# We don't need more than this since it has to wait for the other tests.
shard: [
1/4, 2/4, 3/4, 4/4,
]
fail-fast: false
name: Sqlite Without CGo (${{ matrix.shard }})
runs-on: ubuntu-x64-large-io
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: go.mod
cache: true
- name: Run tests
env:
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
readarray -t PACKAGES <<< "$(./scripts/ci/backend-tests/pkgs-with-tests-named.sh -b TestIntegration | ./scripts/ci/backend-tests/shard.sh -N"$SHARD" -d-)"
# ionice since tests are IO intensive
CGO_ENABLED=0 ionice -c2 -n7 go test -p=4 -tags=sqlite -timeout=8m -run '^TestIntegration' "${PACKAGES[@]}"
mysql:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
strategy:
matrix:
shard: [
1/16, 2/16, 3/16, 4/16,
5/16, 6/16, 7/16, 8/16,
9/16, 10/16, 11/16, 12/16,
13/16, 14/16, 15/16, 16/16,
]
fail-fast: false
name: MySQL (${{ matrix.shard }})
runs-on: ubuntu-x64-large-io
permissions:
contents: read
env:
GRAFANA_TEST_DB: mysql
MYSQL_HOST: 127.0.0.1
services:
mysql:
image: mysql:8.0.43
env:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: grafana_tests
MYSQL_USER: grafana
MYSQL_PASSWORD: password
options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- 3306:3306
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: go.mod
cache: true
- name: Setup MySQL devenv
run: mysql -h 127.0.0.1 -P 3306 -u root -prootpass < devenv/docker/blocks/mysql_tests/setup.sql
- name: Run tests
env:
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
readarray -t PACKAGES <<< "$(./scripts/ci/backend-tests/pkgs-with-tests-named.sh -b TestIntegration | ./scripts/ci/backend-tests/shard.sh -N"$SHARD" -d-)"
CGO_ENABLED=0 go test -p=1 -tags=mysql -timeout=8m -run '^TestIntegration' "${PACKAGES[@]}"
postgres:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
strategy:
matrix:
shard: [
1/16, 2/16, 3/16, 4/16,
5/16, 6/16, 7/16, 8/16,
9/16, 10/16, 11/16, 12/16,
13/16, 14/16, 15/16, 16/16,
]
fail-fast: false
name: Postgres (${{ matrix.shard }})
runs-on: ubuntu-x64-large-io
permissions:
contents: read
env:
GRAFANA_TEST_DB: postgres
PGPASSWORD: grafanatest
POSTGRES_HOST: 127.0.0.1
services:
postgres:
image: postgres:17.6
env:
POSTGRES_USER: grafanatest
POSTGRES_PASSWORD: grafanatest
POSTGRES_DB: grafanatest
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: go.mod
cache: true
- name: Setup Postgres devenv
run: psql -p 5432 -h 127.0.0.1 -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql
- name: Run tests
env:
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
readarray -t PACKAGES <<< "$(./scripts/ci/backend-tests/pkgs-with-tests-named.sh -b TestIntegration | ./scripts/ci/backend-tests/shard.sh -N"$SHARD" -d-)"
CGO_ENABLED=0 go test -p=1 -tags=postgres -timeout=8m -run '^TestIntegration' "${PACKAGES[@]}"
# This is the job that is actually required by rulesets.
# We want to only require one job instead of all the individual tests and shards.
# Future work also allows us to start skipping some tests based on changed files.
required-backend-integration-tests:
needs:
- mysql
- postgres
- sqlite
# always() is the best function here.
# success() || failure() will skip this function if any need is also skipped.
# That means conditional test suites will fail the entire requirement check.
if: always()
name: All backend integration tests complete
runs-on: ubuntu-latest
steps:
- name: Check test suites
env:
NEEDS: ${{ toJson(needs) }}
run: |
FAILURES="$(echo "$NEEDS" | jq 'with_entries(select(.value.result == "failure")) | map_values(.result)')"
echo "$FAILURES"
if [ "$(echo "$FAILURES" | jq '. | length')" != "0" ]; then
exit 1
fi
echo "All OK!"