|
| 1 | +name: Common Flow for Tests |
| 2 | + |
| 3 | +# Documentation: https://redislabs.atlassian.net/wiki/spaces/DX/pages/3967844669/RediSearch+CI+refactor |
| 4 | + |
| 5 | +inputs: |
| 6 | + env: |
| 7 | + default: "ubuntu-22.04" |
| 8 | + type: string |
| 9 | + container: |
| 10 | + type: string |
| 11 | + sanitizer: |
| 12 | + type: string |
| 13 | + test-config: |
| 14 | + description: 'Test configuration environment variable (e.g. "CONFIG=tls" or "QUICK=1")' |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + redis-ref: |
| 18 | + description: 'Redis ref to checkout' |
| 19 | + type: string |
| 20 | + required: true |
| 21 | + |
| 22 | +runs: |
| 23 | + using: composite |
| 24 | + steps: |
| 25 | + - name: Get Installation Mode |
| 26 | + shell: bash |
| 27 | + id: mode |
| 28 | + run: | |
| 29 | + [[ -z "${{ inputs.container }}" ]] && echo "mode=sudo" >> $GITHUB_OUTPUT || echo "mode=" >> $GITHUB_OUTPUT |
| 30 | + - name: Check if node20 is Supported |
| 31 | + id: node20 |
| 32 | + uses: ./.github/actions/node20-supported |
| 33 | + with: |
| 34 | + container: ${{ inputs.container }} |
| 35 | + - name: Install git |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + # TODO: must be changed to run a script based on the input env |
| 39 | + echo ::group::Install git |
| 40 | + ${{ steps.mode.outputs.mode }} apt-get update && apt-get install -y git |
| 41 | + echo ::endgroup:: |
| 42 | + - name: Setup specific |
| 43 | + shell: bash |
| 44 | + working-directory: .install |
| 45 | + run: | |
| 46 | + echo ::group::OS-Specific Setup |
| 47 | + ./install_script.sh ${{ steps.mode.outputs.mode }} |
| 48 | + echo ::endgroup:: |
| 49 | + echo ::group::Get Rust |
| 50 | + ./getrust.sh ${{ steps.mode.outputs.mode }} |
| 51 | + echo ::endgroup:: |
| 52 | +
|
| 53 | + - name: Full checkout (node20 supported) |
| 54 | + if: steps.node20.outputs.supported == 'true' |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + submodules: recursive |
| 58 | + - name: Full checkout (node20 unsupported) |
| 59 | + if: steps.node20.outputs.supported == 'false' |
| 60 | + uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + submodules: recursive |
| 63 | + |
| 64 | + - name: Get Redis |
| 65 | + uses: actions/checkout@v4 |
| 66 | + with: |
| 67 | + repository: redis/redis |
| 68 | + ref: ${{ inputs.redis-ref }} |
| 69 | + path: redis |
| 70 | + submodules: 'recursive' |
| 71 | + - name: Build |
| 72 | + uses: ./.github/actions/build-json-module-and-redis |
| 73 | + with: |
| 74 | + sanitizer: ${{ inputs.san }} |
| 75 | + |
| 76 | + - name: Set Artifact Names |
| 77 | + shell: bash |
| 78 | + # Artifact names have to be unique, so we base them on the environment. |
| 79 | + # We also remove invalid characters from the name. |
| 80 | + id: artifact-names |
| 81 | + run: | |
| 82 | + # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ? |
| 83 | + echo "name=$(echo "${{ inputs.container || inputs.env }} ${{ runner.arch }}, Redis ${{ inputs.redis-ref }}" | \ |
| 84 | + sed -e 's/[":\/\\<>\|*?]/_/g' -e 's/__*/_/g' -e 's/^_//' -e 's/_$//')" >> $GITHUB_OUTPUT |
| 85 | +
|
| 86 | + - name: Run tests |
| 87 | + shell: bash |
| 88 | + id: test |
| 89 | + run: | |
| 90 | + echo ::group::Activate virtual environment |
| 91 | + python3 -m venv venv |
| 92 | + echo "source $PWD/venv/bin/activate" >> ~/.bash_profile |
| 93 | + source venv/bin/activate |
| 94 | + echo ::endgroup:: |
| 95 | + echo ::group::Install python dependencies |
| 96 | + ./.install/common_installations.sh |
| 97 | + echo ::endgroup:: |
| 98 | + echo ::group::Unit tests |
| 99 | + . "$HOME/.cargo/env" |
| 100 | + make cargo_test LOG=1 CLEAR_LOGS=0 SAN=${{ inputs.san }} |
| 101 | + echo ::endgroup:: |
| 102 | + echo ::group::Flow tests |
| 103 | + make pytest LOG=1 CLEAR_LOGS=0 SAN=${{ inputs.san }} ${{ inputs.test-config }} |
| 104 | + echo ::endgroup:: |
| 105 | + env: |
| 106 | + PIP_BREAK_SYSTEM_PACKAGES: 1 |
| 107 | + |
| 108 | + - name: Upload test artifacts (node20 supported) |
| 109 | + if: steps.node20.outputs.supported == 'true' && steps.test.outcome == 'failure' |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: Test logs ${{ steps.artifact-names.outputs.name }} |
| 113 | + path: tests/**/logs/*.log* |
| 114 | + if-no-files-found: ignore |
| 115 | + - name: Upload test artifacts (node20 unsupported) |
| 116 | + if: steps.node20.outputs.supported == 'false' && steps.test.outcome == 'failure' |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: Test logs ${{ steps.artifact-names.outputs.name }} |
| 120 | + path: tests/**/logs/*.log* |
| 121 | + if-no-files-found: ignore |
| 122 | + |
| 123 | + - name: Fail flow if tests failed |
| 124 | + shell: bash |
| 125 | + if: steps.test.outcome == 'failure' |
| 126 | + run: exit 1 |
0 commit comments