|
| 1 | +name: Elixir CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: main |
| 7 | + |
| 8 | +env: |
| 9 | + DEFAULT_ELIXIR: 1.15.8-otp-25 |
| 10 | + DEFAULT_OTP: 25.3.2.4 |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + static-analysis: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + name: Static analysis - ${{ matrix.project }} |
| 19 | + |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + project: |
| 23 | + - engine |
| 24 | + - expert |
| 25 | + - expert_credo |
| 26 | + - forge |
| 27 | + steps: |
| 28 | + # Step: Setup Elixir + Erlang image as the base |
| 29 | + - uses: extractions/setup-just@v3 |
| 30 | + - uses: erlef/setup-beam@v1 |
| 31 | + with: |
| 32 | + otp-version: ${{ env.DEFAULT_OTP }} |
| 33 | + elixir-version: ${{ env.DEFAULT_ELIXIR }} |
| 34 | + version-type: "strict" |
| 35 | + |
| 36 | + # Step: Check out the code. |
| 37 | + - name: Checkout code |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + # Step: Define how to cache deps. Restores existing cache if present. |
| 41 | + - name: Cache deps |
| 42 | + id: cache-deps |
| 43 | + uses: actions/cache@v4 |
| 44 | + with: |
| 45 | + path: | |
| 46 | + apps/${{ matrix.project }}/deps |
| 47 | + apps/${{ matrix.project }}/_build |
| 48 | +
|
| 49 | + key: ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}-${{ hashFiles('apps/${{matrix.project}}/mix.lock') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}- |
| 52 | +
|
| 53 | + - name: Deps |
| 54 | + run: just deps ${{ matrix.project }} |
| 55 | + |
| 56 | + - name: Compile |
| 57 | + run: just compile ${{ matrix.project }} --warnings-as-errors |
| 58 | + |
| 59 | + - name: Formatter |
| 60 | + run: just mix ${{ matrix.project }} format --check-formatted |
| 61 | + |
| 62 | + - name: Credo |
| 63 | + run: just mix ${{ matrix.project }} credo |
| 64 | + |
| 65 | + dialyzer: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + name: Dialyzer - ${{ matrix.project }} |
| 68 | + strategy: |
| 69 | + matrix: |
| 70 | + project: |
| 71 | + - engine |
| 72 | + - expert |
| 73 | + - expert_credo |
| 74 | + - forge |
| 75 | + steps: |
| 76 | + - uses: extractions/setup-just@v3 |
| 77 | + - name: Set up Elixir |
| 78 | + uses: erlef/setup-beam@v1 |
| 79 | + with: |
| 80 | + otp-version: ${{ env.DEFAULT_OTP }} |
| 81 | + elixir-version: ${{ env.DEFAULT_ELIXIR }} |
| 82 | + version-type: "strict" |
| 83 | + |
| 84 | + # Step: Check out the code. |
| 85 | + - name: Checkout code |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + # Step: Define how to cache deps. Restores existing cache if present. |
| 89 | + - name: Cache deps |
| 90 | + id: cache-deps |
| 91 | + uses: actions/cache@v4 |
| 92 | + with: |
| 93 | + path: | |
| 94 | + apps/${{ matrix.project }}/deps |
| 95 | + apps/${{ matrix.project }}/_build |
| 96 | +
|
| 97 | + key: ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}-${{ hashFiles('apps/${{ matrix.project }}/mix.lock') }} |
| 98 | + restore-keys: | |
| 99 | + ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}- |
| 100 | +
|
| 101 | + # Step: Create dialyzer .plt files if they're not present |
| 102 | + - name: Cache dialyzer plt files |
| 103 | + id: cache-plt |
| 104 | + uses: actions/cache@v4 |
| 105 | + with: |
| 106 | + key: expert-plts-${{ env.DEFAULT_OTP }}-${{ env.DEFAULT_ELIXIR }}-${{ hashFiles('apps/${{ matrix.project }}/mix.lock' ) }} |
| 107 | + restore-keys: | |
| 108 | + expert-plts-${{ env.DEFAULT_OTP }}-${{ env.DEFAULT_ELIXIR }}-${{ hashFiles('apps/${{ matrix.project }}/mix.lock') }}- |
| 109 | + expert-plts-${{ env.DEFAULT_OTP }}-${{ env.DEFAULT_ELIXIR }}- |
| 110 | + path: "priv/plts" |
| 111 | + |
| 112 | + - name: Deps |
| 113 | + run: just deps ${{ matrix.project }} |
| 114 | + |
| 115 | + - name: Compile |
| 116 | + run: just compile ${{ matrix.project }} --warnings-as-errors |
| 117 | + |
| 118 | + - name: Create PLT |
| 119 | + if: steps.cache-plt.outputs.cache-hit != 'true' |
| 120 | + run: | |
| 121 | + mkdir -p priv/plts |
| 122 | + just mix ${{ matrix.project }} dialyzer --plt |
| 123 | +
|
| 124 | + - name: Dialyzer |
| 125 | + run: | |
| 126 | + just mix ${{ matrix.project }} compile.protocols --warnings-as-errors |
| 127 | + just mix ${{ matrix.project }} dialyzer |
| 128 | +
|
| 129 | + release-test: |
| 130 | + runs-on: ${{matrix.os.name}} |
| 131 | + name: Release test (${{matrix.os.name}}) |
| 132 | + strategy: |
| 133 | + matrix: |
| 134 | + os: |
| 135 | + - name: ubuntu-latest |
| 136 | + target: linux_amd64 |
| 137 | + - name: macos-14 |
| 138 | + target: darwin_arm64 |
| 139 | + - name: macos-13 |
| 140 | + target: darwin_amd64 |
| 141 | + |
| 142 | + include: |
| 143 | + - elixir: "1.17.3" |
| 144 | + otp: "27.3.4.1" |
| 145 | + |
| 146 | + steps: |
| 147 | + - name: Checkout code |
| 148 | + uses: actions/checkout@v4 |
| 149 | + |
| 150 | + - uses: extractions/setup-just@v3 |
| 151 | + - name: Set up Elixir |
| 152 | + uses: erlef/setup-beam@v1 |
| 153 | + with: |
| 154 | + otp-version: ${{matrix.otp}} |
| 155 | + elixir-version: ${{matrix.elixir}} |
| 156 | + |
| 157 | + - uses: mlugg/setup-zig@v2 |
| 158 | + with: |
| 159 | + version: "0.14.1" |
| 160 | + |
| 161 | + - name: Cache deps |
| 162 | + id: cache-deps |
| 163 | + uses: actions/cache@v4 |
| 164 | + with: |
| 165 | + path: | |
| 166 | + apps/**/deps |
| 167 | + apps/**/_build |
| 168 | +
|
| 169 | + key: ${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('apps/**/mix.lock') }} |
| 170 | + restore-keys: | |
| 171 | + ${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}- |
| 172 | +
|
| 173 | + - name: Build and release |
| 174 | + run: just release-local |
| 175 | + |
| 176 | + prep-matrix: |
| 177 | + runs-on: ubuntu-latest |
| 178 | + outputs: |
| 179 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 180 | + steps: |
| 181 | + - name: Checkout to repository |
| 182 | + uses: actions/checkout@v4 |
| 183 | + - name: Set matrix data |
| 184 | + id: set-matrix |
| 185 | + run: echo "matrix=$(jq -c . < .github/matrix.json)" >> $GITHUB_OUTPUT |
| 186 | + |
| 187 | + test: |
| 188 | + runs-on: ubuntu-latest |
| 189 | + name: Test ${{ matrix.project }} on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} |
| 190 | + needs: prep-matrix |
| 191 | + strategy: |
| 192 | + matrix: ${{ fromJson(needs.prep-matrix.outputs.matrix) }} |
| 193 | + steps: |
| 194 | + - name: Checkout code |
| 195 | + uses: actions/checkout@v4 |
| 196 | + |
| 197 | + - uses: extractions/setup-just@v3 |
| 198 | + - name: Set up Elixir |
| 199 | + uses: erlef/setup-beam@v1 |
| 200 | + with: |
| 201 | + otp-version: ${{matrix.otp}} |
| 202 | + elixir-version: ${{matrix.elixir}} |
| 203 | + |
| 204 | + - name: Cache deps |
| 205 | + id: cache-deps |
| 206 | + uses: actions/cache@v4 |
| 207 | + with: |
| 208 | + path: | |
| 209 | + apps/${{ matrix.project }}/deps |
| 210 | + apps/${{ matrix.project }}/_build |
| 211 | +
|
| 212 | + key: ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}-${{ hashFiles('apps/${{matrix.project}}/mix.lock') }} |
| 213 | + restore-keys: | |
| 214 | + ${{ runner.os }}-mix-${{ matrix.project }}-${{ env.DEFAULT_ELIXIR }}-${{ env.DEFAULT_OTP }}- |
| 215 | +
|
| 216 | + - name: Deps |
| 217 | + run: just deps ${{ matrix.project }} |
| 218 | + |
| 219 | + - name: Run tests |
| 220 | + run: just test ${{ matrix.project }} --warnings-as-errors |
0 commit comments