|
| 1 | +--- |
| 2 | +name: Test |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "main" |
| 7 | + pull_request: |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Run tests |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + otp: ['24', '25', '26', '27', '28'] |
| 19 | + elixir: ['1.14.5', '1.15.7', '1.16.3', '1.17.3', '1.18.4', '1.19.4'] |
| 20 | + # https://hexdocs.pm/elixir/compatibility-and-deprecations.html |
| 21 | + exclude: |
| 22 | + - otp: '24' |
| 23 | + elixir: '1.19.4' |
| 24 | + - otp: '24' |
| 25 | + elixir: '1.18.4' |
| 26 | + - otp: '24' |
| 27 | + elixir: '1.17.3' |
| 28 | + - otp: '25' |
| 29 | + elixir: '1.19.4' |
| 30 | + - otp: '26' |
| 31 | + elixir: '1.14.5' |
| 32 | + - otp: '27' |
| 33 | + elixir: '1.14.5' |
| 34 | + - otp: '27' |
| 35 | + elixir: '1.15.7' |
| 36 | + - otp: '27' |
| 37 | + elixir: '1.16.3' |
| 38 | + - otp: '28' |
| 39 | + elixir: '1.14.5' |
| 40 | + - otp: '28' |
| 41 | + elixir: '1.15.7' |
| 42 | + - otp: '28' |
| 43 | + elixir: '1.16.3' |
| 44 | + - otp: '28' |
| 45 | + elixir: '1.17.3' |
| 46 | + env: |
| 47 | + MIX_ENV: test |
| 48 | + steps: |
| 49 | + - name: Check out source |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Install Erlang and Elixir |
| 53 | + uses: erlef/setup-beam@v1 |
| 54 | + with: |
| 55 | + otp-version: ${{ matrix.otp }} |
| 56 | + elixir-version: ${{ matrix.elixir }} |
| 57 | + |
| 58 | + - name: Cache deps |
| 59 | + id: cache-deps |
| 60 | + uses: actions/cache@v4 |
| 61 | + env: |
| 62 | + cache-name: cache-elixir-deps |
| 63 | + with: |
| 64 | + path: deps |
| 65 | + key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} |
| 66 | + restore-keys: | |
| 67 | + ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}- |
| 68 | +
|
| 69 | + - name: Cache compiled build |
| 70 | + id: cache-build |
| 71 | + uses: actions/cache@v4 |
| 72 | + env: |
| 73 | + cache-name: cache-compiled-build |
| 74 | + with: |
| 75 | + path: _build |
| 76 | + key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} |
| 77 | + restore-keys: | |
| 78 | + ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}- |
| 79 | +
|
| 80 | + - name: Install tools |
| 81 | + run: mix do local.rebar --force, local.hex --force |
| 82 | + |
| 83 | + - name: Get Elixir deps |
| 84 | + run: mix deps.get |
| 85 | + |
| 86 | + - name: Compile |
| 87 | + run: mix compile --warnings-as-errors |
| 88 | + |
| 89 | + # - name: Check formatting |
| 90 | + # run: mix format --check-formatted |
| 91 | + |
| 92 | + - name: Run tests |
| 93 | + run: mix test |
| 94 | + |
| 95 | + - name: Run credo |
| 96 | + run: mix credo --mute-exit-status |
| 97 | + # run: mix credo |
| 98 | + |
| 99 | + - name: Run hex.audit |
| 100 | + run: mix hex.audit |
| 101 | + |
| 102 | + - name: Run deps.audit |
| 103 | + run: mix deps.audit |
| 104 | + |
| 105 | + - name: Run dialyzer |
| 106 | + run: mix dialyzer --ignore-exit-status --format github |
| 107 | + |
| 108 | + - name: Publish unit test results to GitHub |
| 109 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 110 | + # Run even if tests fail |
| 111 | + if: always() |
| 112 | + with: |
| 113 | + junit_files: _build/test/junit-reports/*.xml |
| 114 | + # junit_files: _build/test/lib/*/*.xml |
| 115 | + check_name: "Test Results ${{matrix.elixir}} ${{matrix.otp}}" |
| 116 | + |
| 117 | + # - name: Upload results to Datadog |
| 118 | + # if: always() |
| 119 | + # continue-on-error: true |
| 120 | + # env: |
| 121 | + # DD_API_KEY: ${{ secrets.ACTIONS_DD_API_KEY }} |
| 122 | + # DD_ENV: ci |
| 123 | + # run: | |
| 124 | + # npm install -g @datadog/datadog-ci |
| 125 | + # datadog-ci junit upload --service api-graphql _build/test/lib/*/test-junit-report.xml |
0 commit comments