<commit_before>name: CI

on:
  push:
    branches:
      - '*'
    paths-ignore:
      - 'docs/**'
      - '**/*.md'
      - 'appveyor.xml'
  pull_request:
    branches:
      - '*'
    paths-ignore:
      - 'docs/**'
      - '**/*.md'
      - 'appveyor.xml'

# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
# GitHub Actions does not support Docker, PostgreSQL server on Windows, macOS :(

jobs:
  ubuntu-code-style:
    name: 'Ubuntu, code style (JDK 8)'
    runs-on: ubuntu-latest
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50

    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK 8'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: 8

    - name: 'Setup JDK 8 on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: '8'
        architecture: aarch64

    - uses: burrunan/gradle-cache-action@v1
      name: Verify code style
      env:
        S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
        S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        JAVA_HOME: ${{ steps.setup_jdk_arm64.outputs.JAVA_HOME_ARM64 }}
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: jdk8
        arguments: autostyleCheck checkstyleAll jandex

  ubuntu-latest:
    name: 'Ubuntu, PG latest (JDK ${{ matrix.jdk }}) running on ${{ matrix.os }}'
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        jdk: [8, 11]
        os:
          - ubuntu-latest
          - self-hosted
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
# Service must be started after checkout, because we want to use git-stored files for initialization
# of the Docker container. So we start it with and explicit docker ... command
#    services:
#      postgres:
#        image: postgres:latest
#        env:
#          POSTGRES_USER: postgres
#          # Empty password
#          # POSTGRES_PASSWORD: <PASSWORD>
#          POSTGRES_DB: postgres
#        ports:
#          - 5432:5432
#        volumes:
#          - /home/runner/work/pgjdbc/pgjdbc/.travis:/scripts/.travis
#        # needed because the postgres container does not provide a healthcheck
#        options: >-
#          --name db
#          --health-cmd pg_isready
#          --health-interval 10s
#          --health-timeout 5s
#          --health-retries 5
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50
    - name: Start PostgreSQL
      working-directory: docker
      run: docker-compose up -d && docker-compose logs

    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK ${{ matrix.jdk }}'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.jdk }}
        architecture: x64

    - name: 'Setup JDK ${{ matrix.jdk }} on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: ${{ matrix.jdk }}
        architecture: aarch64

    - name: Prepare ssltest.local.properties
      run: echo enable_ssl_tests=true > ssltest.local.properties
    - uses: burrunan/gradle-cache-action@v1
      name: Test
      env:
        S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
        S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: jdk${{ matrix.jdk }}
        arguments: --scan --no-parallel --no-daemon jandex test
        properties: |
          skipReplicationTests=
          port=${{ job.services.postgres.ports['5432'] }}

  linux-checkerframework:
    name: 'CheckerFramework (JDK 11)'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 50
      - name: 'Get test node ARCH'
        run: echo "::set-output name=arch_name::$(uname -i)"
        id: get_arch_name
      - name: 'Set up JDK 11'
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - uses: burrunan/gradle-cache-action@v1
        name: Run CheckerFramework
        env:
          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        with:
          read-only: ${{ matrix.os == 'self-hosted' }}
          job-id: checker-jdk11
          arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes

  source-distribution-check:
    name: 'Source distribution (JDK 11)'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 50
      - name: Start PostgreSQL
        working-directory: docker
        run: docker-compose up -d && docker-compose logs
      - name: 'Set up JDK 11'
        if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: 'Setup JDK 11 on ARM64'
        if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
        uses: AdoptOpenJDK/install-jdk@v1
        with:
          impl: hotspot # or openj9
          version: '11'
          architecture: aarch64

      - uses: burrunan/gradle-cache-action@v1
        name: Prepare source distribution
        env:
          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        with:
          read-only: ${{ matrix.os == 'self-hosted' }}
          job-id: source-release-jdk11
          arguments: --scan --no-parallel --no-daemon sourceDistribution -Ppgjdbc.version=1.0 -Prelease
      - name: Verify source distribution
        working-directory: pgjdbc/build/distributions
        run: |
          tar xzf postgresql-1.0-jdbc-src.tar.gz
          cd postgresql-1.0-jdbc-src
          mvn --batch-mode --fail-at-end --show-version verify

  gss-encryption:
    name: 'Ubuntu, gss encryption (JDK ${{matrix.jdk}}) running on ${{matrix.os}}'
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        jdk: [8, 11]
        os:
          - ubuntu-latest
          - self-hosted
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    steps:
    - uses: actions/checkout@v2
    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK 8'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: 8
    - name: 'Setup JDK 8 on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: '8'
        architecture: aarch64
    - name: 'Install software'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      run: |
        sudo apt -y update
        sudo apt -y install krb5-kdc krb5-admin-server libkrb5-dev postgresql-12
    - name: 'Update hosts'
      run: |
        sudo -- sh -c "echo 127.0.0.1 localhost auth-test-localhost.postgresql.example.com > /etc/hosts"
        cat /etc/hosts

    - uses: burrunan/gradle-cache-action@v1
      name: Build pgjdbc
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: gss-jdk8
        arguments: publishToMavenLocal -Ppgjdbc.version=1.0.0-dev-master -PskipJavadoc
    - name: Run tests
      run: |
        cd test-gss
        ./gradlew assemble
        ./gradlew run
<commit_msg>test: Disable self-hosted GitHub action runner execution on forks<commit_after>name: CI

on:
  push:
    branches:
      - '*'
    paths-ignore:
      - 'docs/**'
      - '**/*.md'
      - 'appveyor.xml'
  pull_request:
    branches:
      - '*'
    paths-ignore:
      - 'docs/**'
      - '**/*.md'
      - 'appveyor.xml'

# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
# GitHub Actions does not support Docker, PostgreSQL server on Windows, macOS :(

jobs:
  matrix_prep:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
    - id: set-matrix
      run: |
        node -p "
          '::set-output name=matrix::' + JSON.stringify({
            jdk: [
              8,
              11,
            ],
            os: [
              'ubuntu-latest',
              // Disable self-hosted on forks:
              ...(process.env.GITHUB_REPOSITORY === 'pgjdbc/pgjdbc' ? ['self-hosted'] : [])
            ],
          })"

  ubuntu-code-style:
    name: 'Ubuntu, code style (JDK 8)'
    runs-on: ubuntu-latest
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50

    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK 8'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: 8

    - name: 'Setup JDK 8 on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: '8'
        architecture: aarch64

    - uses: burrunan/gradle-cache-action@v1
      name: Verify code style
      env:
        S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
        S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        JAVA_HOME: ${{ steps.setup_jdk_arm64.outputs.JAVA_HOME_ARM64 }}
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: jdk8
        arguments: autostyleCheck checkstyleAll jandex

  ubuntu-latest:
    name: 'Ubuntu, PG latest (JDK ${{ matrix.jdk }}) running on ${{ matrix.os }}'
    runs-on: ${{ matrix.os }}
    needs: matrix_prep
    strategy:
      fail-fast: false
      matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
# Service must be started after checkout, because we want to use git-stored files for initialization
# of the Docker container. So we start it with and explicit docker ... command
#    services:
#      postgres:
#        image: postgres:latest
#        env:
#          POSTGRES_USER: postgres
#          # Empty password
#          # POSTGRES_PASSWORD: <PASSWORD>
#          POSTGRES_DB: postgres
#        ports:
#          - 5432:5432
#        volumes:
#          - /home/runner/work/pgjdbc/pgjdbc/.travis:/scripts/.travis
#        # needed because the postgres container does not provide a healthcheck
#        options: >-
#          --name db
#          --health-cmd pg_isready
#          --health-interval 10s
#          --health-timeout 5s
#          --health-retries 5
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50
    - name: Start PostgreSQL
      working-directory: docker
      run: docker-compose up -d && docker-compose logs

    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK ${{ matrix.jdk }}'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.jdk }}
        architecture: x64

    - name: 'Setup JDK ${{ matrix.jdk }} on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: ${{ matrix.jdk }}
        architecture: aarch64

    - name: Prepare ssltest.local.properties
      run: echo enable_ssl_tests=true > ssltest.local.properties
    - uses: burrunan/gradle-cache-action@v1
      name: Test
      env:
        S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
        S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: jdk${{ matrix.jdk }}
        arguments: --scan --no-parallel --no-daemon jandex test
        properties: |
          skipReplicationTests=
          port=${{ job.services.postgres.ports['5432'] }}

  linux-checkerframework:
    name: 'CheckerFramework (JDK 11)'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 50
      - name: 'Get test node ARCH'
        run: echo "::set-output name=arch_name::$(uname -i)"
        id: get_arch_name
      - name: 'Set up JDK 11'
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - uses: burrunan/gradle-cache-action@v1
        name: Run CheckerFramework
        env:
          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        with:
          read-only: ${{ matrix.os == 'self-hosted' }}
          job-id: checker-jdk11
          arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes

  source-distribution-check:
    name: 'Source distribution (JDK 11)'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 50
      - name: Start PostgreSQL
        working-directory: docker
        run: docker-compose up -d && docker-compose logs
      - name: 'Set up JDK 11'
        if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: 'Setup JDK 11 on ARM64'
        if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
        uses: AdoptOpenJDK/install-jdk@v1
        with:
          impl: hotspot # or openj9
          version: '11'
          architecture: aarch64

      - uses: burrunan/gradle-cache-action@v1
        name: Prepare source distribution
        env:
          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
        with:
          read-only: ${{ matrix.os == 'self-hosted' }}
          job-id: source-release-jdk11
          arguments: --scan --no-parallel --no-daemon sourceDistribution -Ppgjdbc.version=1.0 -Prelease
      - name: Verify source distribution
        working-directory: pgjdbc/build/distributions
        run: |
          tar xzf postgresql-1.0-jdbc-src.tar.gz
          cd postgresql-1.0-jdbc-src
          mvn --batch-mode --fail-at-end --show-version verify

  gss-encryption:
    name: 'Ubuntu, gss encryption (JDK ${{matrix.jdk}}) running on ${{matrix.os}}'
    runs-on: ${{ matrix.os }}
    needs: matrix_prep
    strategy:
      fail-fast: false
      matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
    env:
      ACTIONS_STEP_DEBUG: true
      ACTIONS_RUNNER_DEBUG: true
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    steps:
    - uses: actions/checkout@v2
    - name: 'Get test node ARCH'
      run: echo "::set-output name=arch_name::$(uname -i)"
      id: get_arch_name

    - name: 'Set up JDK 8'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      uses: actions/setup-java@v1
      with:
        java-version: 8
    - name: 'Setup JDK 8 on ARM64'
      if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
      uses: AdoptOpenJDK/install-jdk@v1
      with:
        impl: hotspot # or openj9
        version: '8'
        architecture: aarch64
    - name: 'Install software'
      if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
      run: |
        sudo apt -y update
        sudo apt -y install krb5-kdc krb5-admin-server libkrb5-dev postgresql-12
    - name: 'Update hosts'
      run: |
        sudo -- sh -c "echo 127.0.0.1 localhost auth-test-localhost.postgresql.example.com > /etc/hosts"
        cat /etc/hosts

    - uses: burrunan/gradle-cache-action@v1
      name: Build pgjdbc
      with:
        read-only: ${{ matrix.os == 'self-hosted' }}
        job-id: gss-jdk8
        arguments: publishToMavenLocal -Ppgjdbc.version=1.0.0-dev-master -PskipJavadoc
    - name: Run tests
      run: |
        cd test-gss
        ./gradlew assemble
        ./gradlew run

{'fraction_non_alphanumeric': 0.12130005803830528, 'fraction_numerical': 0.01839814277423099, 'mean_word_length': 2.1192976104272265, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 2, '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': '485536', 'n_tokens_mistral': 6171, 'n_tokens_neox': 5778, 'n_words': 1231}