<commit_before>name: test

on:
  push:
    branches: [main]
  pull_request:
  schedule:
    - cron: "0 5 * * *"
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-20.04

    strategy:
      matrix:
        python-version: [3.7, 3.8, 3.9]
        jupyter-version: ["5.6", "5.7", "5.*", "6.0", "6.1", "6.2", "6.3", "6.*"]

    # Can't use Minio official image because we can't specify the docker command in Github Actions
    # https://github.community/t5/GitHub-Actions/Job-service-command/m-p/33901
    # https://github.community/t5/GitHub-Actions/Specify-command-in-job-service-container/m-p/40616
    services:
      minio:
        image: getfider/minio:0.0.2
        # image: minio/minio:RELEASE.2018-06-29T02-11-29Z
        # command: server /export
        ports:
          - 9000:9000
          - 9001:9001
        env:
          MINIO_ACCESS_KEY: access-key
          MINIO_SECRET_KEY: secret-key
        volumes:
          - /tmp/tmp-data:/data

    steps:
      - uses: actions/checkout@v2
      - run: git fetch --prune --unshallow

      # ------------------------------------------------------------------------
      # Python env

      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: 1.2.0a2
          virtualenvs-create: true
          virtualenvs-in-project: true

      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.jupyter-version }}-${{ hashFiles('**/poetry.lock') }}

      - name: Install Python dependencies (notebook==${{ matrix.jupyter-version }})
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: |
          poetry install --no-interaction --no-root --with test
          source .venv/bin/activate
          pip install -U notebook==${{ matrix.jupyter-version }}
          pip freeze

      - name: Print Python info
        run: |
          source .venv/bin/activate
          which python
          python --version
          which pip
          pip --version

      # ------------------------------------------------------------------------
      # Test

      - name: Verify Minio
        run: |
          sudo mkdir -p /tmp/tmp-data/notebooks
          curl http://localhost:9000/<commit_msg>Fix coverage<commit_after>name: test

on:
  push:
    branches: [main]
  pull_request:
  schedule:
    - cron: "0 5 * * *"
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-20.04

    strategy:
      matrix:
        python-version: [3.7, 3.8, 3.9]
        jupyter-version: ["5.6", "5.7", "5.*", "6.0", "6.1", "6.2", "6.3", "6.*"]

    # Can't use Minio official image because we can't specify the docker command in Github Actions
    # https://github.community/t5/GitHub-Actions/Job-service-command/m-p/33901
    # https://github.community/t5/GitHub-Actions/Specify-command-in-job-service-container/m-p/40616
    services:
      minio:
        image: getfider/minio:0.0.2
        # image: minio/minio:RELEASE.2018-06-29T02-11-29Z
        # command: server /export
        ports:
          - 9000:9000
          - 9001:9001
        env:
          MINIO_ACCESS_KEY: access-key
          MINIO_SECRET_KEY: secret-key
        volumes:
          - /tmp/tmp-data:/data

    steps:
      - uses: actions/checkout@v2
      - run: git fetch --prune --unshallow

      # ------------------------------------------------------------------------
      # Python env

      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: 1.2.0a2
          virtualenvs-create: true
          virtualenvs-in-project: true

      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.jupyter-version }}-${{ hashFiles('**/poetry.lock') }}

      - name: Ensure cache is healthy
        if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
        run: poetry run python --version || rm -rf .venv

      - name: Install Python dependencies
        run: |
          poetry install --no-interaction --no-root
          source .venv/bin/activate
          pip install -U notebook==${{ matrix.jupyter-version }}
          pip freeze

      - name: Print Python info
        run: |
          source .venv/bin/activate
          which python
          python --version
          which pip
          pip --version

      # ------------------------------------------------------------------------
      # Test

      - name: Verify Minio
        run: |
          sudo mkdir -p /tmp/tmp-data/notebooks
          curl http://localhost:9000/
{'fraction_non_alphanumeric': 0.179612600273919, 'fraction_numerical': 0.03247896693406378, 'mean_word_length': 1.5058823529411764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1043809', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1556, 'n_words': 341}