Skip to content

Commit 24c7cd9

Browse files
committed
new workflow for creating fail comparison report
1 parent c42d432 commit 24c7cd9

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Compare CI Failures
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
current_ref:
7+
description: 'Current reference (workflow url, commit hash, or git tag) (default: current commit on selected branch)'
8+
required: false
9+
type: string
10+
previous_ref:
11+
description: 'Previous reference to compare with (workflow url, commit hash, or git tag) (default: previous stable tag on selected branch)'
12+
required: false
13+
type: string
14+
upstream_ref:
15+
description: 'Upstream reference to compare with (MAJOR.MINOR version, commit hash, or git tag) (default: previous lts tag on selected branch)'
16+
required: false
17+
type: string
18+
include_broken:
19+
description: 'Include BROKEN tests in comparison'
20+
required: false
21+
type: boolean
22+
default: false
23+
push:
24+
tags:
25+
- 'v*.altinity*'
26+
27+
env:
28+
CHECKS_DATABASE_HOST: ${{ secrets.CHECKS_DATABASE_HOST }}
29+
CHECKS_DATABASE_USER: ${{ secrets.CLICKHOUSE_TEST_STAT_LOGIN }}
30+
CHECKS_DATABASE_PASSWORD: ${{ secrets.CLICKHOUSE_TEST_STAT_PASSWORD }}
31+
32+
jobs:
33+
compare:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Check commit status
37+
run: |
38+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.current_ref }}" ]]; then
39+
# For workflow_dispatch with custom ref, skip the check
40+
exit 0
41+
fi
42+
43+
# Query GitHub API for commit status
44+
STATUSES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
45+
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/status")
46+
47+
# Check if there are any statuses
48+
if [ "$(echo $STATUSES | jq '.total_count')" -eq 0 ]; then
49+
echo "No commit statuses found for ${{ github.sha }}. Assuming tests have not run yet. Aborting workflow."
50+
exit 1
51+
fi
52+
53+
echo "Found commit statuses, proceeding with comparison."
54+
55+
- name: Check out repository code
56+
uses: actions/checkout@v3
57+
58+
- name: Set up Python
59+
uses: actions/setup-python@v4
60+
with:
61+
python-version: '3.x'
62+
cache: 'pip'
63+
64+
- name: Install dependencies
65+
run: |
66+
python -m pip install --upgrade pip
67+
pip install clickhouse-driver requests pandas
68+
69+
- name: Set default refs
70+
id: default_refs
71+
run: |
72+
VERSION=$(git describe --tags --abbrev=0 | sed 's/v\([0-9]\+\.[0-9]\+\).*/\1/')
73+
PREVIOUS_TAG_COMMIT=$(git log -1 --until=yesterday --tags=v${VERSION}*.altinity* | grep -Po "(?<=commit ).*")
74+
UPSTREAM_TAG_COMMIT=$(git log -1 --tags=v${VERSION}*-lts | grep -Po "(?<=commit ).*")
75+
echo "PREVIOUS_TAG: $(git tag --contains $PREVIOUS_TAG_COMMIT) $PREVIOUS_TAG_COMMIT"
76+
echo "UPSTREAM_TAG: $(git tag --contains $UPSTREAM_TAG_COMMIT) $UPSTREAM_TAG_COMMIT"
77+
echo "PREVIOUS_TAG_COMMIT=$PREVIOUS_TAG_COMMIT" >> $GITHUB_OUTPUT
78+
echo "UPSTREAM_TAG_COMMIT=$UPSTREAM_TAG_COMMIT" >> $GITHUB_OUTPUT
79+
80+
- name: Comparison report
81+
if: ${{ !cancelled() }}
82+
run: |
83+
git clone --revision=c5751cefd4f56bd7300b5f6d84a5ae9d0b686772 --depth=1 https://github.com/Altinity/actions.git
84+
cd actions
85+
python3 scripts/compare_ci_fails.py \
86+
--current-ref ${{ inputs.current_ref || github.sha }} \
87+
--previous-ref ${{ inputs.previous_ref || steps.default_refs.outputs.PREVIOUS_TAG_COMMIT }} \
88+
--upstream-ref ${{ inputs.upstream_ref || steps.default_refs.outputs.UPSTREAM_TAG_COMMIT }} \
89+
${{ inputs.include_broken && '--broken' || '' }}
90+
cat comparison_results.md >> $GITHUB_STEP_SUMMARY
91+
92+
- name: Upload comparison results
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: comparison-results
96+
path: |
97+
actions/comparison_results.md

0 commit comments

Comments
 (0)