Skip to content

Set up pre-commit hooks and workflows to check code style #3

Set up pre-commit hooks and workflows to check code style

Set up pre-commit hooks and workflows to check code style #3

name: check_code_quality
on:
push:
branches: [ main ]
paths:
- "src/**.py"
- "test/**.py"
- "template/**.py"
pull_request:
branches: [ main ]
paths:
- "src/**.py"
- "test/**.py"
- "template/**.py"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Check Code Quality
runs-on: ubuntu-latest
if: github.repository == 'aws/sagemaker-distribution'
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./environment.yml
environment-name: sagemaker-distribution
init-shell: bash
- name: Free up disk space
run: rm -rf /opt/hostedtoolcache
- name: Activate sagemaker-distribution
run: micromamba activate sagemaker-distribution
- name: Check style with black
run: black --line-length=120 --check src test template
- name: Check style with autoflake
run: autoflake --in-place --expand-star-imports --ignore-init-module-imports --remove-all-unused-imports -rc src test template
- name: Check style with isort
run: isort --profile black -c src test template