name: apidrift-check (experimental) description: >- EXPERIMENTAL. Flag Python code that uses library APIs which do not exist (or keyword arguments that are not accepted) in the dependency versions pinned by your lockfile. Results appear in GitHub code scanning. branding: icon: alert-triangle color: orange inputs: paths: description: Files or directories to check, one per line (relative to the repository root) default: "." lockfile: description: uv.lock, poetry.lock, pylock.toml or Pipfile.lock (empty = auto-detect at the repo root) default: "" requirements: description: requirements.txt with == pins (used if no lockfile) default: "" data-url: description: >- https:// base URL of the PyPI API Drift data folder (must contain releases.parquet, api_history.parquet, signatures.parquet and top_level_modules.parquet), e.g. a Hugging Face dataset `resolve/main/data` URL required: true data-version: description: Cache key for the downloaded data (letters, digits, '.', '_', '-'); bump it when the dataset is refreshed default: "2026.10-v1.3" fail-on-findings: description: Fail the job when findings are reported ("true" or "false") default: "false" options: description: >- Optional checker flags, space separated. Only these are accepted: --strict, --nearest, --no-deprecations default: "" runs: using: composite steps: - uses: actions/setup-python@v5 with: python-version: "3.12" # Every workflow input reaches the shell only through environment variables, never through ${{ }} # expansion inside a script, and run_action.py validates them and calls the checker with an argument list. - name: Validate inputs id: inputs shell: bash env: IN_DATA_VERSION: ${{ inputs.data-version }} IN_DATA_URL: ${{ inputs.data-url }} run: python "$GITHUB_ACTION_PATH/run_action.py" validate - name: Install apidrift shell: bash run: python -m pip install --quiet "$GITHUB_ACTION_PATH/../.." - name: Restore dataset cache id: cache uses: actions/cache@v4 with: path: ~/.cache/apidrift/${{ steps.inputs.outputs.data_version }} key: apidrift-data-${{ steps.inputs.outputs.data_version }} - name: Download dataset if: steps.cache.outputs.cache-hit != 'true' shell: bash env: IN_DATA_VERSION: ${{ inputs.data-version }} IN_DATA_URL: ${{ inputs.data-url }} run: python "$GITHUB_ACTION_PATH/run_action.py" download - name: Run apidrift-check shell: bash env: IN_PATHS: ${{ inputs.paths }} IN_LOCKFILE: ${{ inputs.lockfile }} IN_REQUIREMENTS: ${{ inputs.requirements }} IN_DATA_VERSION: ${{ inputs.data-version }} IN_OPTIONS: ${{ inputs.options }} run: python "$GITHUB_ACTION_PATH/run_action.py" check - name: Upload SARIF if: always() && hashFiles('apidrift.sarif') != '' uses: github/codeql-action/upload-sarif@v3 with: sarif_file: apidrift.sarif category: apidrift - name: Fail on findings if: inputs.fail-on-findings == 'true' shell: bash run: test "$APIDRIFT_FINDINGS_EXIT" = "0"