Skip to content

Commit 66591bc

Browse files
jsilvelaNiccoloFeijlong49
authored
feat: create a test thermometer (#10)
- Introduce a "thermometer" both for the GH summary, and as an output that can be used in chatops - Stop overcounting kubernetes versions and failure rates in them - Cap the number of alerts shown in chatops (max 2 per metric) - Update the GH actions dependencies Closes #9 Signed-off-by: Jaime Silvela <[email protected]> Signed-off-by: Niccolò Fei <[email protected]> Signed-off-by: John Long <[email protected]> Co-authored-by: Niccolò Fei <[email protected]> Co-authored-by: John Long <[email protected]>
1 parent 3139ac5 commit 66591bc

14 files changed

+249
-55
lines changed

.github/workflows/overflow-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
name: Overflow Test
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

1717
- name: Generate Test Summary
1818
id: generate-summary
@@ -23,7 +23,7 @@ jobs:
2323

2424
- name: If there is an overflow summary, archive it
2525
if: ${{steps.generate-summary.outputs.Overflow}}
26-
uses: actions/upload-artifact@v3
26+
uses: actions/upload-artifact@v4
2727
with:
2828
name: ${{steps.generate-summary.outputs.Overflow}}
2929
path: ${{steps.generate-summary.outputs.Overflow}}

.github/workflows/test.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
name: Smoke Test
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111

1212
- name: Generate Test Summary
1313
id: generate-summary
@@ -18,3 +18,6 @@ jobs:
1818
- name: If there are alerts, echo them
1919
if: ${{steps.generate-summary.outputs.alerts}}
2020
run: echo "${{steps.generate-summary.outputs.alerts}}"
21+
22+
- name: Echo the thermometer
23+
run: echo "${{steps.generate-summary.outputs.thermometer}}"

.github/workflows/unit-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
name: Unit test
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111

1212
- name: Set up Python
13-
uses: actions/setup-python@v4
13+
uses: actions/setup-python@v5
1414
with:
1515
python-version: '3.x'
1616

DEVELOPERS_DEVELOPERS_DEVELOPERS.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
# Building and testing locally
1+
# Building, testing, releasing
22

33
The `ciclops` GitHub Action runs using a Docker container that encapsulates the
44
Python script that does the CI test analysis.
55

6+
## Releasing
7+
8+
We recommend that users of Ciclops use released versions rather than `main`.
9+
For testing, it may be convenient to [use a full SHA](#testing-within-a-calling-github-workflow).
10+
11+
The procedure for cutting a release:
12+
13+
1. Decide on the version number (following semVer)
14+
1. Update the [Release notes file](ReleaseNotes.md), following the convention
15+
in the file, i.e. the version number included in the section, and the release
16+
date in the first line
17+
1. Review and merge the release notes, and create and push a new tag with the
18+
desired version number
19+
1. Cut a new release in [GitHub](https://github.com/cloudnative-pg/ciclops/releases/new),
20+
choosing the recent tag, and pasting the relevant content from the
21+
Release Notes file (no need for the release date line).
22+
623
## Developing and testing
724

825
You can test directly with the Python code on the `example-artifacts` directory,
@@ -72,6 +89,22 @@ CIclops has the beginning of a unit test suite. You can run it with:
7289
python3 -m unittest
7390
```
7491

92+
## Testing within a calling GitHub workflow
93+
94+
Even with unit tests and local tests, it's good to try Ciclops code out from a
95+
client workflow. We can use a full length commit SHA to test out changes,
96+
before cutting out a new release.
97+
See the [GitHub document on using third party actions](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions).
98+
99+
Example:
100+
``` yaml
101+
- name: Compute the E2E test summary
102+
id: generate-summary
103+
uses: cloudnative-pg/ciclops@<FULL_LENGTH_SHA>
104+
with:
105+
artifact_directory: test-artifacts/da
106+
```
107+
75108
## How it works
76109
77110
The files in this repository are needed for the Dockerfile to build and run, of

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ watch over Continuous Integration pipelines for all eternity.
2020

2121
## Outputs
2222

23-
Two outputs might be produced:
23+
Up to three outputs might be produced:
24+
25+
- `thermometer`: this will contain stand-alone text with a color-coded list
26+
of test metrics that can serve as an overview of the state of the test suite
27+
on CI/CD. This is generated on every execution of Ciclops.
2428

2529
- `alerts`: this will contain stand-alone text with systematic failures
2630
detected by CIclops. It is meant to enable further steps in the calling
@@ -97,7 +101,12 @@ There are two advanced cases we want to call attention to:
97101
called `Overflow`.
98102

99103
2. Monitoring with chatops \
100-
CIclops will create a series of alerts when systematic failures are detected.
104+
Ciclops will generate a "thermometer" on every execution, offering a
105+
color-coded overview of the test health. This thermometer is included in
106+
the GitHub summary, and in addition, is exported as an output in plain
107+
text, which can be sent via chatops.
108+
In addition, Ciclops will create a series of alerts when systematic failures
109+
are detected.
101110
By "systematic", we mean cases such as:
102111

103112
- all test combinations have failed
@@ -131,6 +140,13 @@ The following snippet shows how to use these features:
131140
path: ${{steps.generate-summary.outputs.Overflow}}
132141
retention-days: 7
133142
143+
- name: Get a slack message with the Ciclops thermometer
144+
uses: rtCamp/action-slack-notify@v2
145+
env:
146+
SLACK_USERNAME: cnpg-bot
147+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
148+
SLACK_MESSAGE: ${{steps.generate-summary.outputs.thermometer}}
149+
134150
- name: If there are alerts, send them over Slack
135151
if: ${{steps.generate-summary.outputs.alerts}}
136152
uses: rtCamp/action-slack-notify@v2

action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ inputs:
2222
outputs:
2323
alerts:
2424
description: 'Any systematic failures found by CIclops'
25+
thermometer:
26+
description: 'A color-coded health meter'
2527
Overflow:
2628
description: 'The name of the file where the full report was written, on oveflow'
2729
runs:

example-artifacts/id1_0b185c51a60964ecab5bb7d97458ca95fd421f325f3896ed239d5d3f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postgres_kind": "PostgreSQL",
1111
"matrix_id": "id1",
1212
"postgres_version": "11.1",
13-
"k8s_version": "22",
13+
"k8s_version": "1.22",
1414
"workflow_id": 12,
1515
"repo": "my-repo",
1616
"branch": "my-branch"

example-artifacts/id1_4902843ff6a60bc4fdb76000698c46de8e7f9763a1a0fe63f70fd5f8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postgres_kind": "PostgreSQL",
1111
"matrix_id": "id1",
1212
"postgres_version": "11.1",
13-
"k8s_version": "22",
13+
"k8s_version": "1.22",
1414
"workflow_id": 12,
1515
"repo": "my-repo",
1616
"branch": "my-branch"

example-artifacts/id1_9891d0d1caa1ec8fd0adfe622e341f84dd3d1df1cffee843e1fb84a0.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postgres_kind": "PostgreSQL",
1111
"matrix_id": "id1",
1212
"postgres_version": "11.1",
13-
"k8s_version": "22",
13+
"k8s_version": "1.22",
1414
"workflow_id": 12,
1515
"repo": "my-repo",
1616
"branch": "my-branch"

few-artifacts/id1_0b185c51a60964ecab5bb7d97458ca95fd421f325f3896ed239d5d3f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"postgres_kind": "PostgreSQL",
1111
"matrix_id": "id1",
1212
"postgres_version": "11.1",
13-
"k8s_version": "22",
13+
"k8s_version": "1.22",
1414
"workflow_id": 12,
1515
"repo": "my-repo",
1616
"branch": "my-branch"

0 commit comments

Comments
 (0)