v1.0.0 (I hope) #57
This file contains 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: "CI Pipeline" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- ready_for_review | |
concurrency: | |
group: pipeline-${{ github.event.repository.name }}-${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
pipeline: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
otp: ["26.2"] | |
elixir: ["1.18.1", "1.17.3", "1.16.3"] | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
id: beam | |
with: | |
otp-version: ${{matrix.otp}} | |
elixir-version: ${{matrix.elixir}} | |
- name: Cache deps | |
id: cache-deps | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-elixir-deps | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
${{ runner.os }}-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 }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
${{ runner.os }}-mix-${{ env.cache-name }}- | |
${{ runner.os }}-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 | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Check for unused deps | |
run: mix deps.unlock --check-unused | |
- name: Compiles without warnings | |
run: mix compile --warnings-as-errors | |
- name: Check Formatting | |
run: mix format --check-formatted | |
- name: Lint with Credo | |
run: mix credo | |
- name: Restore PLT cache | |
id: plt_cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: | | |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}- | |
path: | | |
priv/plts | |
# Create PLTs if no cache was found | |
- name: Create PLTs | |
if: steps.plt_cache.outputs.cache-hit != 'true' | |
run: mix dialyzer --plt | |
# By default, the GitHub Cache action will only save the cache if all steps in the job succeed, | |
# so we separate the cache restore and save steps in case running dialyzer fails. | |
- name: Save PLT cache | |
id: plt_cache_save | |
uses: actions/cache/save@v4 | |
if: steps.plt_cache.outputs.cache-hit != 'true' | |
with: | |
key: | | |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} | |
path: | | |
priv/plts | |
- name: Run Dialyzer | |
run: mix dialyzer --format github | |
- name: Start EPMD for tests | |
run: epmd -daemon | |
- name: Initialize Docker Compose Environment for Testing | |
run: docker compose up -d | |
- name: Sleep for 30 seconds to allow compose environment to launch | |
run: sleep 30s | |
shell: bash | |
- name: Run tests | |
run: mix test | |
- name: Generate systemd Service Example | |
run: mix run scripts/systemd_service.exs | |
- name: systemd-analyze of Service Example | |
run: systemd-analyze verify example_systemd_service.service | |
- name: Generate start.sh Script Example | |
run: mix run scripts/start_sh.exs | |
- name: Shellcheck Lint of Example Compressed start.sh | |
run: shellcheck example_start_compressed.sh | |
- name: Shellcheck Lint of Example Uncompressed start.sh | |
run: shellcheck example_start_uncompressed.sh |