|
| 1 | +name: elixir |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + tags: |
| 7 | + - v* |
| 8 | + pull_request: |
| 9 | + workflow_dispatch: |
| 10 | + schedule: |
| 11 | + # Nightly run; execute daily at 07:37 AM UTC on main (default branch). This is an hour |
| 12 | + # after the Rust checks. |
| 13 | + - cron: '37 7 * * *' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +env: |
| 19 | + # cache-busting key -- change it if the build changes in a way that invalidates old |
| 20 | + # cached state |
| 21 | + cache_key: init |
| 22 | + |
| 23 | +jobs: |
| 24 | + build_test: |
| 25 | + name: compile, test, static checks (elixir ${{ matrix.elixir.label }}, otp ${{ matrix.otp.label }}, rust ${{ matrix.rust_toolchain.label }}) |
| 26 | + runs-on: linux-x86_64-16cpu |
| 27 | + |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + elixir: |
| 31 | + - version: 1.19.5 |
| 32 | + label: latest |
| 33 | + otp: |
| 34 | + - version: 28.4.2 |
| 35 | + label: latest |
| 36 | + rust_toolchain: |
| 37 | + - version: 1.94.0 |
| 38 | + label: latest |
| 39 | + |
| 40 | + defaults: |
| 41 | + run: |
| 42 | + working-directory: ts_elixir |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v6 |
| 47 | + |
| 48 | + - name: Cache mix |
| 49 | + id: cache-mix |
| 50 | + uses: actions/cache@v5 |
| 51 | + with: |
| 52 | + path: | |
| 53 | + ~/.mix |
| 54 | + ts_elixir/_build/ |
| 55 | + ts_elixir/deps/ |
| 56 | + key: ${{ runner.os }}-mix-${{ env.cache_key }}-elixir-${{ matrix.elixir.version }}-otp-${{ matrix.otp.version }}-${{ hashFiles('**/mix.lock') }} |
| 57 | + |
| 58 | + - name: Cache Rust |
| 59 | + id: cache-rust-elixir |
| 60 | + uses: actions/cache@v5 |
| 61 | + with: |
| 62 | + path: | |
| 63 | + ~/.cargo/bin/ |
| 64 | + ~/.cargo/registry/index/ |
| 65 | + ~/.cargo/registry/cache/ |
| 66 | + ~/.cargo/git/db/ |
| 67 | + ~/.rustup/toolchains |
| 68 | + target/ |
| 69 | + key: ${{ runner.os }}-elixir-rs-${{ env.cache_key }}-${{ matrix.rust_toolchain.version }}-${{ hashFiles('**/Cargo.lock') }} |
| 70 | + |
| 71 | + - name: Install elixir |
| 72 | + id: install-elixir |
| 73 | + uses: erlef/setup-beam@v1.24.0 |
| 74 | + with: |
| 75 | + otp-version: ${{ matrix.otp.version }} |
| 76 | + elixir-version: ${{ matrix.elixir.version }} |
| 77 | + |
| 78 | + - name: Install Rust toolchain |
| 79 | + id: install-rust-toolchain |
| 80 | + if: steps.cache-rust-elixir.outputs.cache-hit != 'true' |
| 81 | + uses: dtolnay/rust-toolchain@master |
| 82 | + with: |
| 83 | + toolchain: ${{ matrix.rust_toolchain.version }} |
| 84 | + |
| 85 | + - name: Install dependencies |
| 86 | + run: mix deps.get |
| 87 | + |
| 88 | + - name: Compile dependencies |
| 89 | + run: mix deps.compile |
| 90 | + |
| 91 | + - name: Compile (MIX_ENV=dev) |
| 92 | + run: mix compile --warnings-as-errors |
| 93 | + |
| 94 | + - name: Compile (MIX_ENV=prod) |
| 95 | + run: mix compile --warnings-as-errors |
| 96 | + env: |
| 97 | + MIX_ENV: prod |
| 98 | + |
| 99 | + - name: Format |
| 100 | + run: mix format --check-formatted |
| 101 | + |
| 102 | + - name: Test |
| 103 | + run: mix test |
| 104 | + env: |
| 105 | + # TODO(npry): testing tailnet + set TS_RS_TEST_AUTHKEY |
| 106 | + TS_RS_TEST_NET: 0 |
| 107 | + |
| 108 | + - name: Dialyzer |
| 109 | + run: mix dialyzer --format github |
| 110 | + |
| 111 | + - name: Credo |
| 112 | + run: mix credo list --format oneline |
| 113 | + |
| 114 | + - name: Docs |
| 115 | + run: mix docs --warnings-as-errors |
| 116 | + |
| 117 | + - name: Upload docs |
| 118 | + uses: actions/upload-artifact@v7 |
| 119 | + with: |
| 120 | + name: exdoc-${{ github.sha }} |
| 121 | + path: ts_elixir/doc |
| 122 | + retention-days: 7 |
0 commit comments