Mars CI Core workflow (mars-project/mars)
The Mars CI Core workflow from mars-project/mars, explained and optimized by Latchkey.
CI health: A - excellent
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Mars CI Core workflow from the mars-project/mars 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
name: Mars CI Core
on:
push:
branches:
- '*'
pull_request:
types: ['opened', 'reopened', 'synchronize']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, 3.9-cython]
include:
- { os: ubuntu-latest, python-version: 3.9-cython, no-common-tests: 1,
no-deploy: 1, with-cython: 1 }
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up conda ${{ matrix.python-version }}
env:
PYTHON: ${{ matrix.python-version }}
shell: bash
run: |
source ./ci/install-conda.sh
python -m pip install --upgrade pip setuptools wheel coverage;
- name: Install dependencies
env:
WITH_HADOOP: ${{ matrix.with-hadoop }}
WITH_KUBERNETES: ${{ matrix.with-kubernetes }}
NO_COMMON_TESTS: ${{ matrix.no-common-tests }}
WITH_CYTHON: ${{ matrix.with-cython }}
shell: bash
run: |
source ./ci/reload-env.sh
export DEFAULT_VENV=$VIRTUAL_ENV
if [[ ! "$PYTHON" =~ "3.6" ]]; then
conda install -n test --quiet --yes -c conda-forge python=$PYTHON numba
fi
# todo remove this when fastparquet release new version
if [[ "$PYTHON" =~ "3.6" ]]; then
pip install numpy\<1.20.0
fi
source ./ci/rewrite-cov-config.sh
pip install numpy scipy cython oss2
pip install -e ".[dev,extra]"
pip install virtualenv flaky
if [ -z "$NO_COMMON_TESTS" ]; then
if [[ ! "$PYTHON" =~ "3.6" ]] && [[ ! "$PYTHON" =~ "3.9" ]]; then
pip install h5py zarr matplotlib prometheus-client requests
conda install -n test --quiet --yes -c conda-forge python=$PYTHON \
"tiledb-py>=0.4.3,<0.6.0" "tiledb<2.0.0" || true
fi
conda install -n test --quiet --yes -c pkgs/main python=$PYTHON certifi
fi
conda list -n test
- name: Test with pytest
env:
WITH_HADOOP: ${{ matrix.with-hadoop }}
WITH_KUBERNETES: ${{ matrix.with-kubernetes }}
WITH_CYTHON: ${{ matrix.with-cython }}
NO_COMMON_TESTS: ${{ matrix.no-common-tests }}
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION: 1
CHANGE_MINIKUBE_NONE_USER: true
shell: bash
run: |
source ./ci/reload-env.sh
source ./ci/run-tests.sh
coverage xml
- name: Report coverage data
shell: bash
run: |
bash <(curl -s https://codecov.io/bash)
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Mars CI Core on: push: branches: - '*' pull_request: types: ['opened', 'reopened', 'synchronize'] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] python-version: [3.7, 3.8, 3.9, 3.9-cython] include: - { os: ubuntu-latest, python-version: 3.9-cython, no-common-tests: 1, no-deploy: 1, with-cython: 1 } steps: - name: Check out code uses: actions/checkout@v2 with: fetch-depth: 2 - name: Set up conda ${{ matrix.python-version }} env: PYTHON: ${{ matrix.python-version }} shell: bash run: | source ./ci/install-conda.sh python -m pip install --upgrade pip setuptools wheel coverage; - name: Install dependencies env: WITH_HADOOP: ${{ matrix.with-hadoop }} WITH_KUBERNETES: ${{ matrix.with-kubernetes }} NO_COMMON_TESTS: ${{ matrix.no-common-tests }} WITH_CYTHON: ${{ matrix.with-cython }} shell: bash run: | source ./ci/reload-env.sh export DEFAULT_VENV=$VIRTUAL_ENV if [[ ! "$PYTHON" =~ "3.6" ]]; then conda install -n test --quiet --yes -c conda-forge python=$PYTHON numba fi # todo remove this when fastparquet release new version if [[ "$PYTHON" =~ "3.6" ]]; then pip install numpy\<1.20.0 fi source ./ci/rewrite-cov-config.sh pip install numpy scipy cython oss2 pip install -e ".[dev,extra]" pip install virtualenv flaky if [ -z "$NO_COMMON_TESTS" ]; then if [[ ! "$PYTHON" =~ "3.6" ]] && [[ ! "$PYTHON" =~ "3.9" ]]; then pip install h5py zarr matplotlib prometheus-client requests conda install -n test --quiet --yes -c conda-forge python=$PYTHON \ "tiledb-py>=0.4.3,<0.6.0" "tiledb<2.0.0" || true fi conda install -n test --quiet --yes -c pkgs/main python=$PYTHON certifi fi conda list -n test - name: Test with pytest env: WITH_HADOOP: ${{ matrix.with-hadoop }} WITH_KUBERNETES: ${{ matrix.with-kubernetes }} WITH_CYTHON: ${{ matrix.with-cython }} NO_COMMON_TESTS: ${{ matrix.no-common-tests }} NUMPY_EXPERIMENTAL_ARRAY_FUNCTION: 1 CHANGE_MINIKUBE_NONE_USER: true shell: bash run: | source ./ci/reload-env.sh source ./ci/run-tests.sh coverage xml - name: Report coverage data shell: bash run: | bash <(curl -s https://codecov.io/bash)
What changed
- Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 1 job (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.