Skip to content

Commit 93fb587

Browse files
authored
Actions: Run tests (#669)
1 parent f818934 commit 93fb587

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.github/workflows/test.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
tests:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
version: [lts/*, .nvmrc]
21+
22+
name: Tests (Node.js ${{ matrix.version }})
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read # clone the repository
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
30+
31+
# We start the backend service while we install dependencies.
32+
# We'll wait on it when we are about to start the actual tests.
33+
- working-directory: devenv/docker/test
34+
run: docker compose up -d
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ (matrix.version != '.nvmrc' && matrix.version) || '' }}
39+
node-version-file: ${{ (matrix.version == '.nvmrc' && matrix.version) || '' }}
40+
- run: yarn install --frozen-lockfile
41+
42+
# Time to wait for Grafana to be ready, if it isn't already. (It probably is, but we can be sure for practically free...)
43+
- working-directory: devenv/docker/test
44+
run: docker compose up -d --wait
45+
- run: yarn run test-ci
46+
env:
47+
GRAFANA_DOMAIN: localhost
48+
1649
eslint:
1750
name: ESLint
1851
runs-on: ubuntu-latest

devenv/docker/test/docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ services:
77
- 3000:3000
88
environment:
99
GF_FEATURE_TOGGLES_ENABLE: renderAuthJWT
10+
healthcheck:
11+
test: ["CMD", "curl", "-f", "http://localhost:3000/healthz"]
12+
start_period: 15s # give it a while to startup and do migrations
13+
interval: 5s
14+
timeout: 3s
15+
retries: 5
1016
volumes:
1117
- ./dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
1218
- ../../../scripts/drone/provisioning/dashboards:/usr/share/grafana/dashboards

src/service/http-server.integration.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ afterEach(() => {
118118
});
119119

120120
function setupTestEnv(config?: ServiceConfig) {
121-
if (process.env['CI'] === 'true') {
121+
if (process.env['GRAFANA_DOMAIN']) {
122+
domain = process.env['GRAFANA_DOMAIN'];
123+
} else if (process.env['CI'] === 'true') {
122124
domain = 'grafana';
123125
}
124126

0 commit comments

Comments
 (0)