diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1b4b6f34d65..878975846db 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -792,6 +792,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/pr-codeql-analysis-python.yml @DanCech /.github/workflows/pr-commands.yml @tolzhabayev /.github/workflows/pr-patch-check.yml @grafana/grafana-developer-enablement-squad +/.github/workflows/pr-test-integration.yml @grafana/grafana-backend-group /.github/workflows/pr-backend-unit-tests.yml @grafana/grafana-backend-group /.github/workflows/pr-backend-coverage.yml @grafana/grafana-backend-group /.github/workflows/sync-mirror.yml @grafana/grafana-developer-enablement-squad diff --git a/.github/workflows/pr-test-integration.yml b/.github/workflows/pr-test-integration.yml new file mode 100644 index 00000000000..f0a5f0a7fa3 --- /dev/null +++ b/.github/workflows/pr-test-integration.yml @@ -0,0 +1,126 @@ +name: Integration Tests + +on: + push: + branches: + - main + - release-*.*.* + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + sqlite: + name: Sqlite + 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: Restore GOCACHE + uses: actions/cache/restore@v4 + with: + key: go-test-cache-${{ github.ref_name }}-sqlite + restore-keys: | + go-test-cache-${{ github.base_ref }}-sqlite + go-test-cache-main-sqlite + path: /home/runner/.cache/go-build + - run: | + make gen-go + go test -tags=sqlite -timeout=5m -run '^TestIntegration' $(find ./pkg -type f -name '*_test.go' -exec grep -l '^func TestIntegration' '{}' '+' | grep -o '\(.*\)/' | sort -u) + - name: Save GOCACHE + uses: actions/cache/save@v4 + with: + key: go-test-cache-${{ github.ref_name }}-sqlite + path: /home/runner/.cache/go-build + mysql: + name: MySQL + runs-on: ubuntu-latest-8-cores + 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 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + - name: Restore GOCACHE + uses: actions/cache/restore@v4 + with: + key: go-test-cache-${{ github.ref_name }}-mysql + restore-keys: | + go-test-cache-${{ github.base_ref }}-mysql + go-test-cache-main-mysql + path: /home/runner/.cache/go-build + - run: | + sudo apt-get update -yq && sudo apt-get install mariadb-client + cat devenv/docker/blocks/mysql_tests/setup.sql | mariadb -h 127.0.0.1 -P 3306 -u root -prootpass --disable-ssl-verify-server-cert + make gen-go + go test -tags=mysql -p=1 -timeout=5m -run '^TestIntegration' $(find ./pkg -type f -name '*_test.go' -exec grep -l '^func TestIntegration' '{}' '+' | grep -o '\(.*\)/' | sort -u) + - name: Save GOCACHE + uses: actions/cache/save@v4 + with: + key: go-test-cache-${{ github.ref_name }}-mysql + path: /home/runner/.cache/go-build + postgres: + name: Postgres + runs-on: ubuntu-latest-8-cores + 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 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + - name: Restore GOCACHE + uses: actions/cache/restore@v4 + with: + key: go-test-cache-${{ github.ref_name }}-postgres + restore-keys: | + go-test-cache-${{ github.base_ref }}-postgres + go-test-cache-main-postgres + path: /home/runner/.cache/go-build + - env: + GRAFANA_TEST_DB: postgres + PGPASSWORD: grafanatest + POSTGRES_HOST: 127.0.0.1 + run: | + sudo apt-get update -yq && sudo apt-get install postgresql-client + psql -p 5432 -h 127.0.0.1 -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql + make gen-go + go test -p=1 -tags=postgres -timeout=5m -run '^TestIntegration' $(find ./pkg -type f -name '*_test.go' -exec grep -l '^func TestIntegration' '{}' '+' | grep -o '\(.*\)/' | sort -u) + - name: Save GOCACHE + uses: actions/cache/save@v4 + with: + key: go-test-cache-${{ github.ref_name }}-postgres + path: /home/runner/.cache/go-build