Skip to content

Commit

Permalink
chore: Test Grafana v10 and v11 in CI
Browse files Browse the repository at this point in the history
* Split CI jobs in multiple files

Signed-off-by: Mahendra Paipuri <mahendra.paipuri@gmail.com>
  • Loading branch information
mahendrapaipuri committed Jul 12, 2024
1 parent c69d2ca commit d5f4b7d
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 170 deletions.
3 changes: 1 addition & 2 deletions .ci/config/tls/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ apps:

jsonData:
appUrl: https://localhost:3000
skipTlsCheck: true
orientation: portrait
layout: simple
dashboardMode: default
dashboardMode: full
timeZone: ''
logo: ''
maxRenderWorkers: 2
Expand Down
6 changes: 4 additions & 2 deletions .ci/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
context: ../.config
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-oss}
grafana_version: ${GRAFANA_VERSION:-10.4.2}
grafana_version: ${GRAFANA_VERSION:-11.1.0}
ports:
- 3080:${GF_SERVER_HTTP_PORT:-3000}/tcp
volumes:
Expand All @@ -25,6 +25,7 @@ services:
- GF_SERVER_HTTP_PORT=${GF_SERVER_HTTP_PORT:-3000}
- GF_LOG_LEVEL=${GF_LOG_LEVEL:-info}
- GF_DATAPROXY_LOGGING=true
- GF_APP_URL=http://localhost:3000
# allow anonymous admin so we don't have to set up a password to start testing
- GF_AUTH_ANONYMOUS_ENABLED=false
- GF_AUTH_BASIC_ENABLED=true
Expand Down Expand Up @@ -62,7 +63,7 @@ services:
context: ../.config
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-oss}
grafana_version: ${GRAFANA_VERSION:-10.4.2}
grafana_version: ${GRAFANA_VERSION:-11.1.0}
ports:
- 3443:${GF_SERVER_HTTP_PORT:-3000}/tcp
volumes:
Expand Down Expand Up @@ -94,6 +95,7 @@ services:
- GF_SERVER_PROTOCOL=https
- GF_SERVER_CERT_KEY=/etc/grafana/tls/localhost.key
- GF_SERVER_CERT_FILE=/etc/grafana/tls/localhost.crt
- IGNORE_HTTPS_ERRORS=true
# Grafana image renderer
- GF_RENDERING_SERVER_URL=http://renderer_tls:8081/render
- GF_RENDERING_CALLBACK_URL=https://grafana_tls:${GF_SERVER_HTTP_PORT:-3000}/
Expand Down
181 changes: 18 additions & 163 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,171 +9,26 @@ on:
branches:
- main

permissions:
# All nested workflows will inherit these permissions and so no need to declare
# in each step file
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
uses: ./.github/workflows/step_build.yml

e2e-tests:
needs: [build]
uses: ./.github/workflows/step_e2e-tests.yml

package:
needs: [build, e2e-tests]
uses: ./.github/workflows/step_package.yml
# For nightly build releases
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

# Install chrome as we will use it in unit tests
- uses: browser-actions/setup-chrome@v1
with:
install-dependencies: true

- name: Install dependencies
run: yarn install --immutable --prefer-offline

- name: Check types
run: yarn typecheck

- name: Lint
run: yarn lint

- name: Unit tests
run: yarn test:ci

- name: Build frontend
run: yarn build

- name: Check for backend
id: check-for-backend
run: |
if [ -f "Magefile.go" ]
then
echo "has-backend=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go environment
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: coverage

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: build

- name: Run e2e tests
run: |
yarn e2e:server:up
# Sleep for a while for containers to be up and running
sleep 20
# Run e2e tests
yarn e2e
# Run API tests
yarn e2e:report
# yarn e2e:server:down
- name: Compare PDF report from plain server
uses: nowsprinting/diff-pdf-action@v1
with:
file1: default.pdf
file2: .ci/reports/default.pdf
options: --verbose

- name: Compare PDF report from TLS server
uses: nowsprinting/diff-pdf-action@v1
with:
file1: alternative.pdf
file2: .ci/reports/alternative.pdf
options: --verbose

# Remove this once plugin review has been submitted
- name: Package plugin
# Grafana Labs review needs the plugin file in zip format with sha1 checksum
run: |
mv dist mahendrapaipuri-dashboardreporter-app
zip mahendrapaipuri-dashboardreporter-app-nightly.zip mahendrapaipuri-dashboardreporter-app -r
sha1sum mahendrapaipuri-dashboardreporter-app-nightly.zip | cut -f1 -d' ' > mahendrapaipuri-dashboardreporter-app-nightly.zip.sha1
- name: Validate plugin
run: |
zip plugin-app.zip pkg/ src/ package.json go.* Magefile.go -r
git clone --depth 1 --branch v0.16.1 https://github.com/grafana/plugin-validator
pushd ./plugin-validator/pkg/cmd/plugincheck2
go install
popd
plugincheck2 -sourceCodeUri plugin-app.zip -config ./plugin-validator/config/pipeline.yaml mahendrapaipuri-dashboardreporter-app-nightly.zip
shell: bash

# Check if bootstrap script is working for latest release and nightly release
- name: Check bootstrap script
run: |
mkdir -p latest
cd latest
../scripts/bootstrap-dashboard-reporter-app.sh
cd ..
mkdir -p nightly
cd nightly
NIGHTLY=1 ../scripts/bootstrap-dashboard-reporter-app.sh
cd ..
shell: bash

- name: Upload plugin artifacts
uses: actions/upload-artifact@v4
with:
name: plugin-artifacts
path: |
mahendrapaipuri-dashboardreporter-app-nightly.zip
mahendrapaipuri-dashboardreporter-app-nightly.zip.sha1
retention-days: 3

- name: Collect docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: docker-logs

- name: Upload UI Test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: ui-test-output
path: |
test-results
docker-logs
default.pdf
alternative.pdf
retention-days: 1

- name: Release nightly
uses: softprops/action-gh-release@v1
# Only run on main branch
if: github.ref == 'refs/heads/main'
with:
prerelease: true
name: nightly
tag_name: nightly
files: |
mahendrapaipuri-dashboardreporter-app-nightly.zip
mahendrapaipuri-dashboardreporter-app-nightly.zip.sha1
fail_on_unmatched_files: true
body: |
# Latest Build Complete! :rocket:
For the public download links of these build artifacts, please see:
<https://github.com/mahendrapaipuri/grafana-dashboard-reporter-app/releases/tag/nightly>
68 changes: 68 additions & 0 deletions .github/workflows/step_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: build
run-name: Build and Unit Tests

on:
workflow_call:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable --prefer-offline

- name: Check types
run: yarn typecheck

- name: Lint
run: yarn lint

- name: Unit tests
run: yarn test:ci

- name: Build frontend
run: yarn build

- name: Check for backend
id: check-for-backend
run: |
if [ -f "Magefile.go" ]
then
echo "has-backend=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go environment
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: coverage

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist
retention-days: 1
94 changes: 94 additions & 0 deletions .github/workflows/step_e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: e2e-tests
run-name: End2End tests

on:
workflow_call:

jobs:
tests:
name: tests
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
# Grafana v10
- grafana-version: 10.4.5
# Grafana v11
- grafana-version: 11.1.0

steps:
- uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable --prefer-offline

# Install chrome as we will use it in e2e tests
- uses: browser-actions/setup-chrome@v1
with:
install-dependencies: true

- name: Run e2e tests
run: |
# Upload/Download artifacts wont preserve permissions
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
# Add +x bits on executables
chmod -R +x dist/gpx_*
GRAFANA_VERSION=${{ matrix.grafana-version }} yarn e2e:server:up
# Sleep for a while for containers to be up and running
sleep 20
# Run e2e tests
yarn e2e
# Run API tests
yarn e2e:report
# yarn e2e:server:down
- name: Compare PDF report from plain server
uses: nowsprinting/diff-pdf-action@v1
with:
file1: default.pdf
file2: .ci/reports/default.pdf
options: --verbose

- name: Compare PDF report from TLS server
uses: nowsprinting/diff-pdf-action@v1
with:
file1: alternative.pdf
file2: .ci/reports/alternative.pdf
options: --verbose

- name: Collect docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: docker-logs

- name: Upload UI Test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: ui-test-output-${{ matrix.grafana-version }}
path: |
test-results
docker-logs
default.pdf
alternative.pdf
retention-days: 1
Loading

0 comments on commit d5f4b7d

Please sign in to comment.