|
| 1 | +name: CI v30.1 |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + # https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs |
| 12 | + # Workflows that would otherwise be triggered using `on: push` or |
| 13 | + # `on: pull_request` won't be triggered if you add any of the |
| 14 | + # following strings to the commit message in a push, or the HEAD |
| 15 | + # commit of a pull request: |
| 16 | + # - [skip ci] |
| 17 | + # - [ci skip] |
| 18 | + # - [no ci] |
| 19 | + # - [skip actions] |
| 20 | + # - [actions skip] |
| 21 | + |
| 22 | + test: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + environment: review |
| 25 | + |
| 26 | + env: |
| 27 | + MIX_ENV: test |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + LATEST_TYPESENSE: '30.1' |
| 30 | + |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + include: |
| 34 | + - typesense: '30.1' |
| 35 | + otp: '25' |
| 36 | + elixir: '1.14' |
| 37 | + lint: false |
| 38 | + - typesense: '30.1' |
| 39 | + otp: '28' |
| 40 | + elixir: '1.18' |
| 41 | + lint: true |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout repo |
| 45 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 46 | + |
| 47 | + - name: Check for misspellings |
| 48 | + uses: codespell-project/actions-codespell@8f01853be192eb0f849a5c7d721450e7a467c579 |
| 49 | + |
| 50 | + - name: Start Typesense |
| 51 | + run: | |
| 52 | + docker run -id \ |
| 53 | + -p 8108:8108 \ |
| 54 | + --name typesense \ |
| 55 | + -v /tmp/typesense-data:/data \ |
| 56 | + -v /tmp/typesense-analytics-data:/analytics-data \ |
| 57 | + typesense/typesense:${{ matrix.typesense}} \ |
| 58 | + --api-key xyz \ |
| 59 | + --data-dir /data \ |
| 60 | + --enable-search-analytics=true \ |
| 61 | + --analytics-dir=/analytics-data \ |
| 62 | + --analytics-flush-interval=60 \ |
| 63 | + --analytics-minute-rate-limit=100 \ |
| 64 | + --enable-cors |
| 65 | +
|
| 66 | + - name: Wait for Typesense to be healthy |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + start_time=$(date +%s) |
| 70 | + timeout=30 |
| 71 | + counter=0 |
| 72 | + until curl -s http://localhost:8108/health | grep -q '"ok":true'; do |
| 73 | + if [ $counter -eq $timeout ]; then |
| 74 | + echo "Timed out waiting for Typesense to be healthy" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | + echo "Waiting for Typesense to be healthy..." |
| 78 | + sleep 1 |
| 79 | + counter=$((counter + 1)) |
| 80 | + done |
| 81 | + end_time=$(date +%s) |
| 82 | + elapsed=$((end_time - start_time)) |
| 83 | + echo "Typesense healthcheck elapsed: ${elapsed}s" |
| 84 | +
|
| 85 | + - name: Setup Elixir/OTP |
| 86 | + uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 |
| 87 | + with: |
| 88 | + otp-version: ${{matrix.otp}} |
| 89 | + elixir-version: ${{matrix.elixir}} |
| 90 | + |
| 91 | + - name: Restore cache |
| 92 | + id: cache_restore |
| 93 | + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 |
| 94 | + if: ${{ matrix.lint }} |
| 95 | + with: |
| 96 | + path: | |
| 97 | + deps |
| 98 | + _build |
| 99 | + priv/plts |
| 100 | + key: ${{ runner.os }}-typesense-${{ matrix.typesense }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }} |
| 101 | + restore-keys: | |
| 102 | + ${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp }}-${{ matrix.elixir }}-mix- |
| 103 | +
|
| 104 | + - name: Install Dependencies |
| 105 | + run: | |
| 106 | + mix local.rebar --if-missing |
| 107 | + mix local.hex --if-missing |
| 108 | + mix deps.get |
| 109 | +
|
| 110 | + - name: Find unused dependencies |
| 111 | + run: mix deps.unlock --check-unused |
| 112 | + if: ${{ matrix.lint }} |
| 113 | + |
| 114 | + - name: Check retired dependencies |
| 115 | + run: mix hex.audit |
| 116 | + if: ${{ matrix.lint }} |
| 117 | + |
| 118 | + - name: Security audit of dependencies |
| 119 | + run: mix deps.audit |
| 120 | + if: ${{ matrix.lint }} |
| 121 | + |
| 122 | + - name: Compile project |
| 123 | + run: mix compile --all-warnings |
| 124 | + |
| 125 | + - name: Run static analysis |
| 126 | + run: mix credo --all --strict |
| 127 | + if: ${{ matrix.lint }} |
| 128 | + |
| 129 | + - name: Check format files |
| 130 | + run: mix format --check-formatted |
| 131 | + if: ${{ matrix.lint }} |
| 132 | + |
| 133 | + - name: Create PLTs |
| 134 | + if: ${{ steps.cache_restore.outputs.cache-hit != 'true' && matrix.lint }} |
| 135 | + run: mix dialyzer --plt |
| 136 | + |
| 137 | + - name: Dialyzer |
| 138 | + run: mix dialyzer --format github --format dialyxir |
| 139 | + if: ${{ matrix.lint }} |
| 140 | + |
| 141 | + - name: Run tests |
| 142 | + run: mix test --only ${{ matrix.typesense }}:true --only nls:true --trace |
| 143 | + |
| 144 | + - name: Post test coverage to Coveralls |
| 145 | + run: mix coveralls.github |
| 146 | + if: ${{ matrix.lint && github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 147 | + |
| 148 | + - name: Save cache |
| 149 | + id: cache_save |
| 150 | + uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 |
| 151 | + if: ${{ matrix.lint }} |
| 152 | + with: |
| 153 | + path: | |
| 154 | + deps |
| 155 | + _build |
| 156 | + priv/plts |
| 157 | + key: ${{ runner.os }}-typesense-${{ matrix.typesense }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }} |
| 158 | + |
0 commit comments