Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reusable actions for linting #2948

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
name: Code Quality Checks
on:
workflow_call:
inputs:
python_version:
required: true
type: string
pip_deps:
required: true
type: string
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' }}
defaults:
run:
working-directory: .
jobs:
code-quality:
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
python_version:
- "3.9"
- "3.10"
- "3.11"
pip_deps:
- "[dev]"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Checkout
uses: actions/checkout@v3
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
python-version: ${{ inputs.python_version }}
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
python -m pip install --upgrade .${{ inputs.pip_deps }}
- name: Run checks
run: |
pre-commit run --all-files
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: v0.0.2
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/code-quality
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}
47 changes: 15 additions & 32 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,19 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a
# config file.
# By default, queries listed here will override any specified in a
# config file.
# Prefix the list here with "+" to use these queries and those in the
# config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually
# (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

# - run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: v0.0.2
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/codeql-analysis
with:
language: ${{ matrix.language }}
37 changes: 20 additions & 17 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,31 @@ on:
download-path:
required: true
type: string
secrets:
app_id:
required: true
private_key:
required: true
jobs:
coverage:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
pip install coverage[toml]==6.5.0
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.private_key }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: v0.0.2
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/coverage
with:
path: ${{ inputs.download-path }}
- name: Generate coverage report
run: |
set -ex
# Flatten the coverage files
ls ${{ inputs.download-path }} | while read x; do mv ${{ inputs.download-path }}/$x/.coverage .coverage.$x; done
python -m coverage combine
python -m coverage report
download-path: ${{ inputs.download-path }}
3 changes: 3 additions & 0 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ jobs:
needs: [daily-pytest-cpu]
with:
download-path: artifacts
secrets:
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}

daily-pytest-gpu:
uses: ./.github/workflows/pytest-gpu.yaml
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/pr-code-quality.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/pr-cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ jobs:
needs: [pytest-cpu]
with:
download-path: artifacts
secrets:
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
29 changes: 17 additions & 12 deletions .github/workflows/smoketest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@ jobs:
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Checkout
uses: actions/checkout@v3
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
python-version: ${{ matrix.python_version }}
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
python -m pip install --upgrade .
python -m pip install pytest==7.2.1 pytest_codeblocks==0.16.1
- name: Run checks
run: |
pytest tests/test_smoketest.py
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: v0.0.2
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/smoketest
with:
python_version: ${{ matrix.python_version }}
Loading