File: api-check.yml

package info (click to toggle)
setuptools-scm 9.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,108 kB
  • sloc: python: 7,068; sh: 18; makefile: 7
file content (79 lines) | stat: -rw-r--r-- 2,653 bytes parent folder | download
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
name: API Stability Check

on:
  pull_request:
  push:
    branches:
    - "*"

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

env:
  FORCE_COLOR: 1

jobs:
  api-check:
    name: Check API stability with griffe
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0

      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          pip install -U pip setuptools
          pip install -e .[test]
          pip install griffe

      - name: Run griffe API check
        id: griffe-check
        continue-on-error: true
        run: |
          echo "Running griffe API stability check..."
          if griffe check setuptools_scm -ssrc -f github; then
            echo "api_check_result=success" >> $GITHUB_OUTPUT
            echo "exit_code=0" >> $GITHUB_OUTPUT
          else
            exit_code=$?
            echo "api_check_result=warning" >> $GITHUB_OUTPUT
            echo "exit_code=$exit_code" >> $GITHUB_OUTPUT
            exit $exit_code
          fi

      - name: Report API check result
        if: always()
        uses: actions/github-script@v8
        with:
          script: |
            const result = '${{ steps.griffe-check.outputs.api_check_result }}'
            const exitCode = '${{ steps.griffe-check.outputs.exit_code }}'

            if (result === 'success') {
              core.notice('API stability check passed - no breaking changes detected')
              await core.summary
                .addHeading('✅ API Stability Check: Passed', 2)
                .addRaw('No breaking changes detected in the public API')
                .write()
            } else if (result === 'warning') {
              core.warning(`API stability check detected breaking changes (exit code: ${exitCode}). Please review the API changes above.`)
              await core.summary
                .addHeading('⚠️ API Stability Warning', 2)
                .addRaw('Breaking changes detected in the public API. Please review the changes reported above.')
                .addRaw(`\n\nExit code: ${exitCode}`)
                .write()
            } else {
              core.error('API stability check failed to run properly')
              await core.summary
                .addHeading('❌ API Stability Check: Failed', 2)
                .addRaw('The griffe check failed to execute. This may indicate griffe is not installed or there was an error.')
                .write()
            }