Github CI/CD Integration

If you are already running a CI/CD service on Github, it is easy to add Coderrect to your workflows. In a nutshell, add the following to .github/workflows/ci.yml

- name: coderrect setup
      run: |
        tar zxf coderrect-linux-hpc-0.9.1.tar.gz
        echo "$PWD/coderrect-linux-hpc-0.9.1/bin" >> $GITHUB_PATH
- name: make
      run: coderrect -analyzeAllBinaries make
- name: coderrect check
      run: coderrect -publishResults


Continuous Integration/Continuous Delivery (CI/CD) is a common practice now for developing software. In CI, typically tests and checks are run against every pull request and code commit to ensure the new code changes do not break anything or introduce new bugs. CI makes it easier to fix bugs quickly and often.

If your code is hosted on Github, you can create custom CI/CD workflows directly in your GitHub repository with GitHub Actions. All you need is to add a .yml file under .github/workflows/ of your Github repo.

As an example, Redis has a ci.yml file with the following content:

name: CI
on: [push, pull_request]
    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - name: make
      run: make
    - name: test
      run: |
        sudo apt-get install tcl8.5
        ./runtest --verbose
    - name: module api test
      run: ./runtest-moduleapi --verbose

With the configuration above, Github CI will build and test Redis upon every code push and pull request. If the build is successful and the tests are all passed, Github will show a green tick associated with the commit.

Otherwise, if the build or any test fails, you will see a red cross:

Integrating Coderrect into Github CI

To run coderrect in the Github CI, in ci.yml, simply add the following three steps:

# Step 1: download coderrect and add to path
- name: setup coderrect
      run: |
        tar zxf coderrect-linux-0.8.0.tar.gz
        echo "::add-path::$PWD/coderrect-linux-0.8.0/bin"
# Step 2: build and run coderrect
- name: make
      run: coderrect -analyzeAllBinaries make
# Step 3: coderrect results
- name: coderrect check
      run: coderrect -publishResults

In Step 1, coderrect is setup;

In Step 2, the flag -analyzeAllBinaries tells Coderrect to check all the build targets;

In Step 3, if any race is detected the results will be reported in the CI terminal. A red cross sign will be shown, indicating potential race hazards found by Coderrect:

To see the detailed race information, just click the arrow sign to expand it:

Cache the downloaded Coderrect

Coderrect only needs to be downloaded once for Github CI. To cache the downloaded Coderrect package, simply add the following to ci.yml.

    - name: cache coderrect
      id: cache-coderrect
      uses: actions/cache@v2
        path: coderrect-linux-0.8.0
        key: ${{ runner.os }}-coderrect

    - name: setup coderrect
      if: steps.cache-coderrect.outputs.cache-hit != 'true'

A full example is available at here.