forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yaml
More file actions
81 lines (74 loc) · 3.47 KB
/
Copy pathaction.yaml
File metadata and controls
81 lines (74 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright (c) 2023 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0
name: 'Verify Metric Snapshot and Upload Metrics'
description: 'Upload or cache the metrics data after verification'
inputs:
snapshot:
description: 'Path to the metric file'
required: true
artifact_key:
description: 'Artifact key used for uploading and fetching artifacts'
required: true
runs:
using: 'composite'
steps:
- name: Upload current metrics snapshot
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: ${{ inputs.artifact_key }}
path: ./.metrics/${{ inputs.snapshot }}.txt
retention-days: 7
# The github cache restore successfully restores when cache saved has same key and same path.
# Hence to restore release metric with name relese_{metric_name} , the name must be changed to the same.
- name: Change file name before caching
if: github.ref_name == 'main'
shell: bash
run: |
mv ./.metrics/${{ inputs.snapshot }}.txt ./.metrics/baseline_${{ inputs.snapshot }}.txt
- name: Cache metrics snapshot on main branch for longer retention
if: github.ref_name == 'main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ./.metrics/baseline_${{ inputs.snapshot }}.txt
key: ${{ inputs.artifact_key }}_${{ github.run_id }}
# Use restore keys to match prefix and fetch the latest cache
# Here , restore keys is an ordered list of prefixes that need to be matched
- name: Download the cached tagged metrics
id: download-release-snapshot
if: github.ref_name != 'main'
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ./.metrics/baseline_${{ inputs.snapshot }}.txt
key: ${{ inputs.artifact_key }}
restore-keys: |
${{ inputs.artifact_key }}
# Create an empty stub so the diff artifact is always uploaded on PRs.
# The fan-in uses 1-to-1 presence of diff artifacts to detect infra failures
# (a missing diff_* artifact means this action never ran for that snapshot).
# The stub is overwritten by the compare step when a baseline exists.
- name: Create diff file stub
if: github.ref_name != 'main'
shell: bash
run: touch ./.metrics/diff_${{ inputs.snapshot }}.txt
- name: Calculate diff between the snapshots
id: compare-snapshots
if: ${{ (github.ref_name != 'main') && (steps.download-release-snapshot.outputs.cache-matched-key != '') }}
continue-on-error: true
shell: bash
run: |
python3 -m pip install prometheus-client
if python3 ./scripts/e2e/compare_metrics.py --file1 ./.metrics/${{ inputs.snapshot }}.txt --file2 ./.metrics/baseline_${{ inputs.snapshot }}.txt --output ./.metrics/diff_${{ inputs.snapshot }}.txt; then
echo "No differences found in metrics"
else
echo "🛑 Differences found in metrics"
echo "has_diff=true" >> $GITHUB_OUTPUT
fi
# Always upload the diff artifact on PRs (even when empty / no baseline yet).
# Presence of this artifact in the fan-in proves this action ran for the snapshot.
- name: Upload the diff artifact
if: github.ref_name != 'main'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: diff_${{ inputs.artifact_key }}
path: ./.metrics/diff_${{ inputs.snapshot }}.txt
retention-days: 7