169 lines
4.9 KiB
YAML
169 lines
4.9 KiB
YAML
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:
|
|
sqlite:
|
|
strategy:
|
|
matrix:
|
|
shard: [
|
|
1/8, 2/8, 3/8, 4/8,
|
|
5/8, 6/8, 7/8, 8/8,
|
|
]
|
|
fail-fast: false
|
|
|
|
name: Sqlite (${{ matrix.shard }})
|
|
runs-on: ubuntu-latest-8-cores
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
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=5m -run '^TestIntegration' "${PACKAGES[@]}"
|
|
mysql:
|
|
strategy:
|
|
matrix:
|
|
shard: [
|
|
1/8, 2/8, 3/8, 4/8,
|
|
5/8, 6/8, 7/8, 8/8,
|
|
]
|
|
fail-fast: false
|
|
|
|
name: MySQL (${{ matrix.shard }})
|
|
runs-on: ubuntu-latest-8-cores
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
GRAFANA_TEST_DB: mysql
|
|
MYSQL_HOST: 127.0.0.1
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0.32
|
|
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@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
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-)"
|
|
go test -p=1 -tags=mysql -timeout=5m -run '^TestIntegration' "${PACKAGES[@]}"
|
|
postgres:
|
|
strategy:
|
|
matrix:
|
|
shard: [
|
|
1/8, 2/8, 3/8, 4/8,
|
|
5/8, 6/8, 7/8, 8/8,
|
|
]
|
|
fail-fast: false
|
|
|
|
name: Postgres (${{ matrix.shard }})
|
|
runs-on: ubuntu-latest-8-cores
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
GRAFANA_TEST_DB: postgres
|
|
PGPASSWORD: grafanatest
|
|
POSTGRES_HOST: 127.0.0.1
|
|
services:
|
|
postgres:
|
|
image: postgres:12.3-alpine
|
|
env:
|
|
POSTGRES_USER: grafanatest
|
|
POSTGRES_PASSWORD: grafanatest
|
|
POSTGRES_DB: grafanatest
|
|
ports:
|
|
- 5432:5432
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
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-)"
|
|
go test -p=1 -tags=postgres -timeout=5m -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!"
|