-
Notifications
You must be signed in to change notification settings - Fork 0
add new composite actions, add a stale stubs check to type check workflow, refactor shared logic into composite actions #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8752a89
add new composite actions, add a stale stubs check to type check work…
speediedan ca2691f
fix composite action variable/logic mismatch
speediedan b71a375
updated stale stubs and type checks to upload diff artifact, enhanced…
speediedan 7f5cbab
make gpu az pipelines workflow pr trigger explicit
speediedan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Check file diffs | ||
| description: Compare files with git diff and produce a patch if they differ | ||
| inputs: | ||
| compare_paths: | ||
| description: Space-separated list of files/paths to compare with git diff | ||
| required: true | ||
| patch_path: | ||
| description: Path to write the patch file | ||
| required: false | ||
| default: file_diff.patch | ||
| error_message: | ||
| description: Custom error message to display if files differ | ||
| required: false | ||
| default: "Files have changed" | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - id: check | ||
| name: Check for diffs and write patch | ||
| shell: bash | ||
| run: | | ||
| set -e | ||
| rc=0 | ||
| git --no-pager diff --exit-code ${{ inputs.compare_paths }} > ${{ inputs.patch_path }} 2> file_diff.err || rc=$? | ||
| if [ "$rc" -eq 0 ]; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| rm -f file_diff.err || true | ||
| elif [ "$rc" -eq 1 ]; then | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| echo "Patch size: $(wc -c < ${{ inputs.patch_path }}) bytes" | ||
| echo "${{ inputs.error_message }}" | ||
| echo "--- Diff ---" | ||
| cat ${{ inputs.patch_path }} || true | ||
| rm -f file_diff.err || true | ||
| else | ||
| echo "git diff failed with exit code $rc" >&2 | ||
| echo "--- git diff stderr ---" >&2 | ||
| cat file_diff.err >&2 || true | ||
| exit $rc | ||
| fi | ||
| echo "patch_path=${{ inputs.patch_path }}" >> $GITHUB_OUTPUT | ||
|
|
||
| outputs: | ||
| changed: | ||
| description: 'true if files differ' | ||
| value: ${{ steps.check.outputs.changed }} | ||
| patch_path: | ||
| description: 'path to generated patch file' | ||
| value: ${{ steps.check.outputs.patch_path }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: "Install CI Dependencies" | ||
| description: "Install Python dependencies for CI workflows including platform-dependent packages and post-upgrades" | ||
|
|
||
| inputs: | ||
| show_pip_list: | ||
| description: "Whether to show pip list output after installations" | ||
| required: false | ||
| default: "false" | ||
| apply_post_upgrades: | ||
| description: "Whether to apply post-upgrade packages" | ||
| required: false | ||
| default: "true" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up venv and install ci dependencies | ||
| shell: bash | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools wheel build --cache-dir "$PIP_CACHE_DIR" | ||
| # Prefer CI pinned requirements if present | ||
| if [ -f requirements/ci/requirements.txt ]; then | ||
| pip install -r requirements/ci/requirements.txt --cache-dir "$PIP_CACHE_DIR" | ||
| python -m pip install -e '.[test,examples,lightning]' --cache-dir "$PIP_CACHE_DIR" | ||
| else | ||
| python -m pip install -e '.[test,examples,lightning]' -c requirements/ci_constraints.txt --cache-dir "$PIP_CACHE_DIR" | ||
| fi | ||
| if [ "${{ inputs.show_pip_list }}" = "true" ]; then | ||
| pip list | ||
| fi | ||
|
|
||
| - name: Install platform-dependent packages | ||
| shell: bash | ||
| run: | | ||
| # Install platform-dependent packages with flexible constraints to allow platform-specific resolution | ||
| if [ -f requirements/platform_dependent.txt ] && [ -s requirements/platform_dependent.txt ]; then | ||
| echo "Installing platform-dependent packages..." | ||
| python -m pip install -r requirements/platform_dependent.txt --cache-dir "$PIP_CACHE_DIR" || echo "Some platform-dependent packages may not be available on this platform, continuing..." | ||
| else | ||
| echo "No platform-dependent packages to install." | ||
| fi | ||
|
|
||
| - name: Optional post-upgrades (datasets/fsspec etc) | ||
| shell: bash | ||
| env: | ||
| APPLY_POST_UPGRADES: ${{ inputs.apply_post_upgrades }} | ||
| run: | | ||
| if ([ "${APPLY_POST_UPGRADES}" = "1" ] || [ "${APPLY_POST_UPGRADES}" = "true" ]) && [ -s requirements/post_upgrades.txt ]; then | ||
| echo "Applying post-upgrades..." | ||
| python -m pip install --upgrade -r requirements/post_upgrades.txt --cache-dir "$PIP_CACHE_DIR" | ||
| if [ "${{ inputs.show_pip_list }}" = "true" ]; then | ||
| pip list | ||
| fi | ||
| else | ||
| echo "Skipping post-upgrades (either disabled or file empty)." | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||
| name: Type Check | ||||
| name: Stale Stubs and Type Checks | ||||
|
|
||||
| on: | ||||
| push: | ||||
|
|
@@ -9,6 +9,7 @@ on: | |||
| - "pyproject.toml" | ||||
| - "src/**" | ||||
| - "requirements/**" | ||||
| - "scripts/generate_op_stubs.py" | ||||
| - ".github/workflows/type-check.yml" | ||||
| # Exclude documentation-only files from triggering | ||||
| - "!docs/**" | ||||
|
|
@@ -28,6 +29,7 @@ on: | |||
| - "pyproject.toml" | ||||
| - "src/**" | ||||
| - "requirements/**" | ||||
| - "scripts/generate_op_stubs.py" | ||||
| - ".github/workflows/type-check.yml" | ||||
| # Exclude documentation-only files from triggering | ||||
| - "!docs/**" | ||||
|
|
@@ -75,42 +77,48 @@ jobs: | |||
| restore-keys: | | ||||
| ubuntu-22.04-pip-wheels-${{ steps.set_time_period.outputs.TIME_PERIOD }}-py3.12- | ||||
|
|
||||
| - name: Set up venv and install ci dependencies | ||||
| shell: bash | ||||
| run: | | ||||
| python -m pip install --upgrade pip setuptools wheel build --cache-dir "$PIP_CACHE_DIR" | ||||
| # Prefer CI pinned requirements if present | ||||
| if [ -f requirements/ci/requirements.txt ]; then | ||||
| pip install -r requirements/ci/requirements.txt --cache-dir "$PIP_CACHE_DIR" | ||||
| python -m pip install -e '.[test,examples,lightning]' --cache-dir "$PIP_CACHE_DIR" | ||||
| else | ||||
| python -m pip install -e '.[test,examples,lightning]' -c requirements/ci_constraints.txt --cache-dir "$PIP_CACHE_DIR" | ||||
| fi | ||||
| - name: Install CI dependencies | ||||
| uses: ./.github/actions/install-ci-dependencies | ||||
| with: | ||||
| apply_post_upgrades: ${{ vars.APPLY_POST_UPGRADES || 'true' }} | ||||
|
|
||||
| - name: Install platform-dependent packages | ||||
| - name: Check type stubs are up to date | ||||
| id: check_stubs | ||||
| continue-on-error: true | ||||
| shell: bash | ||||
| run: | | ||||
| # Install platform-dependent packages with flexible constraints to allow platform-specific resolution | ||||
| if [ -f requirements/platform_dependent.txt ] && [ -s requirements/platform_dependent.txt ]; then | ||||
| echo "Installing platform-dependent packages..." | ||||
| python -m pip install -r requirements/platform_dependent.txt --cache-dir "$PIP_CACHE_DIR" || echo "Some platform-dependent packages may not be available on this platform, continuing..." | ||||
| else | ||||
| echo "No platform-dependent packages to install." | ||||
| fi | ||||
| # Make a backup of current stubs | ||||
| cp src/interpretune/__init__.pyi src/interpretune/__init__.pyi.backup | ||||
|
||||
| cp src/interpretune/__init__.pyi src/interpretune/__init__.pyi.backup |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition logic is unnecessarily complex with nested brackets. Consider simplifying to
if [[ "${APPLY_POST_UPGRADES}" =~ ^(1|true)$ ]] && [[ -s requirements/post_upgrades.txt ]]; thenfor better readability.