Skip to content

Commit 1c101ef

Browse files
sunkerCopilot
andauthored
feat: switch e2e-version to use nightly image instead of grafana-dev (#216)
* remove get-dev-image-tag.js and update index.js to handle nightly image logic * Update e2e-version/index.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update e2e-version/index.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: use getBooleanInput OR for deprecated alias, add nightly image tests * chore: add deprecationMessage to skip-grafana-dev-image, add braces to test ifs --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 73f926e commit 1c101ef

6 files changed

Lines changed: 73 additions & 195 deletions

File tree

e2e-version/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ This Action resolves what Grafana image names and versions to use when E2E testi
44

55
## Inputs
66

7-
### `skip-grafana-dev-image`
7+
### `skip-grafana-nightly-image`
88

9-
By default, this actions resolves an image for the latest build of the main branch in Grafana. If you don't want to include the `grafana-dev` image in your test matrix, you can opt-out on it by setting the `skip-grafana-dev-image` to `true`.
9+
By default, this action includes the `grafana-enterprise:nightly` image in the test matrix. To exclude it, set `skip-grafana-nightly-image` to `true`.
10+
11+
> **Deprecated:** The old `skip-grafana-dev-image` input is still accepted as an alias but will be removed in a future release.
1012
1113
### `limit`
1214

@@ -17,7 +19,7 @@ The maximum number of versions to resolve. Default is 6, 0 means no limit.
1719
The action supports two modes.
1820

1921
**plugin-grafana-dependency (default)**
20-
The will return the most recent grafana-dev image and all the latest patch release of every minor version of Grafana Enterprise that satisfies the range specified in the [dependencies.grafanaDependency](https://grafana.com/developers/plugin-tools/reference/plugin-json#properties-1) property in plugin.json. This requires the plugin.json file to be placed in the `<root>/src` directory. To avoid starting too many jobs, to output will be capped 6 versions.
22+
This will return the `grafana-enterprise:nightly` image and all the latest patch releases of every minor version of Grafana Enterprise that satisfies the range specified in the [dependencies.grafanaDependency](https://grafana.com/developers/plugin-tools/reference/plugin-json#properties-1) property in plugin.json. This requires the plugin.json file to be placed in the `<root>/src` directory. To avoid starting too many jobs, the output will be capped at 6 versions.
2123

2224
### Example
2325

@@ -26,8 +28,8 @@ At the time of writing, the most recent release of Grafana is 10.3.1. If the plu
2628
```json
2729
[
2830
{
29-
"name": "grafana-dev",
30-
"version": "10.4.0-157931"
31+
"name": "grafana-enterprise",
32+
"version": "nightly"
3133
},
3234
{
3335
"name": "grafana-enterprise",
@@ -55,7 +57,7 @@ At the time of writing, the most recent release of Grafana is 10.3.1. If the plu
5557
Please note that the output changes as new versions of Grafana are being released.
5658

5759
**version-support-policy**
58-
Except for resolving the most recent grafana-dev image, this will resolve versions according to Grafana's plugin compatibility support policy. Specifically, it retrieves the latest patch release for each minor version within the current major version of Grafana. Additionally, it includes the most recent release for the latest minor version of the previous major Grafana version.```
60+
Except for including the `grafana-enterprise:nightly` image, this will resolve versions according to Grafana's plugin compatibility support policy. Specifically, it retrieves the latest patch release for each minor version within the current major version of Grafana. Additionally, it includes the most recent release for the latest minor version of the previous major Grafana version.
5961

6062
### Example
6163

@@ -64,8 +66,8 @@ At the time of writing, the most recent release of Grafana is 10.2.2. The output
6466
```json
6567
[
6668
{
67-
"name": "grafana-dev",
68-
"version": "10.4.0-157931"
69+
"name": "grafana-enterprise",
70+
"version": "nightly"
6971
},
7072
{
7173
"name": "grafana-enterprise",

e2e-version/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: 'Grafana E2E version resolver'
22
description: 'Resolve Grafana versions for use in E2E tests'
33

44
inputs:
5+
skip-grafana-nightly-image:
6+
default: false
7+
required: false
8+
description: 'Optionally, you can skip the Grafana nightly image'
9+
type: boolean
510
skip-grafana-dev-image:
611
default: false
712
required: false
8-
description: 'Optionally, you can skip the Grafana dev image'
13+
description: 'Deprecated: use skip-grafana-nightly-image instead'
14+
deprecationMessage: 'skip-grafana-dev-image is deprecated, use skip-grafana-nightly-image instead'
915
type: boolean
1016
skip-grafana-react-19-preview-image:
1117
required: false

e2e-version/dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e-version/get-dev-image-tag.js

Lines changed: 0 additions & 174 deletions
This file was deleted.

e2e-version/index.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const core = require('@actions/core');
22
const semver = require('semver');
3-
const getDevImageTag = require('./get-dev-image-tag');
43
const fs = require('fs/promises');
54
const path = require('path');
65

6+
const SkipGrafanaNightlyImageInput = 'skip-grafana-nightly-image';
77
const SkipGrafanaDevImageInput = 'skip-grafana-dev-image';
88
const SkipGrafanaReact19PreviewImageInput = 'skip-grafana-react-19-preview-image';
99
const VersionResolverTypeInput = 'version-resolver-type';
@@ -18,7 +18,9 @@ const VersionResolverTypes = {
1818

1919
async function run() {
2020
try {
21-
const skipGrafanaDevImage = core.getBooleanInput(SkipGrafanaDevImageInput);
21+
// skip-grafana-dev-image is a deprecated alias for skip-grafana-nightly-image
22+
const skipGrafanaNightlyImage =
23+
core.getBooleanInput(SkipGrafanaNightlyImageInput) || core.getBooleanInput(SkipGrafanaDevImageInput);
2224

2325
// Determine default for React image based on repository owner
2426
// Include by default for Grafana org repositories, skip for others
@@ -83,7 +85,8 @@ async function run() {
8385

8486
if (limit !== 0 && versionResolverType === VersionResolverTypes.PluginGrafanaDependency && versions.length !== 0) {
8587
// limit the number of versions to avoid starting too many jobs
86-
versions = evenlyPickVersions(versions, skipGrafanaDevImage ? limit : limit - 1);
88+
const stableVersionLimit = Math.max(0, skipGrafanaNightlyImage ? limit : limit - 1);
89+
versions = evenlyPickVersions(versions, stableVersionLimit);
8790
}
8891

8992
// official grafana-enterprise image
@@ -92,12 +95,8 @@ async function run() {
9295
version,
9396
}));
9497

95-
if (!skipGrafanaDevImage) {
96-
// get the most recent grafana-dev image
97-
const tag = await getDevImageTag({ core });
98-
if (tag) {
99-
images.unshift({ name: 'grafana-dev', version: tag });
100-
}
98+
if (!skipGrafanaNightlyImage) {
99+
images.unshift({ name: 'grafana-enterprise', version: 'nightly' });
101100
}
102101

103102
if (!skipGrafanaReact19PreviewImage) {

e2e-version/index.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,54 @@ describe('plugin-grafana-dependency mode', () => {
4848
if (name === GrafanaDependencyInput) {
4949
return t.grafanaDependency;
5050
}
51+
if (name === 'limit') {
52+
return '6';
53+
}
54+
if (name === 'skip-grafana-nightly-image') {
55+
return 'true';
56+
}
57+
return '';
5158
});
5259
getBooleanInput.mockReturnValue(true);
5360
const images = await run();
5461
expect(images.map((i) => i.version)).toEqual(t.expectedVersions);
5562
});
5663
});
64+
65+
describe('nightly image', () => {
66+
it('is included by default', async () => {
67+
getInput.mockImplementation((name) => {
68+
if (name === VersionResolverTypeInput) { return VersionResolverTypes.PluginGrafanaDependency; }
69+
if (name === GrafanaDependencyInput) { return '>=10.4.4'; }
70+
if (name === 'limit') { return '6'; }
71+
return '';
72+
});
73+
getBooleanInput.mockReturnValue(false);
74+
const images = await run();
75+
expect(images[0]).toEqual({ name: 'grafana-enterprise', version: 'nightly' });
76+
});
77+
78+
it('is skipped when skip-grafana-nightly-image is true', async () => {
79+
getInput.mockImplementation((name) => {
80+
if (name === VersionResolverTypeInput) { return VersionResolverTypes.PluginGrafanaDependency; }
81+
if (name === GrafanaDependencyInput) { return '>=10.4.4'; }
82+
if (name === 'limit') { return '6'; }
83+
return '';
84+
});
85+
getBooleanInput.mockImplementation((name) => name === 'skip-grafana-nightly-image');
86+
const images = await run();
87+
expect(images.every((i) => i.version !== 'nightly')).toBe(true);
88+
});
89+
90+
it('is skipped when deprecated skip-grafana-dev-image is true', async () => {
91+
getInput.mockImplementation((name) => {
92+
if (name === VersionResolverTypeInput) { return VersionResolverTypes.PluginGrafanaDependency; }
93+
if (name === GrafanaDependencyInput) { return '>=10.4.4'; }
94+
if (name === 'limit') { return '6'; }
95+
return '';
96+
});
97+
getBooleanInput.mockImplementation((name) => name === 'skip-grafana-dev-image');
98+
const images = await run();
99+
expect(images.every((i) => i.version !== 'nightly')).toBe(true);
100+
});
101+
});

0 commit comments

Comments
 (0)