<commit_before>name: Continuous integration

on: [push, pull_request]
jobs:
  Test:
    runs-on: ubuntu-latest
    services:
      redis:
        image: redis
        # Set health checks to wait until redis has started
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 6379:6379
      # elasticsearch:
      #   image: elasticsearch:6.8.14
      #   options: >-
      #     --health-cmd "curl -f http://localhost:9200"
      #     --health-interval 10s
      #     --health-timeout 5s
      #     --health-retries 5
      #   ports:
      #     - 9200:9200
      #     - 9300:9300
      #   env:
      #     discovery.type: single-node
      postgres:
        image: postgis/postgis
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.7
      - name: Cache pip
        uses: actions/cache@v2.1.4
        with:
          path: ~/.cache/pip # This path is specific to Ubuntu
          # Look to see if there is a cache hit for the corresponding requirements file
          key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}-${{ hashFiles('requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
            ${{ runner.os }}-
      - name: Install python dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          python -m pip install -r dev-requirements.txt -r requirements.txt
      - name: Lint
        run: flake8 c2corg_api es_migration
      - name: Configure postgres
        run: |
          echo "create user \"www-data\" with password '<PASSWORD>'" | psql
          USER=github scripts/create_user_db_test.sh
        env:
          PGPASSWORD: <PASSWORD>
          PGUSER: postgres
          PGHOST: localhost
          PGPORT: 5432
      - name: Create config from templates
        run: make -f config/github-actions template
      - name: Install java 8 for (old) elasticsearch
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Run (old) elasticsearch
        run: |
          mkdir /tmp/elasticsearch
          wget -O - https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz | tar xz --directory=/tmp/elasticsearch --strip-components=1
          /tmp/elasticsearch/bin/elasticsearch --daemonize --path.data /tmp
          sleep 30 # ElasticSearch takes few seconds to start, make sure it is available when the build script runs
      - run: curl -v http://localhost:9200
      - name: Run tests
        run: pytest --cov-report term --cov-report xml --cov=c2corg_api
      - name: Send coverage to codacy
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: coverage.xml

  Docker:
    # only publish if tests passed
    needs: test
    # secrets are not available for PR from forks, and dependabot PRs, we don't want to build them
    if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    steps:
      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v2.3.0
        with:
          images: c2corg/v6_api
      - name: Checkout repository
        uses: actions/checkout@v2
      - run: git archive --format=tar --output project.tar "$GITHUB_SHA"
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Publish the docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.docker_meta.outputs.tags }}
          labels: ${{ steps.docker_meta.outputs.labels }}
          build-args: |
            VERSION=$GITHUB_SHA
<commit_msg>do not send coverage to codacy for dependabot or fork PRs<commit_after>name: Continuous integration

on: [push, pull_request]
jobs:
  Test:
    runs-on: ubuntu-latest
    services:
      redis:
        image: redis
        # Set health checks to wait until redis has started
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 6379:6379
      # elasticsearch:
      #   image: elasticsearch:6.8.14
      #   options: >-
      #     --health-cmd "curl -f http://localhost:9200"
      #     --health-interval 10s
      #     --health-timeout 5s
      #     --health-retries 5
      #   ports:
      #     - 9200:9200
      #     - 9300:9300
      #   env:
      #     discovery.type: single-node
      postgres:
        image: postgis/postgis
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.7
      - name: Cache pip
        uses: actions/cache@v2.1.4
        with:
          path: ~/.cache/pip # This path is specific to Ubuntu
          # Look to see if there is a cache hit for the corresponding requirements file
          key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}-${{ hashFiles('requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
            ${{ runner.os }}-
      - name: Install python dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          python -m pip install -r dev-requirements.txt -r requirements.txt
      - name: Lint
        run: flake8 c2corg_api es_migration
      - name: Configure postgres
        run: |
          echo "create user \"www-data\" with password '<PASSWORD>'" | psql
          USER=github scripts/create_user_db_test.sh
        env:
          PGPASSWORD: <PASSWORD>
          PGUSER: postgres
          PGHOST: localhost
          PGPORT: 5432
      - name: Create config from templates
        run: make -f config/github-actions template
      - name: Install java 8 for (old) elasticsearch
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Run (old) elasticsearch
        run: |
          mkdir /tmp/elasticsearch
          wget -O - https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz | tar xz --directory=/tmp/elasticsearch --strip-components=1
          /tmp/elasticsearch/bin/elasticsearch --daemonize --path.data /tmp
          sleep 30 # ElasticSearch takes few seconds to start, make sure it is available when the build script runs
      - run: curl -v http://localhost:9200
      - name: Run tests
        run: pytest --cov-report term --cov-report xml --cov=c2corg_api
      - name: Send coverage to codacy
        # secrets are not available for PR from forks, and dependabot PRs
        if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: coverage.xml

  Docker:
    # only publish if tests passed
    needs: test
    # secrets are not available for PR from forks, and dependabot PRs, we don't want to build them
    if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    steps:
      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v2.3.0
        with:
          images: c2corg/v6_api
      - name: Checkout repository
        uses: actions/checkout@v2
      - run: git archive --format=tar --output project.tar "$GITHUB_SHA"
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Publish the docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.docker_meta.outputs.tags }}
          labels: ${{ steps.docker_meta.outputs.labels }}
          build-args: |
            VERSION=$GITHUB_SHA

{'fraction_non_alphanumeric': 0.10519452292979788, 'fraction_numerical': 0.019995653118887197, 'mean_word_length': 1.836055469953775, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '887349', 'n_tokens_mistral': 2883, 'n_tokens_neox': 2714, 'n_words': 720}