|
| 1 | +name: Compare CI Failures |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + current_ref: |
| 7 | + description: 'Current reference (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 (commit hash, git tag or workflow url) (default: previous stable tag for current reference)' |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + upstream_ref: |
| 15 | + description: 'Upstream reference to compare with (commit hash, git tag or MAJOR.MINOR version) (default: previous lts tag for current reference)' |
| 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: [self-hosted, altinity-on-demand, altinity-style-checker-aarch64] |
| 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 | + with: |
| 58 | + fetch-depth: 0 |
| 59 | + ref: ${{ inputs.current_ref || github.ref }} |
| 60 | + |
| 61 | + - name: Set up Python |
| 62 | + uses: actions/setup-python@v4 |
| 63 | + with: |
| 64 | + python-version: '3.x' |
| 65 | + cache: 'pip' |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + pip install clickhouse-driver requests pandas tabulate |
| 71 | +
|
| 72 | + - name: Set default refs |
| 73 | + id: default_refs |
| 74 | + run: | |
| 75 | + VERSION=$(git describe --tags --abbrev=0 | sed 's/v\([0-9]\+\.[0-9]\+\).*/\1/') |
| 76 | + echo "Detected version: $VERSION" |
| 77 | + |
| 78 | + CURRENT_TAG=$(git tag --contains ${{ inputs.current_ref || github.sha }} | sort -r | grep -m 1 'altinity' || echo '') |
| 79 | + echo "CURRENT_TAG: '$CURRENT_TAG' ${{ inputs.current_ref || github.sha }}" |
| 80 | + PREVIOUS_TAG_COMMIT=$(git log -1 --until=yesterday --tags=v${VERSION}*.altinity* | grep -Po "(?<=commit ).*") |
| 81 | + PREVIOUS_TAG=$(git tag --contains $PREVIOUS_TAG_COMMIT | sort -r | grep -m 1 'altinity') |
| 82 | + echo "PREVIOUS_TAG: '$PREVIOUS_TAG' $PREVIOUS_TAG_COMMIT" |
| 83 | + UPSTREAM_TAG_COMMIT=$(git log -1 --tags=v${VERSION}*-lts | grep -Po "(?<=commit ).*") |
| 84 | + UPSTREAM_TAG=$(git tag --contains $UPSTREAM_TAG_COMMIT | sort -r | grep -m 1 'lts') |
| 85 | + echo "UPSTREAM_TAG: '$UPSTREAM_TAG' $UPSTREAM_TAG_COMMIT" |
| 86 | +
|
| 87 | + echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_OUTPUT |
| 88 | + echo "PREVIOUS_TAG_COMMIT=$PREVIOUS_TAG_COMMIT" >> $GITHUB_OUTPUT |
| 89 | + echo "UPSTREAM_TAG=$UPSTREAM_TAG" >> $GITHUB_OUTPUT |
| 90 | + echo "UPSTREAM_TAG_COMMIT=$UPSTREAM_TAG_COMMIT" >> $GITHUB_OUTPUT |
| 91 | + echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_OUTPUT |
| 92 | + - name: Comparison report |
| 93 | + if: ${{ !cancelled() }} |
| 94 | + run: | |
| 95 | + git clone https://github.com/Altinity/actions.git |
| 96 | + cd actions |
| 97 | + git checkout 4623f919ee2738bea69aad405879562476736932 |
| 98 | + python3 scripts/compare_ci_fails.py \ |
| 99 | + --current-ref ${{ steps.default_refs.outputs.CURRENT_TAG || inputs.current_ref || github.sha }} \ |
| 100 | + --previous-ref ${{ steps.default_refs.outputs.PREVIOUS_TAG || inputs.previous_ref || steps.default_refs.outputs.PREVIOUS_TAG_COMMIT }} \ |
| 101 | + --upstream-ref ${{ steps.default_refs.outputs.UPSTREAM_TAG || inputs.upstream_ref || steps.default_refs.outputs.UPSTREAM_TAG_COMMIT }} \ |
| 102 | + ${{ inputs.include_broken && '--broken' || '' }} |
| 103 | + cat comparison_results.md >> $GITHUB_STEP_SUMMARY |
| 104 | +
|
| 105 | + - name: Upload comparison results |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: comparison-results |
| 109 | + path: | |
| 110 | + actions/comparison_results.md |
0 commit comments