From fa0e1f48e4dd4f06fc83755fd0341ec95b4d16d3 Mon Sep 17 00:00:00 2001
From: Sloane <sloane@perrault.email>
Date: Thu, 6 Jul 2023 16:19:01 -0400
Subject: [PATCH] Lower Elixir and OTP requirement to 1.11, OTP 21 (#12)

* lower elixir requirement, expand testing matrix

* use simpler versions

* downgrade ubuntu version, don't fail fast

* use elixir & otp versions in cache names
---
 .github/workflows/ci.yaml | 33 ++++++++++++++++++++-------------
 mix.exs                   |  2 +-
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 9140ce6..b603f70 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -14,21 +14,26 @@ permissions:
 
 jobs:
   test:
-    runs-on: ubuntu-latest
-    name: Test on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
+    runs-on: ubuntu-20.04
+    name: Test on OTP ${{matrix.pair.otp}} / Elixir ${{matrix.pair.elixir}}
     strategy:
-      # Specify the OTP and Elixir versions to use when building
-      # and running the workflow steps.
+      fail-fast: false
       matrix:
-        otp: ['26.0.2']       # Define the OTP version [required]
-        elixir: ['1.15.0']    # Define the elixir version [required]
+        include:
+          - pair:
+              elixir: '1.11'
+              otp: '21'
+          - pair:
+              elixir: '1.15'
+              otp: '26'
+            lint: lint
     steps:
     # Step: Setup Elixir + Erlang image as the base.
     - name: Set up Elixir
       uses: erlef/setup-beam@v1
       with:
-        otp-version: ${{matrix.otp}}
-        elixir-version: ${{matrix.elixir}}
+        otp-version: ${{matrix.pair.otp}}
+        elixir-version: ${{matrix.pair.elixir}}
 
     # Step: Check out the code.
     - name: Checkout code
@@ -42,9 +47,9 @@ jobs:
         cache-name: cache-elixir-deps
       with:
         path: deps
-        key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
+        key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
         restore-keys: |
-          ${{ runner.os }}-mix-${{ env.cache-name }}-
+          ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ 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
@@ -56,10 +61,10 @@ jobs:
         cache-name: cache-compiled-build
       with:
         path: _build
-        key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
+        key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
         restore-keys: |
-          ${{ runner.os }}-mix-${{ env.cache-name }}-
-          ${{ runner.os }}-mix-
+          ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ env.cache-name }}-
+          ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-
 
     # Step: Conditionally bust the cache when job is re-run.
     # Sometimes, we may have issues with incremental builds that are fixed by
@@ -83,12 +88,14 @@ jobs:
     # Customize this step if a different behavior is desired.
     - name: Compiles without warnings
       run: mix compile --warnings-as-errors
+      if: ${{ matrix.lint }}
 
     # Step: Check that the checked in code has already been formatted.
     # This step fails if something was found unformatted.
     # Customize this step as desired.
     - name: Check Formatting
       run: mix format --check-formatted
+      if: ${{ matrix.lint }}
 
     # Step: Execute the tests.
     - name: Run tests
diff --git a/mix.exs b/mix.exs
index 013f8a5..e2a8fd2 100644
--- a/mix.exs
+++ b/mix.exs
@@ -7,7 +7,7 @@ defmodule TypeID.MixProject do
     [
       app: :typeid_elixir,
       version: @version,
-      elixir: "~> 1.15",
+      elixir: "~> 1.11",
       start_permanent: Mix.env() == :prod,
       description: description(),
       package: package(),