<commit_before>name: Openfire CI

env:
  CI: true

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    name: Build Openfire from source
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 1.8, 11 ]

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - name: Cache Maven repository
        uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-java${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-java${{ matrix.java }}-maven-
            ${{ runner.os }}-
      - name: Build with Maven
        run: mvn -B package -Pcoverage --file pom.xml
      - name: Upload distribution
        uses: actions/upload-artifact@v1
        with:
          name: distribution-java${{ matrix.java }}
          path: distribution/target/distribution-base
      - name: Upload test files
        uses: actions/upload-artifact@v1
        with:
          name: test-files
          path: |
            runIntegrationTests
            runAioxmppIntegrationTests
            test.gradle
      - name: Upload coverage report for 'xmppserver' module
        if: ${{ matrix.java == 1.8 }}
        uses: actions/upload-artifact@v1
        with:
          name: Coverage Report for 'xmppserver' module
          path: xmppserver/target/site/jacoco/

  aioxmpp:

    name: Execute aioxmpp-based CI tests
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Download distribution artifact from build job.
        uses: actions/download-artifact@v1
        with:
          name: distribution-java1.8
          path: distribution
      - name: Setup environment for Openfire
        shell: bash
        run: |
          echo "127.0.0.1 example.org" | sudo tee -a /etc/hosts
      - name: Start Openfire
        shell: bash
        run: |
          sh ./distribution/bin/openfire.sh -demoboot &
      - name: Wait until Openfire is available
        shell: bash
        run: |
          until printf "" 2>>/dev/null >>/dev/tcp/localhost/7070; do sleep 0.3; done
      - name: Print success (replace this with running a test)
        shell: bash
        run: |
          echo "Successfully started Openfire"

      - name: Checkout aioxmpp
        uses: actions/checkout@v2
        with:
          repository: horazont/aioxmpp
          path: aioxmpp
          ref: devel
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.6
      - name: Install aioxmpp dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install nose
          python -m pip install -e aioxmpp
      - name: Generate Openfire test config
        run: |
          cat >"aioxmpp/openfire-config.ini" <<EOL
          [global]
          provisioner=aioxmpp.e2etest.provision.AnonymousProvisioner

          [aioxmpp.e2etest.provision.AnonymousProvisioner]
          domain=example.org
          host=localhost
          port=5222
          no_verify=true
          quirks=["https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#no-adhoc-ping", "https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#no-xep-0049", "https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#muc-no-333"]
          EOL
      - name: Create aioxmpp test script
        run: |
          cat >"runAioxmppTests.sh" <<'EOL'
          pushd aioxmpp
          mkdir output
          python -m aioxmpp.e2etest --e2etest-config="openfire-config.ini" --e2etest-only -e 'test_set_topic' -e 'test_publish_and_purge' -e 'test_publish_multiple_and_get_by_id' tests 2>&1 | tee output/aioxmpp.test.output.txt
          if [ ${PIPESTATUS[0]} -ne 0 ]; then false; fi;
          popd
          EOL

          chmod +x runAioxmppTests.sh
      - name: Run aioxmpp tests
        run: n=0; until [ "$n" -ge 3 ]; do ./runAioxmppTests.sh && break; n=$((n+1)); done # Try tests a few times, in case of flakiness
            
      - name: Expose test output
        uses: actions/upload-artifact@v1
        with:
          name: aioxmpp test output
          path: aioxmpp/output

      - name: Stop Openfire
        shell: bash
        run: |
          pkill -f openfire.lib

  smack:

    name: Execute Smack-based CI tests
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Download distribution artifact from build job.
        uses: actions/download-artifact@v1
        with:
          name: distribution-java1.8
          path: distribution/target/distribution-base
      - name: Download test files from build job.
        uses: actions/download-artifact@v1
        with:
          name: test-files
      - name: Set up Java
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - name: Fix file permissions
        run: |
          chmod +x distribution/target/distribution-base/bin/openfire.sh
          chmod +x ./runIntegrationTests
      - name: Run smack tests
        run: n=0; until [ "$n" -ge 3 ]; do ./runIntegrationTests -d -l -i 127.0.0.1 && break; n=$((n+1)); done # Try tests a few times, in case of flakiness

  publish:

    name: Publish to Maven
    runs-on: ubuntu-latest
    needs: [aioxmpp, smack]
    if: ${{github.ref == 'refs/heads/master' && github.event_name == 'push'}}

    steps:
      - uses: actions/checkout@v2
        with:
          # Defend against another commit quickly following the first
          # We want the one that's been tested, rather than the head of master
          ref: ${{ github.event.push.after }}
      - name: Cache Maven repository
        uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-java11-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-java11-maven-
            ${{ runner.os }}-
      - name: Set up Java for publishing
        uses: actions/setup-java@v1
        with:
          java-version: 11
          server-id: igniterealtime
          server-username: IGNITE_REALTIME_MAVEN_USERNAME
          server-password: <PASSWORD>
      - name: Publish
        run: mvn -B deploy
        env:
          IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
          IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
<commit_msg>Move to v2 of download/upload-artifact<commit_after>name: Openfire CI

env:
  CI: true

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    name: Build Openfire from source
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 1.8, 11 ]

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - name: Cache Maven repository
        uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-java${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-java${{ matrix.java }}-maven-
            ${{ runner.os }}-
      - name: Build with Maven
        run: mvn -B package -Pcoverage --file pom.xml
      - name: Upload distribution
        uses: actions/upload-artifact@v2
        with:
          name: distribution-java${{ matrix.java }}
          path: distribution/target/distribution-base
      - name: Upload test files
        uses: actions/upload-artifact@v2
        with:
          name: test-files
          path: |
            runIntegrationTests
            runAioxmppIntegrationTests
            test.gradle
      - name: Upload coverage report for 'xmppserver' module
        if: ${{ matrix.java == 1.8 }}
        uses: actions/upload-artifact@v2
        with:
          name: Coverage Report for 'xmppserver' module
          path: xmppserver/target/site/jacoco/

  aioxmpp:

    name: Execute aioxmpp-based CI tests
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Download distribution artifact from build job.
        uses: actions/download-artifact@v2
        with:
          name: distribution-java1.8
          path: distribution
      - name: Setup environment for Openfire
        shell: bash
        run: |
          echo "127.0.0.1 example.org" | sudo tee -a /etc/hosts
      - name: Start Openfire
        shell: bash
        run: |
          sh ./distribution/bin/openfire.sh -demoboot &
      - name: Wait until Openfire is available
        shell: bash
        run: |
          until printf "" 2>>/dev/null >>/dev/tcp/localhost/7070; do sleep 0.3; done
      - name: Print success (replace this with running a test)
        shell: bash
        run: |
          echo "Successfully started Openfire"

      - name: Checkout aioxmpp
        uses: actions/checkout@v2
        with:
          repository: horazont/aioxmpp
          path: aioxmpp
          ref: devel
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.6
      - name: Install aioxmpp dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install nose
          python -m pip install -e aioxmpp
      - name: Generate Openfire test config
        run: |
          cat >"aioxmpp/openfire-config.ini" <<EOL
          [global]
          provisioner=aioxmpp.e2etest.provision.AnonymousProvisioner

          [aioxmpp.e2etest.provision.AnonymousProvisioner]
          domain=example.org
          host=localhost
          port=5222
          no_verify=true
          quirks=["https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#no-adhoc-ping", "https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#no-xep-0049", "https://zombofant.net/xmlns/aioxmpp/e2etest/quirks#muc-no-333"]
          EOL
      - name: Create aioxmpp test script
        run: |
          cat >"runAioxmppTests.sh" <<'EOL'
          pushd aioxmpp
          mkdir output
          python -m aioxmpp.e2etest --e2etest-config="openfire-config.ini" --e2etest-only -e 'test_set_topic' -e 'test_publish_and_purge' -e 'test_publish_multiple_and_get_by_id' tests 2>&1 | tee output/aioxmpp.test.output.txt
          if [ ${PIPESTATUS[0]} -ne 0 ]; then false; fi;
          popd
          EOL

          chmod +x runAioxmppTests.sh
      - name: Run aioxmpp tests
        run: n=0; until [ "$n" -ge 3 ]; do ./runAioxmppTests.sh && break; n=$((n+1)); done # Try tests a few times, in case of flakiness
            
      - name: Expose test output
        uses: actions/upload-artifact@v2
        with:
          name: aioxmpp test output
          path: aioxmpp/output

      - name: Stop Openfire
        shell: bash
        run: |
          pkill -f openfire.lib

  smack:

    name: Execute Smack-based CI tests
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Download distribution artifact from build job.
        uses: actions/download-artifact@v2
        with:
          name: distribution-java1.8
          path: distribution/target/distribution-base
      - name: Download test files from build job.
        uses: actions/download-artifact@v2
        with:
          name: test-files
      - name: Set up Java
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - name: Fix file permissions
        run: |
          chmod +x distribution/target/distribution-base/bin/openfire.sh
          chmod +x ./runIntegrationTests
      - name: Run smack tests
        run: n=0; until [ "$n" -ge 3 ]; do ./runIntegrationTests -d -l -i 127.0.0.1 && break; n=$((n+1)); done # Try tests a few times, in case of flakiness

  publish:

    name: Publish to Maven
    runs-on: ubuntu-latest
    needs: [aioxmpp, smack]
    if: ${{github.ref == 'refs/heads/master' && github.event_name == 'push'}}

    steps:
      - uses: actions/checkout@v2
        with:
          # Defend against another commit quickly following the first
          # We want the one that's been tested, rather than the head of master
          ref: ${{ github.event.push.after }}
      - name: Cache Maven repository
        uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-java11-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-java11-maven-
            ${{ runner.os }}-
      - name: Set up Java for publishing
        uses: actions/setup-java@v1
        with:
          java-version: 11
          server-id: igniterealtime
          server-username: IGNITE_REALTIME_MAVEN_USERNAME
          server-password: <PASSWORD>REALTIME_MAVEN_PASSWORD
      - name: Publish
        run: mvn -B deploy
        env:
          IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
          IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}

{'fraction_non_alphanumeric': 0.10557768924302789, 'fraction_numerical': 0.01325467361323935, 'mean_word_length': 1.8669009444322424, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3221965', 'n_tokens_mistral': 4317, 'n_tokens_neox': 4058, 'n_words': 1044}