72 lines
2.9 KiB
YAML
72 lines
2.9 KiB
YAML
name: Test & Deploy
|
|
on: push
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: erlef/setup-beam@v1
|
|
id: setup-beam
|
|
with:
|
|
version-type: strict
|
|
version-file: .tool-versions
|
|
- name: Cache deps
|
|
id: cache-deps
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-elixir-deps
|
|
with:
|
|
path: deps
|
|
key: ${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}-elixir-${{ steps.setup-beam.outputs.elixir-version }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}-elixir-${{ steps.setup-beam.outputs.elixir-version }}-mix-${{ env.cache-name }}-
|
|
|
|
# Step: Define how to cache the `_build` directory. After the first run,
|
|
# this speeds up tests runs a lot. This includes not re-compiling our
|
|
# project's downloaded deps every run.
|
|
- name: Cache compiled build
|
|
id: cache-build
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-compiled-build
|
|
with:
|
|
path: _build
|
|
key: ${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}-elixir-${{ steps.setup-beam.outputs.elixir-version }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}-elixir-${{ steps.setup-beam.outputs.elixir-version }}-mix-${{ env.cache-name }}-
|
|
${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}-elixir-${{ steps.setup-beam.outputs.elixir-version }}-mix-
|
|
|
|
# Step: Conditionally bust the cache when job is re-run.
|
|
# Sometimes, we may have issues with incremental builds that are fixed by
|
|
# doing a full recompile. In order to not waste dev time on such trivial
|
|
# issues (while also reaping the time savings of incremental builds for
|
|
# *most* day-to-day development), force a full recompile only on builds
|
|
# that are retried.
|
|
- name: Clean to rule out incremental build as a source of flakiness
|
|
if: github.run_attempt != '1'
|
|
run: |
|
|
mix deps.clean --all
|
|
mix clean
|
|
shell: sh
|
|
- run: mix deps.get
|
|
- run: mix deps.unlock --check-unused
|
|
- run: mix gettext.extract --check-up-to-date
|
|
- run: mix format --check-formatted
|
|
- run: mix test
|
|
|
|
deploy:
|
|
name: Deploy
|
|
needs: test
|
|
runs-on: ubuntu-24.04
|
|
environment: production
|
|
if: github.ref == 'refs/heads/main'
|
|
concurrency: deploy-group # optional: ensure only one action runs at a time
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: superfly/flyctl-actions/setup-flyctl@master
|
|
- run: flyctl deploy --remote-only
|
|
env:
|
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|