Skip to content

Arm Backend: Add tests for rsub.Scalar, transpose_copy.int and t_copy.default #55564

Arm Backend: Add tests for rsub.Scalar, transpose_copy.int and t_copy.default

Arm Backend: Add tests for rsub.Scalar, transpose_copy.int and t_copy.default #55564

Workflow file for this run

name: Lint
on:
pull_request:
branches-ignore:
- nightly
push:
branches:
- main
- release/*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true
jobs:
get-changed-files:
if: github.repository_owner == 'pytorch'
name: Get changed files
uses: ./.github/workflows/_get-changed-files.yml
lintrunner-mypy:
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
needs: [get-changed-files]
permissions:
id-token: write
contents: read
if: |
github.repository_owner == 'pytorch' && (
needs.get-changed-files.outputs.changed-files == '*' ||
contains(needs.get-changed-files.outputs.changed-files, '.py') ||
contains(needs.get-changed-files.outputs.changed-files, '.pyi')
)
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
submodules: 'recursive'
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 90
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
# For mypy linting, we need to first install executorch first so that
# it builds the python package information.
BUILD_TOOL="cmake"
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
CACHE_DIRECTORY="/tmp/.lintbin"
# Try to recover the cached binaries
if [[ -d "${CACHE_DIRECTORY}" ]]; then
# It's ok to fail this as lintrunner init would download these binaries
# again if they do not exist
cp -r "${CACHE_DIRECTORY}" . || true
fi
RC=0
# Run lintrunner on all files. pytorch/pytorch notes that mypy
# in particular needs this.
if ! lintrunner --force-color --all-files --take MYPY --tee-json=lint.json 2> /dev/null; then
echo ""
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --take MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
RC=1
fi
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
jq --raw-output \
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
lint.json || true
exit $RC
lintrunner:
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
needs: [get-changed-files]
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
submodules: false
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 90
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
# Not sure why this isn't set up in the docker
# image. lintrunner-mypy seems to work becaus setup-linux.sh
# does this as part of install_executorch.
pip install -r requirements-dev.txt
CACHE_DIRECTORY="/tmp/.lintbin"
# Try to recover the cached binaries
if [[ -d "${CACHE_DIRECTORY}" ]]; then
# It's ok to fail this as lintrunner init would download these binaries
# again if they do not exist
cp -r "${CACHE_DIRECTORY}" . || true
fi
RC=0
CHANGED_FILES="${{ needs.get-changed-files.outputs.changed-files }}"
if [ "$CHANGED_FILES" = '*' ]; then
LINTRUNNER_FILES="--all-files"
else
LINTRUNNER_FILES="${CHANGED_FILES}"
fi
if ! lintrunner --force-color ${LINTRUNNER_FILES} --skip MYPY --tee-json=lint.json 2> /dev/null; then
echo ""
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --skip MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
RC=1
fi
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
jq --raw-output \
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
lint.json || true
exit $RC
link-check:
uses: ./.github/workflows/_link_check.yml
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
android-java-format:
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 90
script: |
FILES_NEEDS_FORMAT=$(find extension/android/executorch_android/src/main/java/org/pytorch/executorch \
extension/android/executorch_android/src/main/java/org/pytorch/executorch/extension/llm \
extension/android/executorch_android/src/main/java/org/pytorch/executorch/annotations \
extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch \
extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench \
extension/benchmark/android/benchmark/app/src/androidTest/java/org/pytorch/minibench \
-type f -name "*.java" 2>/dev/null | \
xargs -r /opt/google-java-format -n)
if [ -n "$FILES_NEEDS_FORMAT" ]; then
echo "Warning: The following files need formatting:"
echo "$FILES_NEEDS_FORMAT"
echo ""
echo "Please use google-java-format from https://github.com/google/google-java-format/releases/"
echo ""
echo "To fix, run one of these commands:"
echo " # Using xargs (recommended):"
echo " find <paths> -type f -name '*.java' | xargs google-java-format -i"
echo ""
echo " # Or format specific files:"
echo "$FILES_NEEDS_FORMAT" | while IFS= read -r file; do
echo " google-java-format -i \"$file\""
done
exit 1
fi