|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + env: |
| 16 | + MIX_ENV: test |
| 17 | + |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + elixir: [1.18.1] |
| 21 | + otp: [27.0] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Set up Elixir |
| 28 | + uses: erlef/setup-beam@v1 |
| 29 | + with: |
| 30 | + elixir-version: ${{ matrix.elixir }} |
| 31 | + otp-version: ${{ matrix.otp }} |
| 32 | + |
| 33 | + - name: Cache Elixir deps |
| 34 | + uses: actions/cache@v1 |
| 35 | + id: deps-cache |
| 36 | + with: |
| 37 | + path: deps |
| 38 | + key: ${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 39 | + |
| 40 | + - name: Cache Elixir _build |
| 41 | + uses: actions/cache@v1 |
| 42 | + id: build-cache |
| 43 | + with: |
| 44 | + path: _build |
| 45 | + key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 46 | + |
| 47 | + - name: Install deps |
| 48 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 49 | + run: | |
| 50 | + mix local.rebar --force |
| 51 | + mix local.hex --force |
| 52 | + mix deps.get --only ${{ env.MIX_ENV }} |
| 53 | +
|
| 54 | + - name: Compile deps |
| 55 | + if: steps.build-cache.outputs.cache-hit != 'true' |
| 56 | + run: mix deps.compile --warnings-as-errors |
| 57 | + |
| 58 | + - name: Clean build |
| 59 | + run: mix clean |
| 60 | + |
| 61 | + - name: Check code formatting |
| 62 | + run: mix format --check-formatted |
| 63 | + |
| 64 | + - name: Run Credo |
| 65 | + run: mix credo --strict |
| 66 | + |
| 67 | + static-analisys: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + |
| 70 | + env: |
| 71 | + MIX_ENV: test |
| 72 | + |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + elixir: [1.18.1] |
| 76 | + otp: [27.0] |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v3 |
| 81 | + |
| 82 | + - name: Set up Elixir |
| 83 | + uses: erlef/setup-beam@v1 |
| 84 | + with: |
| 85 | + elixir-version: ${{ matrix.elixir }} |
| 86 | + otp-version: ${{ matrix.otp }} |
| 87 | + |
| 88 | + - name: Cache Elixir deps |
| 89 | + uses: actions/cache@v1 |
| 90 | + id: deps-cache |
| 91 | + with: |
| 92 | + path: deps |
| 93 | + key: ${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 94 | + |
| 95 | + - name: Cache Elixir _build |
| 96 | + uses: actions/cache@v1 |
| 97 | + id: build-cache |
| 98 | + with: |
| 99 | + path: _build |
| 100 | + key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 101 | + |
| 102 | + - name: Install deps |
| 103 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 104 | + run: | |
| 105 | + mix local.rebar --force |
| 106 | + mix local.hex --force |
| 107 | + mix deps.get --only ${{ env.MIX_ENV }} |
| 108 | +
|
| 109 | + - name: Compile deps |
| 110 | + if: steps.build-cache.outputs.cache-hit != 'true' |
| 111 | + run: mix deps.compile --warnings-as-errors |
| 112 | + |
| 113 | + # Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones |
| 114 | + # Cache key based on Elixir & Erlang version (also useful when running in matrix) |
| 115 | + - name: Restore PLT cache |
| 116 | + uses: actions/cache/restore@v3 |
| 117 | + id: plt_cache |
| 118 | + with: |
| 119 | + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt |
| 120 | + restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt |
| 121 | + path: priv/plts |
| 122 | + |
| 123 | + # Create PLTs if no cache was found |
| 124 | + - name: Create PLTs |
| 125 | + if: steps.plt_cache.outputs.cache-hit != 'true' |
| 126 | + run: mix dialyzer --plt |
| 127 | + |
| 128 | + - name: Save PLT cache |
| 129 | + uses: actions/cache/save@v3 |
| 130 | + if: steps.plt_cache.outputs.cache-hit != 'true' |
| 131 | + id: plt_cache_save |
| 132 | + with: |
| 133 | + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plt |
| 134 | + path: priv/plts |
| 135 | + |
| 136 | + - name: Run dialyzer |
| 137 | + run: mix dialyzer --format github |
| 138 | + |
| 139 | + test: |
| 140 | + runs-on: ubuntu-latest |
| 141 | + |
| 142 | + env: |
| 143 | + MIX_ENV: test |
| 144 | + |
| 145 | + strategy: |
| 146 | + matrix: |
| 147 | + elixir: [1.18.1] |
| 148 | + otp: [27.0] |
| 149 | + |
| 150 | + steps: |
| 151 | + - name: Checkout code |
| 152 | + uses: actions/checkout@v3 |
| 153 | + |
| 154 | + - name: Set up Elixir |
| 155 | + uses: erlef/setup-beam@v1 |
| 156 | + with: |
| 157 | + elixir-version: ${{ matrix.elixir }} |
| 158 | + otp-version: ${{ matrix.otp }} |
| 159 | + |
| 160 | + - name: Cache Elixir deps |
| 161 | + uses: actions/cache@v1 |
| 162 | + id: deps-cache |
| 163 | + with: |
| 164 | + path: deps |
| 165 | + key: ${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 166 | + |
| 167 | + - name: Cache Elixir _build |
| 168 | + uses: actions/cache@v1 |
| 169 | + id: build-cache |
| 170 | + with: |
| 171 | + path: _build |
| 172 | + key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 173 | + |
| 174 | + - name: Install deps |
| 175 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 176 | + run: | |
| 177 | + mix local.rebar --force |
| 178 | + mix local.hex --force |
| 179 | + mix deps.get --only ${{ env.MIX_ENV }} |
| 180 | +
|
| 181 | + - name: Compile deps |
| 182 | + if: steps.build-cache.outputs.cache-hit != 'true' |
| 183 | + run: mix deps.compile --warnings-as-errors |
| 184 | + |
| 185 | + - name: Clean build |
| 186 | + run: mix clean |
| 187 | + |
| 188 | + - name: Run tests |
| 189 | + run: mix test |
0 commit comments