name: Daily

on:
  pull_request:
    branches:
      # any PR to a release branch.
      - '[0-9].[0-9]'
  schedule:
    - cron: '0 0 * * *'

jobs:

  test-ubuntu-jemalloc:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make REDIS_CFLAGS='-Werror -DREDIS_TEST'
    - name: test
      run: |
        sudo apt-get install tcl8.6
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster
    - name: unittest
      run: ./src/redis-server test all

  test-ubuntu-libc-malloc:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make MALLOC=libc
    - name: test
      run: |
        sudo apt-get install tcl8.6
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster

  test-ubuntu-no-malloc-usable-size:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make MALLOC=libc CFLAGS=-DNO_MALLOC_USABLE_SIZE
    - name: test
      run: |
        sudo apt-get install tcl8.6
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster

  test-ubuntu-32bit:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
        sudo apt-get update && sudo apt-get install libc6-dev-i386
        make 32bit REDIS_CFLAGS='-Werror -DREDIS_TEST'
    - name: test
      run: |
        sudo apt-get install tcl8.6
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: |
        make -C tests/modules 32bit # the script below doesn't have an argument, we must build manually ahead of time
        ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster
    - name: unittest
      run: ./src/redis-server test all

  test-ubuntu-tls:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
        make BUILD_TLS=yes
    - name: test
      run: |
        sudo apt-get install tcl8.6 tcl-tls
        ./utils/gen-test-certs.sh
        ./runtest --accurate --verbose --tls --dump-logs
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: |
        ./runtest-moduleapi --verbose --tls
        ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: |
        ./runtest-sentinel --tls
        ./runtest-sentinel
    - name: cluster tests
      run: |
        ./runtest-cluster --tls
        ./runtest-cluster

  test-ubuntu-io-threads:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
        make
    - name: test
      run: |
        sudo apt-get install tcl8.6 tcl-tls
        ./runtest --config io-threads 4 --config io-threads-do-reads yes --accurate --verbose --tags network --dump-logs
    - name: cluster tests
      run: |
        ./runtest-cluster --config io-threads 4 --config io-threads-do-reads yes

  test-valgrind:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make valgrind REDIS_CFLAGS='-Werror -DREDIS_TEST'
    - name: test
      run: |
        sudo apt-get update
        sudo apt-get install tcl8.6 valgrind -y
        ./runtest --valgrind --verbose --clients 1 --tags -large-memory --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --valgrind --no-latency --verbose --clients 1
    - name: unittest
      run: |
        valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/redis-server test all
        if grep -q 0x err.txt; then cat err.txt; exit 1; fi

  test-valgrind-no-malloc-usable-size:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE"
    - name: test
      run: |
        sudo apt-get update
        sudo apt-get install tcl8.6 valgrind -y
        ./runtest --valgrind --verbose --clients 1 --tags -large-memory --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --valgrind --no-latency --verbose --clients 1

  test-old-chain-jemalloc:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    container: ubuntu:20.04
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
        apt-get update
        apt-get install -y gnupg2
        echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" >> /etc/apt/sources.list
        echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" >> /etc/apt/sources.list
        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
        apt-get update
        apt-get install -y make gcc-4.8
        update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
        make CC=gcc REDIS_CFLAGS='-Werror'
    - name: testprep
      run: apt-get install -y tcl tcltls tclx
    - name: test
      run: ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster

  test-old-chain-tls:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    container: ubuntu:20.04
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
        apt-get update
        apt-get install -y gnupg2
        echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" >> /etc/apt/sources.list
        echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" >> /etc/apt/sources.list
        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
        apt-get update
        apt-get install -y make gcc-4.8 openssl libssl-dev
        update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
        make CC=gcc BUILD_TLS=yes REDIS_CFLAGS='-Werror'
    - name: testprep
      run: |
        apt-get install -y tcl tcltls tclx
        ./utils/gen-test-certs.sh
    - name: test
      run: |
        ./runtest --accurate --verbose --tls --dump-logs
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: |
        ./runtest-moduleapi --verbose --tls
        ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: |
        ./runtest-sentinel --tls
        ./runtest-sentinel
    - name: cluster tests
      run: |
        ./runtest-cluster --tls
        ./runtest-cluster

  test-macos-latest:
    runs-on: macos-latest
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make
    - name: test
      run: |
        ./runtest --accurate --verbose --no-latency --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster

  test-freebsd:
    runs-on: macos-13
    if: github.repository == 'redis/redis'
    timeout-minutes: 14400
    steps:
    - uses: actions/checkout@v2
    - name: test
      uses: cross-platform-actions/action@v0.22.0
      with:
        operating_system: freebsd
        environment_variables: MAKE
        version: 13.2
        shell: bash
        run: |
          sudo pkg install -y bash gmake lang/tcl86 lang/tclx gcc
          gmake
          ./runtest --single unit/keyspace --single unit/auth --single unit/networking --single unit/protocol

  test-alpine-jemalloc:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    container: alpine:latest
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
          apk add build-base
          make REDIS_CFLAGS='-Werror'
    - name: test
      run: |
        apk add tcl procps
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster

  test-alpine-libc-malloc:
    runs-on: ubuntu-latest
    if: github.repository == 'redis/redis'
    container: alpine:latest
    steps:
    - uses: actions/checkout@v2
    - name: make
      run: |
          apk add build-base
          make REDIS_CFLAGS='-Werror' USE_JEMALLOC=no CFLAGS=-DUSE_MALLOC_USABLE_SIZE
    - name: test
      run: |
        apk add tcl procps
        ./runtest --accurate --verbose --dump-logs
    - name: module api test
      run: ./runtest-moduleapi --verbose
    - name: sentinel tests
      run: ./runtest-sentinel
    - name: cluster tests
      run: ./runtest-cluster
