Skip to content
Latchkey

CI Pipe workflow (candle-org/mindnlp)

The CI Pipe workflow from candle-org/mindnlp, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, run de-duplication, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: candle-org/mindnlp.github/workflows/ci_pipeline.yamlLicense Apache-2.0View source

What it does

This is the CI Pipe workflow from the candle-org/mindnlp repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI Pipe

on:
  pull_request:
    branches: [ "master" ]
    paths:
      - 'src/mindtorch_v2/**'
      - 'tests/mindtorch_v2/**'
      - '.github/workflows/**'
  push:
    branches: [ "master" ]
    paths:
      - 'src/mindtorch_v2/**'
      - 'tests/mindtorch_v2/**'
      - '.github/workflows/**'

permissions:
  contents: read

jobs:
  pylint-check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: 3.11
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip==24.0
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -r requirements/pylint_requirements.txt
    # - name: Install MindSpore
    #   shell: bash
    #   env:
    #     OS: ubuntu-latest
    #     PYTHON: 3.11
    #   run: |
    #     python .github/install_mindspore.py
    #     pip install -r download.txt
    - name: Analysing the mindtorch_v2 code with pylint
      run: |
        pylint --jobs=1 src/mindtorch_v2 --rcfile=.github/pylint.conf

  # ut-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       os: [ubuntu-latest, macos-latest, windows-latest]
  #       python: [3.11]
  #   runs-on: ${{ matrix.os }}
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: avoid macos error
  #     if: matrix.os == 'macos-latest'
  #     run: rm -rf $RUNNER_TOOL_CACHE/Python/3.8.17

  #   - name: Set up Python
  #     uses: actions/setup-python@v4
  #     with:
  #       python-version: ${{ matrix.python }}
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install -r requirements/requirements.txt
  #   # - name: Install MindSpore
  #   #   shell: bash
  #   #   env:
  #   #     OS: ${{ matrix.os }}
  #   #     PYTHON: ${{ matrix.python }}
  #   #   run: |
  #   #     python .github/install_mindspore.py
  #   #     pip install -r download.txt
  #   - name: Test with pytest
  #     run: |
  #       pytest -c pytest.ini -m 'not download and not gpu_only' --ignore=tests/transformers tests

  # release-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       ms_version: ['2.5.0', '2.6.0', '2.7.0']
  #   runs-on: ubuntu-latest
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: Set up Python
  #     uses: actions/setup-python@v4
  #     with:
  #       python-version: 3.11
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install -r requirements/requirements.txt
  #   # - name: Install MindSpore
  #   #   shell: bash
  #   #   run: |
  #   #     pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${{matrix.ms_version}}/MindSpore/unified/x86_64/mindspore-${{matrix.ms_version}}-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com
  #   - name: Test with pytest
  #     run: |
  #       pytest -c pytest.ini -m 'not download and not gpu_only' --ignore=tests/transformers tests
  #       # pytest -c pytest.ini -m 'not download and not gpu_only' tests

  # transformers-model-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       alpha: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
  #   runs-on: ubuntu-latest
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: Set up Python
  #     uses: actions/setup-python@v4
  #     with:
  #       python-version: 3.11
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install torch --index-url https://download.pytorch.org/whl/cpu
  #       pip install -r requirements/requirements.txt
  #   - name: Install MindSpore
  #     shell: bash
  #     env:
  #       OS: ubuntu-latest
  #       PYTHON: 3.11
  #     run: |
  #       pip install mindspore
  #   - name: Test with pytest
  #     run: |
  #       pip install transformers
  #       TRANSFORMERS_VERSION=$(python -c "import transformers; print(transformers.__version__)")
  #       echo "Installed transformers version: $TRANSFORMERS_VERSION"
  #       cd tests
  #       git clone -b v${TRANSFORMERS_VERSION} https://github.com/huggingface/transformers
  #       cd ..
  #       bash scripts/build_and_reinstall.sh
  #       python tests/run_test.py -vs tests/transformers/tests/models/${{ matrix.alpha }}*/test_modeling*

  mindtorch-v2-test:
    needs: pylint-check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: 3.11
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip==24.0
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -r requirements/requirements.txt
    - name: Install MindSpore
      shell: bash
      env:
        OS: ubuntu-latest
        PYTHON: 3.11
      run: |
        pip install mindspore
    - name: Test mindtorch_v2
      run: |
        cd tests/mindtorch_v2
        pytest . -v --tb=short \
          --ignore=test_ops_npu.py \
          --ignore=test_ddp.py \
          --ignore=test_ddp_cpu.py \
          --ignore=test_ddp_builtin_hooks.py \
          --ignore=test_ddp_comm_hook.py \
          --ignore=test_ddp_unused_params.py \
          --ignore=test_ddp_static_graph.py \
          --ignore=test_ddp_bucket_view.py \
          --ignore=test_gloo_ddp.py \
          --ignore=test_hccl_all_to_all_multicard.py

  kaggle-gpu-test:
    needs: pylint-check
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && github.repository_owner == 'mindspore-lab'
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.11
      uses: actions/setup-python@v4
      with:
        python-version: 3.11
    - uses: "lvyufeng/action-kaggle-gpu-test@latest"
      with:
        kaggle_username: "${{ secrets.KAGGLE_USERNAME }}"
        kaggle_key: "${{ secrets.KAGGLE_API_KEY }}"
        kernel_name: mindnlp
        kernel_job_file: .github/kaggle_gpu_test.py

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
 
name: CI Pipe
 
on:
  pull_request:
    branches: [ "master" ]
    paths:
      - 'src/mindtorch_v2/**'
      - 'tests/mindtorch_v2/**'
      - '.github/workflows/**'
  push:
    branches: [ "master" ]
    paths:
      - 'src/mindtorch_v2/**'
      - 'tests/mindtorch_v2/**'
      - '.github/workflows/**'
 
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pylint-check:
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        cache: 'pip'
        python-version: 3.11
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip==24.0
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -r requirements/pylint_requirements.txt
    # - name: Install MindSpore
    #   shell: bash
    #   env:
    #     OS: ubuntu-latest
    #     PYTHON: 3.11
    #   run: |
    #     python .github/install_mindspore.py
    #     pip install -r download.txt
    - name: Analysing the mindtorch_v2 code with pylint
      run: |
        pylint --jobs=1 src/mindtorch_v2 --rcfile=.github/pylint.conf
 
  # ut-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       os: [ubuntu-latest, macos-latest, windows-latest]
  #       python: [3.11]
  #   runs-on: ${{ matrix.os }}
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: avoid macos error
  #     if: matrix.os == 'macos-latest'
  #     run: rm -rf $RUNNER_TOOL_CACHE/Python/3.8.17
 
  #   - name: Set up Python
  #     uses: actions/setup-python@v4
        with:
          cache: 'pip'
  #     with:
  #       python-version: ${{ matrix.python }}
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install -r requirements/requirements.txt
  #   # - name: Install MindSpore
  #   #   shell: bash
  #   #   env:
  #   #     OS: ${{ matrix.os }}
  #   #     PYTHON: ${{ matrix.python }}
  #   #   run: |
  #   #     python .github/install_mindspore.py
  #   #     pip install -r download.txt
  #   - name: Test with pytest
  #     run: |
  #       pytest -c pytest.ini -m 'not download and not gpu_only' --ignore=tests/transformers tests
 
  # release-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       ms_version: ['2.5.0', '2.6.0', '2.7.0']
  #   runs-on: latchkey-small
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: Set up Python
  #     uses: actions/setup-python@v4
        with:
          cache: 'pip'
  #     with:
  #       python-version: 3.11
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install -r requirements/requirements.txt
  #   # - name: Install MindSpore
  #   #   shell: bash
  #   #   run: |
  #   #     pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${{matrix.ms_version}}/MindSpore/unified/x86_64/mindspore-${{matrix.ms_version}}-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com
  #   - name: Test with pytest
  #     run: |
  #       pytest -c pytest.ini -m 'not download and not gpu_only' --ignore=tests/transformers tests
  #       # pytest -c pytest.ini -m 'not download and not gpu_only' tests
 
  # transformers-model-test:
  #   needs: pylint-check
  #   strategy:
  #     matrix:
  #       alpha: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
  #   runs-on: latchkey-small
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: Set up Python
  #     uses: actions/setup-python@v4
        with:
          cache: 'pip'
  #     with:
  #       python-version: 3.11
  #   - name: Install dependencies
  #     run: |
  #       python -m pip install --upgrade pip==24.0
  #       pip install torch --index-url https://download.pytorch.org/whl/cpu
  #       pip install -r requirements/requirements.txt
  #   - name: Install MindSpore
  #     shell: bash
  #     env:
  #       OS: ubuntu-latest
  #       PYTHON: 3.11
  #     run: |
  #       pip install mindspore
  #   - name: Test with pytest
  #     run: |
  #       pip install transformers
  #       TRANSFORMERS_VERSION=$(python -c "import transformers; print(transformers.__version__)")
  #       echo "Installed transformers version: $TRANSFORMERS_VERSION"
  #       cd tests
  #       git clone -b v${TRANSFORMERS_VERSION} https://github.com/huggingface/transformers
  #       cd ..
  #       bash scripts/build_and_reinstall.sh
  #       python tests/run_test.py -vs tests/transformers/tests/models/${{ matrix.alpha }}*/test_modeling*
 
  mindtorch-v2-test:
    needs: pylint-check
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        cache: 'pip'
        python-version: 3.11
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip==24.0
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -r requirements/requirements.txt
    - name: Install MindSpore
      shell: bash
      env:
        OS: ubuntu-latest
        PYTHON: 3.11
      run: |
        pip install mindspore
    - name: Test mindtorch_v2
      run: |
        cd tests/mindtorch_v2
        pytest . -v --tb=short \
          --ignore=test_ops_npu.py \
          --ignore=test_ddp.py \
          --ignore=test_ddp_cpu.py \
          --ignore=test_ddp_builtin_hooks.py \
          --ignore=test_ddp_comm_hook.py \
          --ignore=test_ddp_unused_params.py \
          --ignore=test_ddp_static_graph.py \
          --ignore=test_ddp_bucket_view.py \
          --ignore=test_gloo_ddp.py \
          --ignore=test_hccl_all_to_all_multicard.py
 
  kaggle-gpu-test:
    needs: pylint-check
    runs-on: latchkey-small
    if: github.event_name == 'push' && github.repository_owner == 'mindspore-lab'
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.11
      uses: actions/setup-python@v4
      with:
        cache: 'pip'
        python-version: 3.11
    - uses: "lvyufeng/action-kaggle-gpu-test@latest"
      with:
        kaggle_username: "${{ secrets.KAGGLE_USERNAME }}"
        kaggle_key: "${{ secrets.KAGGLE_API_KEY }}"
        kernel_name: mindnlp
        kernel_job_file: .github/kaggle_gpu_test.py
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow