Skip to content

Commit

Permalink
T6789: Test changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
kumvijaya authored Oct 27, 2024
1 parent 4c250b7 commit 88a9bb8
Showing 1 changed file with 60 additions and 42 deletions.
102 changes: 60 additions & 42 deletions .github/workflows/check-unused-imports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,66 @@ jobs:
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
repository: ${{ github.event.pull_request.base.repo.full_name }}

- uses: dorny/paths-filter@v3
id: py-changes
with:
filters: |
src:
- 'src/**'

- name: Set up Python
if: steps.py-changes.outputs.src == 'true'
uses: actions/setup-python@v3
- name: Get changed files
id: changed-files
uses: actions/github-script@v4
with:
python-version: 3.11
script: |
const prNumber = context.payload.pull_request.number;
const { data: files } = await github.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
return files.map(file => file.filename).filter(file => file.endsWith('.py'));
- name: Print changed files
run: echo "Changed files: ${{ steps.changed-files.outputs.result }}"



# - uses: dorny/paths-filter@v3
# id: py-changes
# with:
# filters: |
# src:
# - 'src/**'

# - name: Set up Python
# if: steps.py-changes.outputs.src == 'true'
# uses: actions/setup-python@v3
# with:
# python-version: 3.11

- name: Install dependencies
if: steps.py-changes.outputs.src == 'true'
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Check unused imports (pylint)
if: steps.py-changes.outputs.src == 'true'
run: |
pylint_files=$(git ls-files *.py src/migration-scripts)
set +e
output=$(pylint --disable=all --enable=W0611 $pylint_files)
exit_code=$?
set -e
echo "$output"
run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message=":white_check_mark: No issues found in *unused-imports* check."
if [[ $exit_code -ne 0 ]]; then
message=":x: Issues found in *unused-imports* check. "
fi
echo "WORKFLOW_MESSAGE=${message}. Please refer the [workflow run]($run_url)" >> $GITHUB_ENV
exit $exit_code
- name: Add PR comment
if: ${{ always() && env.WORKFLOW_MESSAGE != '' }}
uses: mshick/add-pr-comment@v2
with:
message: |-
${{ env.WORKFLOW_MESSAGE }}
message-id: "UNUSED_IMPORTS_VALIDATION"
allow-repeats: false
# - name: Install dependencies
# if: steps.py-changes.outputs.src == 'true'
# run: |
# python -m pip install --upgrade pip
# pip install pylint

# - name: Check unused imports (pylint)
# if: steps.py-changes.outputs.src == 'true'
# run: |
# pylint_files=$(git ls-files *.py src/migration-scripts)
# set +e
# output=$(pylint --disable=all --enable=W0611 $pylint_files)
# exit_code=$?
# set -e
# echo "$output"
# run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# message=":white_check_mark: No issues found in *unused-imports* check."
# if [[ $exit_code -ne 0 ]]; then
# message=":x: Issues found in *unused-imports* check. "
# fi
# echo "WORKFLOW_MESSAGE=${message}. Please refer the [workflow run]($run_url)" >> $GITHUB_ENV
# exit $exit_code

# - name: Add PR comment
# if: ${{ always() && env.WORKFLOW_MESSAGE != '' }}
# uses: mshick/add-pr-comment@v2
# with:
# message: |-
# ${{ env.WORKFLOW_MESSAGE }}
# message-id: "UNUSED_IMPORTS_VALIDATION"
# allow-repeats: false

0 comments on commit 88a9bb8

Please sign in to comment.