|
| 1 | +# Copyright 2022 Giuseppe De Palma, Matteo Trentin |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Elixir |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [main] |
| 20 | + pull_request: |
| 21 | + branches: [main] |
| 22 | + |
| 23 | +env: |
| 24 | + MIX_ENV: test |
| 25 | + |
| 26 | +jobs: |
| 27 | + lint: |
| 28 | + name: Lint check |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + elixir: [1.14] |
| 33 | + otp: [25] |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + |
| 38 | + - name: Setup Elixir/OTP |
| 39 | + uses: erlef/setup-beam@v1 |
| 40 | + with: |
| 41 | + otp-version: "=${{ matrix.otp }}" |
| 42 | + elixir-version: ${{ matrix.elixir }} |
| 43 | + install-hex: true |
| 44 | + install-rebar: true |
| 45 | + |
| 46 | + - name: Retrieve Mix Dependencies Cache |
| 47 | + uses: actions/cache@v1 |
| 48 | + id: mix-cache # id to use in retrieve action |
| 49 | + with: |
| 50 | + path: deps |
| 51 | + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 52 | + |
| 53 | + - name: Install Mix Dependencies (if deps cache miss) |
| 54 | + if: steps.mix-cache.outputs.cache-hit != 'true' |
| 55 | + run: | |
| 56 | + mix local.rebar --force |
| 57 | + mix local.hex --force |
| 58 | + mix deps.get |
| 59 | +
|
| 60 | + - name: Check Formatting |
| 61 | + run: mix format --check-formatted |
| 62 | + |
| 63 | + - name: Run Credo |
| 64 | + run: mix credo --strict |
| 65 | + |
| 66 | + unit-test: |
| 67 | + name: Unit Tests |
| 68 | + strategy: |
| 69 | + matrix: |
| 70 | + os: [ubuntu-20.04, windows-2019, macos-10.15] |
| 71 | + elixir: [1.14] |
| 72 | + otp: [25] |
| 73 | + |
| 74 | + runs-on: ${{ matrix.os }} |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v3 |
| 77 | + |
| 78 | + - name: Setup Elixir/OTP |
| 79 | + if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }} |
| 80 | + uses: erlef/setup-beam@v1 |
| 81 | + with: |
| 82 | + otp-version: "=${{ matrix.otp }}" |
| 83 | + elixir-version: ${{ matrix.elixir }} |
| 84 | + install-hex: true |
| 85 | + install-rebar: true |
| 86 | + - name: Setup Elixir/OTP |
| 87 | + if: ${{ startswith(matrix.os, 'macos') }} |
| 88 | + run: | |
| 89 | + brew install erlang |
| 90 | + brew install elixir |
| 91 | +
|
| 92 | + - name: Retrieve Mix Dependencies Cache |
| 93 | + uses: actions/cache@v1 |
| 94 | + id: mix-cache # id to use in retrieve action |
| 95 | + with: |
| 96 | + path: deps |
| 97 | + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 98 | + |
| 99 | + - name: Install Rebar and Hex |
| 100 | + run: | |
| 101 | + mix local.rebar --force |
| 102 | + mix local.hex --force |
| 103 | + - name: Install Mix Dependencies (if deps cache miss) |
| 104 | + if: steps.mix-cache.outputs.cache-hit != 'true' |
| 105 | + run: | |
| 106 | + mix do deps.get, deps.compile |
| 107 | +
|
| 108 | + - name: Run Core Unit Tests |
| 109 | + run: mix core.test |
| 110 | + |
| 111 | + - name: Run Worker Tests |
| 112 | + run: mix worker.test |
| 113 | + |
| 114 | + integration-test: |
| 115 | + name: Integration Tests |
| 116 | + strategy: |
| 117 | + matrix: |
| 118 | + os: [ubuntu-20.04] |
| 119 | + elixir: [1.14] |
| 120 | + otp: [25] |
| 121 | + |
| 122 | + runs-on: ${{ matrix.os }} |
| 123 | + services: |
| 124 | + postgres: |
| 125 | + image: postgres:latest |
| 126 | + env: |
| 127 | + POSTGRES_USER: postgres |
| 128 | + POSTGRES_PASSWORD: postgres |
| 129 | + POSTGRES_DB: core_test |
| 130 | + ports: |
| 131 | + - 5432:5432 |
| 132 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 133 | + env: |
| 134 | + MIX_ENV: test |
| 135 | + |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v3 |
| 138 | + |
| 139 | + - name: Setup Elixir/OTP |
| 140 | + if: ${{ startswith(matrix.os, 'ubuntu') || startswith(matrix.os, 'windows') }} |
| 141 | + uses: erlef/setup-beam@v1 |
| 142 | + with: |
| 143 | + otp-version: "=${{ matrix.otp }}" |
| 144 | + elixir-version: ${{ matrix.elixir }} |
| 145 | + install-hex: true |
| 146 | + install-rebar: true |
| 147 | + - name: Setup Elixir/OTP |
| 148 | + if: ${{ startswith(matrix.os, 'macos') }} |
| 149 | + run: | |
| 150 | + brew install erlang |
| 151 | + brew install elixir |
| 152 | +
|
| 153 | + - name: Retrieve Mix Dependencies Cache |
| 154 | + uses: actions/cache@v1 |
| 155 | + id: mix-cache # id to use in retrieve action |
| 156 | + with: |
| 157 | + path: deps |
| 158 | + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |
| 159 | + |
| 160 | + - name: Install Mix Dependencies (if deps cache miss) |
| 161 | + if: steps.mix-cache.outputs.cache-hit != 'true' |
| 162 | + run: | |
| 163 | + mix local.rebar --force |
| 164 | + mix local.hex --force |
| 165 | + mix deps.get |
| 166 | +
|
| 167 | + - name: Run Core Integration Tests |
| 168 | + run: mix core.integration_test |
0 commit comments