mirror of https://github.com/grafana/grafana
CI: Add integration tests GitHub Actions workflow (#101732)
* Add integration tests workflow --------- Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>pull/102124/head
parent
9264431c81
commit
20b91cfa04
@ -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 |
||||
Loading…
Reference in new issue