From 61ca879e722afb879764c70f2921254f51577e4e Mon Sep 17 00:00:00 2001 From: Brian <23239305+b-chu@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:05:28 -0500 Subject: [PATCH] Use testing repo actions for linting (#3060) * Use testing repo actions (#2948) * Change to ci repo --- .github/workflows/code-quality.yaml | 50 ++++++++++++++++---------- .github/workflows/codeql-analysis.yml | 40 +++++---------------- .github/workflows/coverage.yaml | 25 +++++-------- .github/workflows/pr-code-quality.yaml | 28 --------------- .github/workflows/smoketest.yaml | 22 ++++++------ 5 files changed, 57 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/pr-code-quality.yaml diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml index 20bbf327b7..36a54ba9a3 100644 --- a/.github/workflows/code-quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -1,13 +1,17 @@ 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: . @@ -15,16 +19,24 @@ 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 composite run steps repository + uses: actions/checkout@v3 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 + repository: mosaicml/ci-testing + ref: v0.0.1 + path: ./ci-testing + - uses: ./ci-testing/.github/actions/code-quality + with: + python_version: ${{ matrix.python_version }} + pip_deps: ${{ matrix.pip_deps }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 151179d524..3f9a079918 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,36 +41,12 @@ 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 composite run steps repository + uses: actions/checkout@v3 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 + repository: mosaicml/ci-testing + ref: v0.0.1 + path: ./ci-testing + - uses: ./ci-testing/.github/actions/codeql-analysis + with: + language: ${{ matrix.language }} diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index f89d67ec39..7e8a05782c 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -12,21 +12,12 @@ jobs: 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 composite run steps repository + uses: actions/checkout@v3 + with: + repository: mosaicml/ci-testing + ref: v0.0.1 + path: ./ci-testing + - uses: ./ci-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 }} diff --git a/.github/workflows/pr-code-quality.yaml b/.github/workflows/pr-code-quality.yaml deleted file mode 100644 index 26d2546e75..0000000000 --- a/.github/workflows/pr-code-quality.yaml +++ /dev/null @@ -1,28 +0,0 @@ -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.9" - - "3.10" - - "3.11" - pip_deps: - - "[dev]" - with: - python_version: ${{ matrix.python_version }} - pip_deps: ${{ matrix.pip_deps }} diff --git a/.github/workflows/smoketest.yaml b/.github/workflows/smoketest.yaml index 429cc40b1d..566142511b 100644 --- a/.github/workflows/smoketest.yaml +++ b/.github/workflows/smoketest.yaml @@ -27,16 +27,14 @@ jobs: - "3.10" - "3.11" steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - name: Checkout + uses: actions/checkout@v3 + - name: Get composite run steps repository + uses: actions/checkout@v3 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 + repository: mosaicml/ci-testing + ref: v0.0.1 + path: ./ci-testing + - uses: ./ci-testing/.github/actions/smoketest + with: + python_version: ${{ matrix.python_version }}