CI: cache JPL ephemeris with retry to avoid flaky NASA downloads #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Elixir CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| MIX_ENV: test | |
| LOCALIZE_DEFAULT_LOCALE: en | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: "Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}${{ matrix.lint && ' (lint)' || '' }}" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Elixir 1.17 — supports OTP 25–27 | |
| - elixir: "1.17-otp-26" | |
| otp: "26" | |
| - elixir: "1.17-otp-27" | |
| otp: "27" | |
| # Elixir 1.18 — supports OTP 25–27 | |
| - elixir: "1.18-otp-26" | |
| otp: "26" | |
| - elixir: "1.18-otp-27" | |
| otp: "27" | |
| # Elixir 1.19 — supports OTP 26–28 | |
| - elixir: "1.19-otp-26" | |
| otp: "26" | |
| - elixir: "1.19-otp-27" | |
| otp: "27" | |
| - elixir: "1.19-otp-28" | |
| otp: "28" | |
| # Elixir 1.20 — supports OTP 27–29 | |
| - elixir: "1.20.0-rc.5-otp-27" | |
| otp: "27" | |
| - elixir: "1.20.0-rc.5-otp-28" | |
| otp: "28" | |
| - elixir: "1.20.0-rc.5-otp-29" | |
| otp: "29" | |
| lint: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ matrix.elixir }} | |
| otp-version: ${{ matrix.otp }} | |
| - name: Restore dependency cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: mix-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('mix.lock') }} | |
| restore-keys: | | |
| mix-${{ matrix.elixir }}-${{ matrix.otp }}- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| # The astro dependency needs the JPL DE440s ephemeris (~32 MB) at compile | |
| # time (to compute Persian era boundaries) and during tests. NAIF's server | |
| # is slow and occasionally times out, so cache the file across runs and only | |
| # hit the network on a cache miss. The path matches astro's runtime resolver | |
| # (`:filename.basedir(:user_cache, "astro")`), so compile and tests find it | |
| # without extra configuration. The key is constant because the file never | |
| # changes; bump it if the ephemeris is ever replaced. | |
| - name: Cache JPL ephemeris | |
| id: cache-ephemeris | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/astro | |
| key: astro-ephemeris-de440s | |
| - name: Install ephemeris | |
| if: steps.cache-ephemeris.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p ~/.cache/astro | |
| for i in 1 2 3; do | |
| if mix astro.download_ephemeris --dest ~/.cache/astro/de440s.bsp; then | |
| exit 0 | |
| fi | |
| echo "Ephemeris download attempt $i failed; retrying in 15s..." | |
| sleep 15 | |
| done | |
| echo "Ephemeris download failed after 3 attempts" >&2 | |
| exit 1 | |
| - name: Check formatting | |
| if: matrix.lint | |
| run: mix format --check-formatted | |
| - name: Compile (warnings as errors) | |
| run: mix compile --warnings-as-errors | |
| - name: Run tests | |
| run: mix test | |
| - name: Restore PLT cache | |
| if: matrix.lint | |
| uses: actions/cache@v5 | |
| with: | |
| path: _build/dev/dialyxir_* | |
| key: plt-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('mix.lock') }} | |
| restore-keys: | | |
| plt-${{ matrix.elixir }}-${{ matrix.otp }}- | |
| - name: Run dialyzer | |
| if: matrix.lint | |
| env: | |
| MIX_ENV: dev | |
| run: mix dialyzer |