whylabs/whylogs-python

View on GitHub
.github/workflows/whylogs-ci.yml

Summary

Maintainability
Test Coverage
name: whylogs-ci

on:
  pull_request:
  push:
    branches: [mainline, 1.0.x]
    tags:
      - "[0-9]+.[0-9]+.[0-9]+*"

defaults:
  run:
    working-directory: python

env:
  CODECOV_UPLOAD: false
  POETRY_VERSION: "1.7.1"
  PROTOC_VERSION: "3.19.4"
  PYPI_PUBLISH: false
  HEAP_APPID_DEV: "3422045963"

jobs:
  python-ci:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

    steps:
      - uses: actions/checkout@v3
      - name: Install Poetry
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: ${{ env.POETRY_VERSION }}
      - name: Set up python with poetry cache
        uses: actions/setup-python@v4
        id: setup-python
        with:
          python-version: ${{ matrix.python-version }}
          cache: poetry
      - run: echo 'python ${{ matrix.python-version }} poetry cache hit ${{ steps.setup-python.outputs.cache-hit }}'

      - name: Set up pre-commit cache
        uses: actions/cache@v3
        if: startsWith(runner.os, 'Linux')
        with:
          path: ~/.cache/pre-commit
          key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
          restore-keys: ${{ runner.os }}-pre-commit-

      - name: Install Protoc
        uses: arduino/setup-protoc@v1
        with:
          version: ${{ env.PROTOC_VERSION }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Check Poetry version
        run: |
          POETRY_VERSION_INSTALLED=$(poetry -V)
          echo "The POETRY_VERSION environment variable is set to $POETRY_VERSION."
          echo "The installed Poetry version is $POETRY_VERSION_INSTALLED."
          case $POETRY_VERSION_INSTALLED in
          *$POETRY_VERSION*) echo "Poetry version correct." ;;
          *) echo "Poetry version incorrect." && exit 1 ;;
          esac

      - name: Install dependencies
        run: make telemetry-opt-out install

      - name: Check virtualenv location
        run: |
          EXPECTED_VIRTUALENV_PATH=${{ github.workspace }}/python/.venv
          INSTALLED_VIRTUALENV_PATH=$(poetry env info --path)
          echo "The virtualenv should be at $EXPECTED_VIRTUALENV_PATH."
          echo "Poetry is using a virtualenv at $INSTALLED_VIRTUALENV_PATH."
          case "$INSTALLED_VIRTUALENV_PATH" in
          "$EXPECTED_VIRTUALENV_PATH") echo "Correct Poetry virtualenv." ;;
          *) echo "Incorrect Poetry virtualenv." && exit 1 ;;
          esac

      - name: Run pre-commit checks
        if: ${{ matrix.python-version == 3.8 }}
        run: make pre-commit

      - name: Run build and test
        run: make test

      - name: Smoke test wheel in client environment
        run: |
          python -m venv verify
          source verify/bin/activate
          pip install --upgrade pip
          pip install dist/whylogs*.whl
          python tests/smoketest.py
          deactivate
          rm -rf verify

      - name: Upload test coverage report to Codecov
        uses: codecov/codecov-action@v2
        if: env.CODECOV_UPLOAD == 'true'
        with:
          fail_ci_if_error: true
          flags: unit

  java-ci:
    runs-on: [ubuntu-latest]
    defaults:
      run:
        shell: bash
        working-directory: java
    steps:
      - uses: actions/checkout@v3
      - name: Change to Java dir
        run: |
          echo $(pwd)
      - name: Setup Java 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Cache Gradle dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - uses: eskatos/gradle-command-action@v1
        with:
          build-root-directory: java
          arguments: build
      - name: Smoke test jar in client environment
        uses: gradle/gradle-build-action@v2
        with:
          build-root-directory: java/smoketest
          arguments: run
          gradle-executable: java/gradlew

  docs-ci:
    needs: python-ci

    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: ["3.9"]

    steps:
      - uses: actions/checkout@v3
      - name: Install Poetry
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: ${{ env.POETRY_VERSION }}
      - uses: actions/setup-python@v4
        id: docs
        with:
          python-version: ${{ matrix.python-version }}
          cache: poetry
      - run: echo 'cache hit ${{ steps.docs.outputs.cache-hit }}'
      - uses: nikeee/setup-pandoc@v1
      - name: Install Protoc
        uses: arduino/setup-protoc@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          version: ${{ env.PROTOC_VERSION }}

      - name: Install dependencies for generating docs
        run: poetry install --extras docs

      - name: Building docs with sphinx
        run: |
          make proto -B
          make docs

      - name: Set outputs
        id: vars
        run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
        if: ${{ github.ref != 'refs/heads/mainline' }}

      - name: Publish docs
        uses: JamesIves/github-pages-deploy-action@4.0.0
        with:
          branch: gh-pages
          folder: python/docs/_build/html
        if: ${{ github.ref == 'refs/heads/mainline' }}