<commit_before><commit_msg>Add bot for updating Galata tests automatically<commit_after>name: Update Galata References

on:
  issue_comment:
    types: [created, edited]

defaults:
  run:
    shell: bash -l {0}

jobs:
  update-reference-screenshots:
    name: Update Galata References
    if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update galata references') }}
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Checkout the branch from the PR that triggered the job
        run: hub pr checkout ${{ github.event.issue.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Setup conda
        uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: bqplot-test
          environment-file: test-environment.yml
          python-version: 3.9
          mamba-version: "*"
          auto-activate-base: false
          channels: conda-forge

      - name: Install bqplot
        run: pip install .

      - name: Install Galata
        run: |
          yarn install
          yarn playwright install chromium
        working-directory: ui-tests

      - name: Launch JupyterLab
        run: yarn run start:detached
        working-directory: ui-tests

      - name: Wait for JupyterLab
        uses: ifaxity/wait-on-action@v1
        with:
          resource: http-get://localhost:8888/api
          timeout: 20000

      - name: Generate updated Galata References
        run: yarn run test:update
        working-directory: ui-tests

      - name: Compress screenshots
        run: |
          sudo apt install optipng
          optipng *.png
        working-directory: ui-tests/tests/bqplot.test.ts-snapshots

      - name: Commit reference images
        run: |
          git config user.name 'github-actions[bot]'
          git config user.email '<EMAIL>[<EMAIL>'

          git pull

          git add ui-tests/tests/bqplot.test.ts-snapshots

          git commit -m "Update Galata References"
          git push
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

{'fraction_non_alphanumeric': 0.08811188811188811, 'fraction_numerical': 0.006993006993006993, 'mean_word_length': 2.0056022408963585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '7479095', 'n_tokens_mistral': 656, 'n_tokens_neox': 611, 'n_words': 166}