<commit_before>name: CI

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  backend-cs-check:
    name: "Backend: PHP CS Fixer"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: OskarStark/php-cs-fixer-ga@2.17.0
        with:
          args: --dry-run --diff --config=backend/.php_cs

  frontend-eslint:
    name: "Frontend: ESLint"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: frontend

      - run: npm run lint
        working-directory: frontend

  print-eslint:
    name: "Print: ESLint"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: print

      - run: npm run lint
        working-directory: print

  backend-tests:
    name: "Backend: Tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - name: Get Composer Cache Directory
        id: composer-cache
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
        working-directory: backend

      - uses: actions/cache@v2
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-composer-

      - run: composer install --no-interaction
        working-directory: backend

      - run: composer test
        working-directory: backend

      - run: backend/vendor/bin/php-coveralls -v --coverage_clover backend/build/logs/clover.xml --json_path backend/build/logs/coveralls-upload.json
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: backend

  frontend-tests:
    name: "Frontend: Tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: frontend

      - run: npm run test:unit
        working-directory: frontend

      - run: cat frontend/data/coverage/lcov.info | npx coveralls .
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_SERVICE_NAME: github
          COVERALLS_SERVICE_NUMBER: ${{ github.run_id }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: frontend

  e2e-tests:
    name: "End-to-end tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - run: docker-compose up -d --build composer backend frontend db

      - run: bash wait-for-container-startup.sh

      - run: docker run -v $PWD:/e2e -w /e2e --network host -e CYPRESS_BASE_URL=http://localhost:3000 cypress/included:3.4.0
        working-directory: frontend

  coveralls-finished:
    name: "Finish coveralls report"
    needs:
      - backend-tests
      - frontend-tests
    runs-on: ubuntu-latest
    steps:

      - uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true

  ci-passed-event:
    name: "Send out CI success event"
    needs:
      - backend-cs-check
      - frontend-eslint
      - print-eslint
      - backend-tests
      - frontend-tests
      - e2e-tests
    runs-on: ubuntu-latest
    steps:

      - uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          event-type: ci-passed
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
<commit_msg>Add coveralls report for frontend to PRs<commit_after>name: CI

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  backend-cs-check:
    name: "Backend: PHP CS Fixer"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: OskarStark/php-cs-fixer-ga@2.17.0
        with:
          args: --dry-run --diff --config=backend/.php_cs

  frontend-eslint:
    name: "Frontend: ESLint"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: frontend

      - run: npm run lint
        working-directory: frontend

  print-eslint:
    name: "Print: ESLint"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: print

      - run: npm run lint
        working-directory: print

  backend-tests:
    name: "Backend: Tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - name: Get Composer Cache Directory
        id: composer-cache
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
        working-directory: backend

      - uses: actions/cache@v2
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-composer-

      - run: composer install --no-interaction
        working-directory: backend

      - run: composer test
        working-directory: backend

      - run: backend/vendor/bin/php-coveralls -v --coverage_clover backend/build/logs/clover.xml --json_path backend/build/logs/coveralls-upload.json
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: backend

  frontend-tests:
    name: "Frontend: Tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm install
        working-directory: frontend

      - run: npm run test:unit
        working-directory: frontend

      - run: cat frontend/data/coverage/lcov.info | npx coveralls .
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_SERVICE_NAME: github
          COVERALLS_SERVICE_NUMBER: ${{ github.run_id }}
          CI_PULL_REQUEST: ${{ github.event.number }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: frontend

  e2e-tests:
    name: "End-to-end tests"
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - run: docker-compose up -d --build composer backend frontend db

      - run: bash wait-for-container-startup.sh

      - run: docker run -v $PWD:/e2e -w /e2e --network host -e CYPRESS_BASE_URL=http://localhost:3000 cypress/included:3.4.0
        working-directory: frontend

  coveralls-finished:
    name: "Finish coveralls report"
    needs:
      - backend-tests
      - frontend-tests
    runs-on: ubuntu-latest
    steps:

      - uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true

  ci-passed-event:
    name: "Send out CI success event"
    needs:
      - backend-cs-check
      - frontend-eslint
      - print-eslint
      - backend-tests
      - frontend-tests
      - e2e-tests
    runs-on: ubuntu-latest
    steps:

      - uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          event-type: ci-passed
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

{'fraction_non_alphanumeric': 0.12922347362181388, 'fraction_numerical': 0.006164789567279194, 'mean_word_length': 1.9465595529165212, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6950162', 'n_tokens_mistral': 2867, 'n_tokens_neox': 2715, 'n_words': 568}