Skip to content

Commit

Permalink
Make code quality workflow reusable (mosaicml#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-chu authored Jan 19, 2024
1 parent 1b393b6 commit 35015b7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
30 changes: 9 additions & 21 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
name: Code Quality Checks
on:
push:
branches:
- dev
- main
- release/**
pull_request:
workflow_call:
workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
inputs:
python_version:
required: true
type: string
pip_deps:
required: true
type: string
defaults:
run:
working-directory: .
jobs:
code-quality:
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
pip_deps:
- "[dev]"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
python-version: ${{ inputs.python_version }}
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
python -m pip install --upgrade .${{ matrix.pip_deps }}
python -m pip install --upgrade .${{ inputs.pip_deps }}
- name: Run checks
run: |
pre-commit run --all-files
27 changes: 27 additions & 0 deletions .github/workflows/pr-code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PR Code Quality Checks
on:
push:
branches:
- dev
- main
- release/**
pull_request:
workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
jobs:
code-quality:
uses: ./.github/workflows/code-quality.yaml
strategy:
matrix:
python_version:
- '3.8'
- '3.9'
- '3.10'
pip_deps:
- '[dev]'
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}

0 comments on commit 35015b7

Please sign in to comment.