<commit_before>name: 'CI'

on:
  push:
    branches:
    - dev
    - master
  pull_request:
    branches:
    - dev
    - master

env:
  TGS4_DOTNET_VERSION: 3.1.x
  TGS4_TEST_DISCORD_CHANNEL: ${{ secrets.DISCORD_CHANNEL_ID }}
  TGS4_TEST_DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
  TGS4_TEST_IRC_CHANNEL: ${{ secrets.IRC_CHANNEL }}
  TGS4_TEST_IRC_CONNECTION_STRING: ${{ secrets.IRC_CONNECTION_STRING }}
  TGS4_TEST_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  TGS4_RELEASE_NOTES_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  dmapi-build:
    name: Build DMAPI
    env:
      BYOND_MAJOR: 513
      BYOND_MINOR: 1527
    runs-on: ubuntu-latest
    steps:
    - name: Install x86 libc Dependencies
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install -y libc6-i386 libstdc++6:i386

    - name: Install BYOND
      if: steps.cache-byond.outputs.cache-hit != 'true'
      run: |
        echo "Setting up BYOND."
        mkdir -p "$HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}"
        cd "$HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}"
        curl "http://www.byond.com/download/build/${{ env.BYOND_MAJOR }}/${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}_byond_linux.zip" -o byond.zip
        unzip byond.zip
        cd byond
        make here
        exit 0

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build DMAPI Test Project
      run: |
        set -e
        retval=1
        source $HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}/byond/bin/byondsetup

        if hash DreamMaker 2>/dev/null
        then
          DreamMaker tests/DMAPI/BasicOperation/basic_operation_test.dme 2>&1 | tee result.log
          retval=$?
          if ! grep '\- 0 errors, 0 warnings' result.log
          then
            retval=1
          fi
        else
          echo "Couldn't find the DreamMaker executable, aborting."
          retval=2
        fi
        exit $retval

  dox-build:
    name: Build Doxygen Site
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Patch Doxyfile
        run: |
          VERSION=$(cat "build/Version.props" | grep -oPm1 "(?<=<TgsCoreVersion>)[^<]+")
          echo -e "\nPROJECT_NUMBER = $VERSION\nINPUT = .\nOUTPUT_DIRECTORY = ./doxout\nPROJECT_LOGO = ./build/tgs.ico\nHAVE_DOT=YES" >> "docs/Doxyfile"

      - name: Doxygen Build
        uses: mattnotmitt/doxygen-action@v1
        with:
          doxyfile-path: 'docs/Doxyfile'

      - name: gh-pages push
        if: github.event_name == 'push' && github.event.ref == 'refs/heads/dev'
        run: |
          git clone -b gh-pages --single-branch "https://git@github.com/tgstation/tgstation-server" $HOME/tgsdox
          pushd $HOME/tgsdox
          rm -r *
          popd
          echo ./doxout/* | xargs -n 10 sudo mv -t $HOME/tgsdox
          cd $HOME/tgsdox
          git config --global push.default simple
          git config user.name "tgstation-server"
          git config user.email "<EMAIL>"
          echo '# THIS BRANCH IS AUTO GENERATED BY GITHUB ACTIONS' > README.md

          # Need to create a .nojekyll file to allow filenames starting with an underscore
          # to be seen on the gh-pages site. Therefore creating an empty .nojekyll file.
          echo "" > .nojekyll
          echo "Adding files..."
          git add --all
          echo "Committing..."
          git diff-index --quiet HEAD || git commit -m "Deploy code docs to GitHub Pages for workflow run ${{ github.run_number }}" -m "Commit: ${{ github.event.head_commit.id }}"
          echo "Pushing..."
          git push -f "https://${{ secrets.DEV_PUSH_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1

  docker-build:
    name: Build Docker Image
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Build Docker Image
      run: docker build . -f build/Dockerfile

  linux-unit-tests:
    name: Linux Unit Tests
    strategy:
      matrix:
        configuration: [ 'Debug', 'Release' ]
    runs-on: ubuntu-latest
    steps:
    - name: Install Node 12.X
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}NoService

    - name: Run Unit Tests
      run: sudo dotnet test tgstation-server.sln --no-build --filter FullyQualifiedName!~IntegrationTest -l "console;verbosity=detailed;noprogress=true" -c ${{ matrix.configuration }}NoService --collect:"XPlat Code Coverage" --settings build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: linux-unit-test-coverage-${{ matrix.configuration }}
        path: ./TestResults/

  windows-unit-tests:
    name: Windows Unit Tests
    strategy:
      matrix:
        configuration: [ 'Debug', 'Release' ]
    runs-on: windows-latest
    steps:
    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}

    - name: Run Unit Tests
      run: dotnet test tgstation-server.sln --no-build --filter FullyQualifiedName!~IntegrationTest -l "console;verbosity=detailed;noprogress=true" -c ${{ matrix.configuration }} --collect:"XPlat Code Coverage" --settings build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: windows-unit-test-coverage-${{ matrix.configuration }}
        path: ./TestResults/

  windows-integration-test:
    name: Windows Integration Test
    needs: dmapi-build
    env:
      TGS4_TEST_DATABASE_TYPE: SqlServer
      TGS4_TEST_DUMP_API_SPEC: yes
    strategy:
      matrix:
        watchdog-type: [ 'Basic', 'System' ]
        configuration: [ 'Debug', 'Release' ]
    runs-on: windows-latest
    steps:
    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Set General__UseBasicWatchdog
      if: ${{ matrix.watchdog-type == 'Basic' }}
      run: echo "General__UseBasicWatchdog=true" >> $env:GITHUB_ENV

    - name: Set TGS4_TEST_CONNECTION_STRING
      shell: bash
      run: |
        TGS4_CONNSTRING_VALUE="Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Initial Catalog=TGS_${{ matrix.watchdog-type }}_${{ matrix.configuration }};Application Name=tgstation-server"
        echo "TGS4_TEST_CONNECTION_STRING=$(echo $TGS4_CONNSTRING_VALUE)" >> $GITHUB_ENV

    - name: Checkout
      uses: actions/checkout@v1

    - name: Set TGS4_TEST_PULL_REQUEST_NUMBER
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_TEST_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $env:GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for PR
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_GITHUB_REF=${{ github.base_ref }}" >> $env:GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for push
      if: ${{ github.event_name == 'push' }}
      shell: bash
      run: |
        TEMP_GITHUB_REF="${{ github.event.ref }}"
        echo "TGS4_GITHUB_REF=${TEMP_GITHUB_REF##*/}" >> $env:GITHUB_ENV

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}

    - name: Run Integration Test
      run: |
        cd tests/Tgstation.Server.Tests
        Start-Sleep -Seconds 10
        dotnet test -c ${{ matrix.configuration }} --no-build "console;verbosity=detailed;noprogress=true" --collect:"XPlat Code Coverage" --settings ../../build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: windows-integration-test-coverage-${{ matrix.configuration }}-${{ matrix.watchdog-type }}
        path: tests/Tgstation.Server.Tests/TestResults/

    - name: Store OpenAPI Spec
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' }}
      uses: actions/upload-artifact@v2
      with:
        name: openapi-spec
        path: C:/swagger.json

    - name: Package Server Service
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }}
      run: |
        cd src/Tgstation.Server.Host.Service
        dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Service
        cd ../Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/Service/lib/Default

    - name: Store Server Service
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }}
      uses: actions/upload-artifact@v2
      with:
        name: ServerService
        path: Artifacts/Service/

  linux-integration-tests:
    name: Linux Integration Test
    needs: dmapi-build
    services: # We start all dbs here so we can just code the stuff once
      postgres:
        image: postgres
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
      mariadb:
        image: mariadb
        ports:
          - 3306:3306
        env:
          MYSQL_ROOT_PASSWORD: <PASSWORD>
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=5s
          --health-timeout=2s
          --health-retries=3
      mysql:
        image: mysql:5.7.31
        ports:
          - 3307:3306
        env:
          MYSQL_ROOT_PASSWORD: <PASSWORD>
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=3
    strategy:
      matrix:
        database-type: [ 'Sqlite', 'PostgresSql', 'MariaDB', 'MySql' ]
        watchdog-type: [ 'Basic', 'System' ]
        configuration: [ 'Debug', 'Release' ]
    runs-on: ubuntu-latest
    steps:
    - name: Disable ptrace_scope
      run: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

    - name: Install Native Dependencies
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install -y libc6-i386 libstdc++6:i386 gdb

    - name: Install Node 12.X
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Set Sqlite Connection Info
      if: ${{ matrix.database-type == 'Sqlite' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=Sqlite" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Data Source=TGS_${{ matrix.watchdog-type }}_${{ matrix.configuration }}.sqlite3;Mode=ReadWriteCreate" >> $GITHUB_ENV

    - name: Set PostgresSql Connection Info
      if: ${{ matrix.database-type == 'PostgresSql' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=PostgresSql" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Application Name=tgstation-server;Host=127.0.0.1;Username=postgres;Password=<PASSWORD>;Database=TGS__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV

    - name: Set MariaDB Connection Info
      if: ${{ matrix.database-type == 'MariaDB' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=MariaDB" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Server=127.0.0.1;uid=root;pwd=<PASSWORD>;database=tgs__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV

    - name: Set MySQL Connection Info
      if: ${{ matrix.database-type == 'MySql' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=MySql" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Server=127.0.0.1;Port=3307;uid=root;pwd=<PASSWORD>;database=tgs__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV
        echo "Database__ServerVersion=5.7.31" >> $GITHUB_ENV

    - name: Set General__UseBasicWatchdog
      if: ${{ matrix.watchdog-type == 'Basic' }}
      run: echo "General__UseBasicWatchdog=true" >> $GITHUB_ENV

    - name: Checkout
      uses: actions/checkout@v1

    - name: Set TGS4_TEST_PULL_REQUEST_NUMBER
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_TEST_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for PR
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_GITHUB_REF=${{ github.base_ref }}" >> $GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for push
      if: ${{ github.event_name == 'push' }}
      shell: bash
      run: |
        TEMP_GITHUB_REF="${{ github.event.ref }}"
        echo "TGS4_GITHUB_REF=${TEMP_GITHUB_REF##*/}" >> $GITHUB_ENV

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}

    - name: Run Integration Test
      run: |
        cd tests/Tgstation.Server.Tests
        sleep 10
        dotnet test -c ${{ matrix.configuration }} --no-build -l "console;verbosity=detailed;noprogress=true" --collect:"XPlat Code Coverage" --settings ../../build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: linux-integration-test-coverage-${{ matrix.configuration }}-${{ matrix.watchdog-type }}-${{ matrix.database-type }}
        path: tests/Tgstation.Server.Tests/TestResults/

    - name: Package Server Console
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }}
      run: |
        cd src/Tgstation.Server.Host.Console
        dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Console
        cd ../Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/Console/lib/Default

    - name: Package Server Update Package
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }}
      run: |
        cd src/Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/ServerUpdate

    - name: Store Server Console
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }}
      uses: actions/upload-artifact@v2
      with:
        name: ServerConsole
        path: Artifacts/Console/

    - name: Store Server Update Package
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }}<commit_msg>Readd "NoService" specifier to Linux build configs<commit_after>name: 'CI'

on:
  push:
    branches:
    - dev
    - master
  pull_request:
    branches:
    - dev
    - master

env:
  TGS4_DOTNET_VERSION: 3.1.x
  TGS4_TEST_DISCORD_CHANNEL: ${{ secrets.DISCORD_CHANNEL_ID }}
  TGS4_TEST_DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
  TGS4_TEST_IRC_CHANNEL: ${{ secrets.IRC_CHANNEL }}
  TGS4_TEST_IRC_CONNECTION_STRING: ${{ secrets.IRC_CONNECTION_STRING }}
  TGS4_TEST_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  TGS4_RELEASE_NOTES_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  dmapi-build:
    name: Build DMAPI
    env:
      BYOND_MAJOR: 513
      BYOND_MINOR: 1527
    runs-on: ubuntu-latest
    steps:
    - name: Install x86 libc Dependencies
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install -y libc6-i386 libstdc++6:i386

    - name: Install BYOND
      if: steps.cache-byond.outputs.cache-hit != 'true'
      run: |
        echo "Setting up BYOND."
        mkdir -p "$HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}"
        cd "$HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}"
        curl "http://www.byond.com/download/build/${{ env.BYOND_MAJOR }}/${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}_byond_linux.zip" -o byond.zip
        unzip byond.zip
        cd byond
        make here
        exit 0

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build DMAPI Test Project
      run: |
        set -e
        retval=1
        source $HOME/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }}/byond/bin/byondsetup

        if hash DreamMaker 2>/dev/null
        then
          DreamMaker tests/DMAPI/BasicOperation/basic_operation_test.dme 2>&1 | tee result.log
          retval=$?
          if ! grep '\- 0 errors, 0 warnings' result.log
          then
            retval=1
          fi
        else
          echo "Couldn't find the DreamMaker executable, aborting."
          retval=2
        fi
        exit $retval

  dox-build:
    name: Build Doxygen Site
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Patch Doxyfile
        run: |
          VERSION=$(cat "build/Version.props" | grep -oPm1 "(?<=<TgsCoreVersion>)[^<]+")
          echo -e "\nPROJECT_NUMBER = $VERSION\nINPUT = .\nOUTPUT_DIRECTORY = ./doxout\nPROJECT_LOGO = ./build/tgs.ico\nHAVE_DOT=YES" >> "docs/Doxyfile"

      - name: Doxygen Build
        uses: mattnotmitt/doxygen-action@v1
        with:
          doxyfile-path: 'docs/Doxyfile'

      - name: gh-pages push
        if: github.event_name == 'push' && github.event.ref == 'refs/heads/dev'
        run: |
          git clone -b gh-pages --single-branch "https://git@github.com/tgstation/tgstation-server" $HOME/tgsdox
          pushd $HOME/tgsdox
          rm -r *
          popd
          echo ./doxout/* | xargs -n 10 sudo mv -t $HOME/tgsdox
          cd $HOME/tgsdox
          git config --global push.default simple
          git config user.name "tgstation-server"
          git config user.email "<EMAIL>"
          echo '# THIS BRANCH IS AUTO GENERATED BY GITHUB ACTIONS' > README.md

          # Need to create a .nojekyll file to allow filenames starting with an underscore
          # to be seen on the gh-pages site. Therefore creating an empty .nojekyll file.
          echo "" > .nojekyll
          echo "Adding files..."
          git add --all
          echo "Committing..."
          git diff-index --quiet HEAD || git commit -m "Deploy code docs to GitHub Pages for workflow run ${{ github.run_number }}" -m "Commit: ${{ github.event.head_commit.id }}"
          echo "Pushing..."
          git push -f "https://${{ secrets.DEV_PUSH_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1

  docker-build:
    name: Build Docker Image
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Build Docker Image
      run: docker build . -f build/Dockerfile

  linux-unit-tests:
    name: Linux Unit Tests
    strategy:
      matrix:
        configuration: [ 'Debug', 'Release' ]
    runs-on: ubuntu-latest
    steps:
    - name: Install Node 12.X
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}NoService

    - name: Run Unit Tests
      run: sudo dotnet test tgstation-server.sln --no-build --filter FullyQualifiedName!~IntegrationTest -l "console;verbosity=detailed;noprogress=true" -c ${{ matrix.configuration }}NoService --collect:"XPlat Code Coverage" --settings build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: linux-unit-test-coverage-${{ matrix.configuration }}
        path: ./TestResults/

  windows-unit-tests:
    name: Windows Unit Tests
    strategy:
      matrix:
        configuration: [ 'Debug', 'Release' ]
    runs-on: windows-latest
    steps:
    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Checkout
      uses: actions/checkout@v1

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}

    - name: Run Unit Tests
      run: dotnet test tgstation-server.sln --no-build --filter FullyQualifiedName!~IntegrationTest -l "console;verbosity=detailed;noprogress=true" -c ${{ matrix.configuration }} --collect:"XPlat Code Coverage" --settings build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: windows-unit-test-coverage-${{ matrix.configuration }}
        path: ./TestResults/

  windows-integration-test:
    name: Windows Integration Test
    needs: dmapi-build
    env:
      TGS4_TEST_DATABASE_TYPE: SqlServer
      TGS4_TEST_DUMP_API_SPEC: yes
    strategy:
      matrix:
        watchdog-type: [ 'Basic', 'System' ]
        configuration: [ 'Debug', 'Release' ]
    runs-on: windows-latest
    steps:
    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Set General__UseBasicWatchdog
      if: ${{ matrix.watchdog-type == 'Basic' }}
      run: echo "General__UseBasicWatchdog=true" >> $env:GITHUB_ENV

    - name: Set TGS4_TEST_CONNECTION_STRING
      shell: bash
      run: |
        TGS4_CONNSTRING_VALUE="Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Initial Catalog=TGS_${{ matrix.watchdog-type }}_${{ matrix.configuration }};Application Name=tgstation-server"
        echo "TGS4_TEST_CONNECTION_STRING=$(echo $TGS4_CONNSTRING_VALUE)" >> $GITHUB_ENV

    - name: Checkout
      uses: actions/checkout@v1

    - name: Set TGS4_TEST_PULL_REQUEST_NUMBER
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_TEST_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $env:GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for PR
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_GITHUB_REF=${{ github.base_ref }}" >> $env:GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for push
      if: ${{ github.event_name == 'push' }}
      shell: bash
      run: |
        TEMP_GITHUB_REF="${{ github.event.ref }}"
        echo "TGS4_GITHUB_REF=${TEMP_GITHUB_REF##*/}" >> $env:GITHUB_ENV

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}

    - name: Run Integration Test
      run: |
        cd tests/Tgstation.Server.Tests
        Start-Sleep -Seconds 10
        dotnet test -c ${{ matrix.configuration }} --no-build "console;verbosity=detailed;noprogress=true" --collect:"XPlat Code Coverage" --settings ../../build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: windows-integration-test-coverage-${{ matrix.configuration }}-${{ matrix.watchdog-type }}
        path: tests/Tgstation.Server.Tests/TestResults/

    - name: Store OpenAPI Spec
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' }}
      uses: actions/upload-artifact@v2
      with:
        name: openapi-spec
        path: C:/swagger.json

    - name: Package Server Service
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }}
      run: |
        cd src/Tgstation.Server.Host.Service
        dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Service
        cd ../Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/Service/lib/Default

    - name: Store Server Service
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }}
      uses: actions/upload-artifact@v2
      with:
        name: ServerService
        path: Artifacts/Service/

  linux-integration-tests:
    name: Linux Integration Test
    needs: dmapi-build
    services: # We start all dbs here so we can just code the stuff once
      postgres:
        image: postgres
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
      mariadb:
        image: mariadb
        ports:
          - 3306:3306
        env:
          MYSQL_ROOT_PASSWORD: <PASSWORD>
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=5s
          --health-timeout=2s
          --health-retries=3
      mysql:
        image: mysql:5.7.31
        ports:
          - 3307:3306
        env:
          MYSQL_ROOT_PASSWORD: <PASSWORD>
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=3
    strategy:
      matrix:
        database-type: [ 'Sqlite', 'PostgresSql', 'MariaDB', 'MySql' ]
        watchdog-type: [ 'Basic', 'System' ]
        configuration: [ 'Debug', 'Release' ]
    runs-on: ubuntu-latest
    steps:
    - name: Disable ptrace_scope
      run: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

    - name: Install Native Dependencies
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install -y libc6-i386 libstdc++6:i386 gdb

    - name: Install Node 12.X
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.TGS4_DOTNET_VERSION }}

    - name: Set Sqlite Connection Info
      if: ${{ matrix.database-type == 'Sqlite' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=Sqlite" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Data Source=TGS_${{ matrix.watchdog-type }}_${{ matrix.configuration }}.sqlite3;Mode=ReadWriteCreate" >> $GITHUB_ENV

    - name: Set PostgresSql Connection Info
      if: ${{ matrix.database-type == 'PostgresSql' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=PostgresSql" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Application Name=tgstation-server;Host=127.0.0.1;Username=postgres;Password=<PASSWORD>;Database=TGS__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV

    - name: Set MariaDB Connection Info
      if: ${{ matrix.database-type == 'MariaDB' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=MariaDB" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Server=127.0.0.1;uid=root;pwd=m<PASSWORD>;database=tgs__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV

    - name: Set MySQL Connection Info
      if: ${{ matrix.database-type == 'MySql' }}
      run: |
        echo "TGS4_TEST_DATABASE_TYPE=MySql" >> $GITHUB_ENV
        echo "TGS4_TEST_CONNECTION_STRING=Server=127.0.0.1;Port=3307;uid=root;pwd=<PASSWORD>;database=tgs__${{ matrix.watchdog-type }}_${{ matrix.configuration }}" >> $GITHUB_ENV
        echo "Database__ServerVersion=5.7.31" >> $GITHUB_ENV

    - name: Set General__UseBasicWatchdog
      if: ${{ matrix.watchdog-type == 'Basic' }}
      run: echo "General__UseBasicWatchdog=true" >> $GITHUB_ENV

    - name: Checkout
      uses: actions/checkout@v1

    - name: Set TGS4_TEST_PULL_REQUEST_NUMBER
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_TEST_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for PR
      if: ${{ github.event_name == 'pull_request' }}
      run: echo "TGS4_GITHUB_REF=${{ github.base_ref }}" >> $GITHUB_ENV

    - name: Set TGS4_GITHUB_REF for push
      if: ${{ github.event_name == 'push' }}
      shell: bash
      run: |
        TEMP_GITHUB_REF="${{ github.event.ref }}"
        echo "TGS4_GITHUB_REF=${TEMP_GITHUB_REF##*/}" >> $GITHUB_ENV

    - name: Build
      run: dotnet build -c ${{ matrix.configuration }}NoService

    - name: Run Integration Test
      run: |
        cd tests/Tgstation.Server.Tests
        sleep 10
        dotnet test -c ${{ matrix.configuration }}NoService --no-build -l "console;verbosity=detailed;noprogress=true" --collect:"XPlat Code Coverage" --settings ../../build/coverlet.runsettings -r ./TestResults

    - name: Store Code Coverage
      uses: actions/upload-artifact@v2
      with:
        name: linux-integration-test-coverage-${{ matrix.configuration }}-${{ matrix.watchdog-type }}-${{ matrix.database-type }}
        path: tests/Tgstation.Server.Tests/TestResults/

    - name: Package Server Console
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }}
      run: |
        cd src/Tgstation.Server.Host.Console
        dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Console
        cd ../Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/Console/lib/Default

    - name: Package Server Update Package
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }}
      run: |
        cd src/Tgstation.Server.Host
        dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/ServerUpdate

    - name: Store Server Console
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }}
      uses: actions/upload-artifact@v2
      with:
        name: ServerConsole
        path: Artifacts/Console/

    - name: Store Server Update Package
      if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }}
{'fraction_non_alphanumeric': 0.12880155069848273, 'fraction_numerical': 0.01229864313882762, 'mean_word_length': 2.4501325954110458, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 109, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 8, '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': '1856305', 'n_tokens_mistral': 10186, 'n_tokens_neox': 9581, 'n_words': 2128}