|
| 1 | +name: Continuous Integration (CI) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + # https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs |
| 10 | + # Workflows that would otherwise be triggered using `on: push` or |
| 11 | + # `on: pull_request` won't be triggered if you add any of the |
| 12 | + # following strings to the commit message in a push, or the HEAD |
| 13 | + # commit of a pull request: |
| 14 | + # - [skip ci] |
| 15 | + # - [ci skip] |
| 16 | + # - [no ci] |
| 17 | + # - [skip actions] |
| 18 | + # - [actions skip] |
| 19 | + |
| 20 | + test: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + env: |
| 24 | + MIX_ENV: test |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + LATEST_TYPESENSE: '27.1' |
| 27 | + |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + - typesense: '0.25.2' |
| 32 | + otp: '25' |
| 33 | + elixir: '1.14' |
| 34 | + - typesense: '26.0' |
| 35 | + otp: '25' |
| 36 | + elixir: '1.14' |
| 37 | + - typesense: '27.1' |
| 38 | + otp: '25' |
| 39 | + elixir: '1.14' |
| 40 | + - typesense: '0.25.2' |
| 41 | + otp: '27' |
| 42 | + elixir: '1.17' |
| 43 | + - typesense: '26.0' |
| 44 | + otp: '27' |
| 45 | + elixir: '1.17' |
| 46 | + - typesense: '27.1' |
| 47 | + otp: '27' |
| 48 | + elixir: '1.17' |
| 49 | + lint: true |
| 50 | + |
| 51 | + services: |
| 52 | + typesense: |
| 53 | + image: typesense/typesense:${{ matrix.typesense }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout repo |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Check for misspellings |
| 60 | + uses: codespell-project/actions-codespell@v2 |
| 61 | + |
| 62 | + - name: Start Typesense |
| 63 | + run: | |
| 64 | + docker run -d \ |
| 65 | + -p 8108:8108 \ |
| 66 | + --name typesense \ |
| 67 | + -v /tmp/typesense-data:/data \ |
| 68 | + -v /tmp/typesense-analytics-data:/analytics-data \ |
| 69 | + typesense/typesense:${{ matrix.typesense}} \ |
| 70 | + --api-key=xyz \ |
| 71 | + --data-dir=/data \ |
| 72 | + --enable-search-analytics=true \ |
| 73 | + --analytics-dir=/analytics-data \ |
| 74 | + --analytics-flush-interval=60 \ |
| 75 | + --analytics-minute-rate-limit=100 \ |
| 76 | + --enable-cors |
| 77 | +
|
| 78 | + - name: Curl Typesense |
| 79 | + run: sleep 1 && curl http://localhost:8108/health |
| 80 | + |
| 81 | + - name: Setup Elixir/OTP |
| 82 | + uses: erlef/setup-beam@v1 |
| 83 | + with: |
| 84 | + otp-version: ${{matrix.otp}} |
| 85 | + elixir-version: ${{matrix.elixir}} |
| 86 | + |
| 87 | + - name: Install Dependencies |
| 88 | + run: | |
| 89 | + mix local.rebar --if-missing |
| 90 | + mix local.hex --if-missing |
| 91 | + mix deps.get |
| 92 | +
|
| 93 | + - name: Compile |
| 94 | + run: mix compile |
| 95 | + |
| 96 | + - name: Cache dependencies/builds |
| 97 | + uses: actions/cache@v4 |
| 98 | + with: |
| 99 | + path: | |
| 100 | + deps |
| 101 | + _build |
| 102 | + key: ${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp}}-${{ matrix.elixir}}-mix-${{ hashFiles('**/mix.lock') }} |
| 103 | + restore-keys: | |
| 104 | + ${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp }}-${{ matrix.elixir }}-mix- |
| 105 | +
|
| 106 | + - name: Find unused dependencies |
| 107 | + run: mix deps.unlock --check-unused |
| 108 | + if: ${{ matrix.lint }} |
| 109 | + |
| 110 | + - name: Check retired dependencies |
| 111 | + run: mix hex.audit |
| 112 | + if: ${{ matrix.lint }} |
| 113 | + |
| 114 | + - name: Security audit of dependencies |
| 115 | + run: mix deps.audit |
| 116 | + if: ${{ matrix.lint }} |
| 117 | + |
| 118 | + - name: Compile project |
| 119 | + run: mix compile --all-warnings |
| 120 | + |
| 121 | + - name: Run static analysis |
| 122 | + run: mix credo --all --strict |
| 123 | + if: ${{ matrix.lint }} |
| 124 | + |
| 125 | + - name: Check format files |
| 126 | + run: mix format --check-formatted |
| 127 | + if: ${{ matrix.lint }} |
| 128 | + |
| 129 | + - name: Run tests |
| 130 | + run: mix test --only ${{ matrix.typesense }}:true --trace |
| 131 | + |
| 132 | + - name: Post test coverage to Coveralls |
| 133 | + run: mix coveralls.github |
| 134 | + if: ${{ matrix.typesense == env.LATEST_TYPESENSE }} |
0 commit comments