adding midway day15 2018 python #93
This file contains 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
name: Lint | |
on: [push] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "2" | |
# Python linting (unchanged) | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Python dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pylint | |
- name: Get changed Python files | |
id: changed-python-files | |
run: | | |
echo "files=$(git diff --name-only HEAD^ HEAD --diff-filter=d '*.py')" >> $GITHUB_OUTPUT | |
- name: Analysing Python code with pylint | |
if: steps.changed-python-files.outputs.files != '' | |
run: | | |
pylint ${{ steps.changed-python-files.outputs.files }} --rcfile=.pylintrc | |
# Rust linting | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Cache Rust dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Get changed Rust files | |
id: changed-rust-files | |
run: | | |
echo "files=$(git diff --name-only HEAD^ HEAD --diff-filter=d '*.rs')" >> $GITHUB_OUTPUT | |
- name: Lint Rust code with clippy | |
if: steps.changed-rust-files.outputs.files != '' | |
run: | | |
for file in ${{ steps.changed-rust-files.outputs.files }}; do | |
directory=$(dirname "$file") | |
directory=$(echo "$directory" | cut -d '/' -f 1) # Extract the first level directory | |
(cd "$directory" && cargo clippy -- -D warnings) | |
done |