Skip to content
Latchkey

CI Build Code Style workflow (alibaba/EasyRec)

The CI Build Code Style workflow from alibaba/EasyRec, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: alibaba/EasyRec.github/workflows/code_style.ymlLicense Apache-2.0View source

What it does

This is the CI Build Code Style workflow from the alibaba/EasyRec 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)
name: CI Build Code Style
on:
  pull_request:
    types: [opened, reopened, synchronize]

jobs:
  ci-test:
    runs-on: EasyRec-py37-tf25
    defaults:
      run:
        shell: bash {0}
    steps:
      - name: FetchCommit ${{ github.event.pull_request.head.sha }}
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          submodules: recursive

      - name: RunCiTest
        id: run_ci_test
        env:
          TEST_DEVICES: ""
          PULL_REQUEST_NUM: ${{ github.event.pull_request.number }}
        run: |
           source ~/.bashrc
           conda activate tf25_py3
           pre-commit run -a
           if [ $? -eq 0 ]
           then
             echo "ci_test_passed=1" >> $GITHUB_OUTPUT
           else
             pre-commit run -a
             if [ $? -eq 0 ]
             then
               echo "ci_test_passed=1" >> $GITHUB_OUTPUT
             else
               echo "ci_test_passed=0" >> $GITHUB_OUTPUT
             fi
           fi

      - name: SignalFail
        env:
          CI_TEST_PASSED: ${{steps.run_ci_test.outputs.ci_test_passed}}
        run: |
          echo "CI_TEST_PASSED=${CI_TEST_PASSED}"
          if [ $CI_TEST_PASSED -ne 1 ]
          then
            echo "code_style_test_failed, will exit"
            exit 1
          fi

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: CI Build Code Style
on:
  pull_request:
    types: [opened, reopened, synchronize]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  ci-test:
    timeout-minutes: 30
    runs-on: EasyRec-py37-tf25
    defaults:
      run:
        shell: bash {0}
    steps:
      - name: FetchCommit ${{ github.event.pull_request.head.sha }}
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          submodules: recursive
 
      - name: RunCiTest
        id: run_ci_test
        env:
          TEST_DEVICES: ""
          PULL_REQUEST_NUM: ${{ github.event.pull_request.number }}
        run: |
           source ~/.bashrc
           conda activate tf25_py3
           pre-commit run -a
           if [ $? -eq 0 ]
           then
             echo "ci_test_passed=1" >> $GITHUB_OUTPUT
           else
             pre-commit run -a
             if [ $? -eq 0 ]
             then
               echo "ci_test_passed=1" >> $GITHUB_OUTPUT
             else
               echo "ci_test_passed=0" >> $GITHUB_OUTPUT
             fi
           fi
 
      - name: SignalFail
        env:
          CI_TEST_PASSED: ${{steps.run_ci_test.outputs.ci_test_passed}}
        run: |
          echo "CI_TEST_PASSED=${CI_TEST_PASSED}"
          if [ $CI_TEST_PASSED -ne 1 ]
          then
            echo "code_style_test_failed, will exit"
            exit 1
          fi
 

What changed

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

Actions used in this workflow