From 5257bd95a5a60de2c786a410e1796fe3a1710e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:05:40 +0100 Subject: [PATCH 01/10] Setup CI --- .formatter.exs | 6 +- .github/github_workflows.ex | 259 ++++++++++++++++++++ .github/workflows/ci.yml | 263 +++++++++++++++++++++ lib/mix/tasks/github_workflows.generate.ex | 2 +- 4 files changed, 528 insertions(+), 2 deletions(-) create mode 100644 .github/github_workflows.ex create mode 100644 .github/workflows/ci.yml diff --git a/.formatter.exs b/.formatter.exs index 4d5fa61..734ad7f 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,8 @@ # Used by "mix format" [ - inputs: ["{mix,.credo,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: [ + "{mix,.credo,.formatter}.exs", + ".github/github_workflows.ex", + "{config,lib,test}/**/*.{ex,exs}" + ] ] diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex new file mode 100644 index 0000000..f84dbd2 --- /dev/null +++ b/.github/github_workflows.ex @@ -0,0 +1,259 @@ +defmodule GithubWorkflows do + @moduledoc false + + def get do + %{ + "ci.yml" => ci_workflow() + } + end + + defp ci_workflow do + [ + [ + name: "CI", + on: [ + pull_request: [], + push: [ + branches: ["main"] + ] + ], + jobs: [ + compile: compile_job(), + credo: credo_job(), + deps_audit: deps_audit_job(), + dialyzer: dialyzer_job(), + format: format_job(), + hex_audit: hex_audit_job(), + prettier: prettier_job(), + test: test_job(), + unused_deps: unused_deps_job() + ] + ] + ] + end + + defp compile_job do + elixir_job("Install deps and compile", + steps: [ + [ + name: "Install Elixir dependencies", + env: [MIX_ENV: "test"], + run: "mix deps.get" + ], + [ + name: "Compile", + env: [MIX_ENV: "test"], + run: "mix compile" + ] + ] + ) + end + + defp credo_job do + elixir_job("Credo", + needs: :compile, + steps: [ + [ + name: "Check code style", + env: [MIX_ENV: "test"], + run: "mix credo --strict" + ] + ] + ) + end + + defp deps_audit_job do + elixir_job("Deps audit", + needs: :compile, + steps: [ + [ + name: "Check for vulnerable Mix dependencies", + env: [MIX_ENV: "test"], + run: "mix deps.audit" + ] + ] + ) + end + + defp dialyzer_job do + cache_key_prefix = "plt-${{ runner.os }}" + + elixir_job("Dialyzer", + needs: :compile, + steps: [ + [ + name: "Restore PLT cache", + uses: "actions/cache@v3", + with: + [ + path: "priv/plts" + ] ++ cache_opts(cache_key_prefix) + ], + [ + name: "Create PLTs", + env: [MIX_ENV: "test"], + run: "mix dialyzer --plt" + ], + [ + name: "Run dialyzer", + env: [MIX_ENV: "test"], + run: "mix dialyzer --format short 2>&1" + ] + ] + ) + end + + defp elixir_job(name, opts) do + needs = Keyword.get(opts, :needs) + steps = Keyword.get(opts, :steps, []) + + cache_key_prefix = "mix-${{ runner.os }}" + + job = [ + name: name, + "runs-on": "ubuntu-latest", + strategy: [ + matrix: [ + versions: [ + %{ + elixir: "1.11", + otp: "21.3" + }, + %{ + elixir: "1.16", + otp: "26.2" + } + ] + ] + ], + steps: + [ + checkout_step(), + [ + name: "Set up Elixir", + uses: "erlef/setup-beam@v1", + with: [ + "elixir-version": "${{ matrix.versions.elixir }}", + "otp-version": "${{ matrix.versions.otp }}" + ] + ], + [ + uses: "actions/cache@v3", + with: + [ + path: ~S""" + _build + deps + """ + ] ++ cache_opts(cache_key_prefix) + ] + ] ++ steps + ] + + if needs do + Keyword.put(job, :needs, needs) + else + job + end + end + + defp format_job do + elixir_job("Format", + needs: :compile, + steps: [ + [ + name: "Check Elixir formatting", + env: [MIX_ENV: "test"], + run: "mix format --check-formatted" + ] + ] + ) + end + + defp hex_audit_job do + elixir_job("Hex audit", + needs: :compile, + steps: [ + [ + name: "Check for retired Hex packages", + env: [MIX_ENV: "test"], + run: "mix hex.audit" + ] + ] + ) + end + + defp prettier_job do + [ + name: "Check formatting using Prettier", + "runs-on": "ubuntu-latest", + steps: [ + checkout_step(), + [ + name: "Restore npm cache", + uses: "actions/cache@v3", + id: "npm-cache", + with: [ + path: "~/.npm", + key: "${{ runner.os }}-npm" + ] + ], + [ + name: "Install Prettier", + if: "steps.npm-cache.outputs.cache-hit != 'true'", + run: "npm i -g prettier" + ], + [ + name: "Run Prettier", + run: "npx prettier -c ." + ] + ] + ] + end + + defp test_job do + elixir_job("Test", + needs: :compile, + steps: [ + [ + name: "Run tests", + env: [ + MIX_ENV: "test", + MUX_CREDENTIALS_EMAIL: "${{ secrets.MUX_CREDENTIALS_EMAIL }}", + MUX_CREDENTIALS_PASSWORD: "${{ secrets.MUX_CREDENTIALS_PASSWORD }}" + ], + run: "mix test --cover --warnings-as-errors" + ] + ] + ) + end + + defp unused_deps_job do + elixir_job("Check unused deps", + needs: :compile, + steps: [ + [ + name: "Check for unused Mix dependencies", + env: [MIX_ENV: "test"], + run: "mix deps.unlock --check-unused" + ] + ] + ) + end + + defp checkout_step do + [ + name: "Checkout", + uses: "actions/checkout@v4" + ] + end + + defp cache_opts(prefix) do + [ + key: "#{prefix}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }}", + "restore-keys": ~s""" + #{prefix}- + """ + ] + end +end diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7c44a50 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,263 @@ +name: CI +on: + pull_request: [] + push: + branches: + - main +jobs: + compile: + name: Install deps and compile + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Install Elixir dependencies + env: + MIX_ENV: test + run: mix deps.get + - name: Compile + env: + MIX_ENV: test + run: mix compile + credo: + needs: compile + name: Credo + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Check code style + env: + MIX_ENV: test + run: mix credo --strict + deps_audit: + needs: compile + name: Deps audit + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Check for vulnerable Mix dependencies + env: + MIX_ENV: test + run: mix deps.audit + dialyzer: + needs: compile + name: Dialyzer + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Restore PLT cache + uses: actions/cache@v3 + with: + path: priv/plts + key: plt-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: plt-${{ runner.os }}- + - name: Create PLTs + env: + MIX_ENV: test + run: mix dialyzer --plt + - name: Run dialyzer + env: + MIX_ENV: test + run: mix dialyzer --format short 2>&1 + format: + needs: compile + name: Format + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Check Elixir formatting + env: + MIX_ENV: test + run: mix format --check-formatted + hex_audit: + needs: compile + name: Hex audit + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Check for retired Hex packages + env: + MIX_ENV: test + run: mix hex.audit + prettier: + name: Check formatting using Prettier + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Restore npm cache + uses: actions/cache@v3 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-npm + - name: Install Prettier + if: steps.npm-cache.outputs.cache-hit != 'true' + run: npm i -g prettier + - name: Run Prettier + run: npx prettier -c . + test: + needs: compile + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Run tests + env: + MIX_ENV: test + MUX_CREDENTIALS_EMAIL: ${{ secrets.MUX_CREDENTIALS_EMAIL }} + MUX_CREDENTIALS_PASSWORD: ${{ secrets.MUX_CREDENTIALS_PASSWORD }} + run: mix test --cover --warnings-as-errors + unused_deps: + needs: compile + name: Check unused deps + runs-on: ubuntu-latest + strategy: + matrix: + versions: + - otp: 21.3 + elixir: 1.11 + - otp: 26.2 + elixir: 1.16 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.versions.elixir }} + otp-version: ${{ matrix.versions.otp }} + - uses: actions/cache@v3 + with: + path: "_build\ndeps" + key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ runner.os }}- + - name: Check for unused Mix dependencies + env: + MIX_ENV: test + run: mix deps.unlock --check-unused diff --git a/lib/mix/tasks/github_workflows.generate.ex b/lib/mix/tasks/github_workflows.generate.ex index 33e3cb7..e16518e 100644 --- a/lib/mix/tasks/github_workflows.generate.ex +++ b/lib/mix/tasks/github_workflows.generate.ex @@ -136,7 +136,7 @@ defmodule Mix.Tasks.GithubWorkflows.Generate do ``` More complex workflows can be found here: - https://github.com/optimumBA/phx.tools/blob/main/.github/github_workflows.ex + https://github.com/optimumBA/github_workflows_generator/blob/main/.github/github_workflows.ex """ From be2752fc9fac1741b208493f3faf54b54fddc4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:15:51 +0100 Subject: [PATCH 02/10] Fix missing OTP version error --- .github/github_workflows.ex | 6 ++++-- .github/workflows/ci.yml | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index f84dbd2..c1f55bd 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -1,6 +1,8 @@ defmodule GithubWorkflows do @moduledoc false + @runner_image "ubuntu-20.04" + def get do %{ "ci.yml" => ci_workflow() @@ -111,7 +113,7 @@ defmodule GithubWorkflows do job = [ name: name, - "runs-on": "ubuntu-latest", + "runs-on": @runner_image, strategy: [ matrix: [ versions: [ @@ -186,7 +188,7 @@ defmodule GithubWorkflows do defp prettier_job do [ name: "Check formatting using Prettier", - "runs-on": "ubuntu-latest", + "runs-on": @runner_image, steps: [ checkout_step(), [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c44a50..a2ca039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: jobs: compile: name: Install deps and compile - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -39,7 +39,7 @@ jobs: credo: needs: compile name: Credo - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -67,7 +67,7 @@ jobs: deps_audit: needs: compile name: Deps audit - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -95,7 +95,7 @@ jobs: dialyzer: needs: compile name: Dialyzer - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -133,7 +133,7 @@ jobs: format: needs: compile name: Format - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -161,7 +161,7 @@ jobs: hex_audit: needs: compile name: Hex audit - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -188,7 +188,7 @@ jobs: run: mix hex.audit prettier: name: Check formatting using Prettier - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v4 @@ -206,7 +206,7 @@ jobs: test: needs: compile name: Test - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: @@ -236,7 +236,7 @@ jobs: unused_deps: needs: compile name: Check unused deps - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: versions: From d7cc5c528e49be3e533a3330a4d2182e5601bb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:22:35 +0100 Subject: [PATCH 03/10] Continue running CI when other jobs fail --- .github/github_workflows.ex | 1 + .github/workflows/ci.yml | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index c1f55bd..635f202 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -115,6 +115,7 @@ defmodule GithubWorkflows do name: name, "runs-on": @runner_image, strategy: [ + "fail-fast": false, matrix: [ versions: [ %{ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2ca039..6cfbef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ jobs: name: Install deps and compile runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -41,6 +42,7 @@ jobs: name: Credo runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -69,6 +71,7 @@ jobs: name: Deps audit runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -97,6 +100,7 @@ jobs: name: Dialyzer runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -135,6 +139,7 @@ jobs: name: Format runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -163,6 +168,7 @@ jobs: name: Hex audit runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -208,6 +214,7 @@ jobs: name: Test runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 @@ -238,6 +245,7 @@ jobs: name: Check unused deps runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: versions: - otp: 21.3 From 686d99fef964b757fdb242279b0bad835c92ed29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:29:18 +0100 Subject: [PATCH 04/10] Use different runner depending on the OTP version --- .github/github_workflows.ex | 27 +++++++------- .github/workflows/ci.yml | 70 +++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index 635f202..0840a49 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -1,8 +1,6 @@ defmodule GithubWorkflows do @moduledoc false - @runner_image "ubuntu-20.04" - def get do %{ "ci.yml" => ci_workflow() @@ -78,8 +76,6 @@ defmodule GithubWorkflows do end defp dialyzer_job do - cache_key_prefix = "plt-${{ runner.os }}" - elixir_job("Dialyzer", needs: :compile, steps: [ @@ -89,7 +85,7 @@ defmodule GithubWorkflows do with: [ path: "priv/plts" - ] ++ cache_opts(cache_key_prefix) + ] ++ cache_opts(prefix: "plt") ], [ name: "Create PLTs", @@ -109,22 +105,22 @@ defmodule GithubWorkflows do needs = Keyword.get(opts, :needs) steps = Keyword.get(opts, :steps, []) - cache_key_prefix = "mix-${{ runner.os }}" - job = [ name: name, - "runs-on": @runner_image, + "runs-on": "${{ matrix.versions.runner-image }}", strategy: [ "fail-fast": false, matrix: [ versions: [ %{ elixir: "1.11", - otp: "21.3" + otp: "21.3", + "runner-image": "ubuntu-20.04" }, %{ elixir: "1.16", - otp: "26.2" + otp: "26.2", + "runner-image": "ubuntu-latest" } ] ] @@ -148,7 +144,7 @@ defmodule GithubWorkflows do _build deps """ - ] ++ cache_opts(cache_key_prefix) + ] ++ cache_opts(prefix: "mix") ] ] ++ steps ] @@ -189,7 +185,7 @@ defmodule GithubWorkflows do defp prettier_job do [ name: "Check formatting using Prettier", - "runs-on": @runner_image, + "runs-on": "${{ matrix.versions.runner-image }}", steps: [ checkout_step(), [ @@ -251,9 +247,12 @@ defmodule GithubWorkflows do ] end - defp cache_opts(prefix) do + defp cache_opts(opts) do + prefix = Keyword.get(opts, :prefix) + [ - key: "#{prefix}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }}", + key: + "#{prefix}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }}", "restore-keys": ~s""" #{prefix}- """ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cfbef6..6780b28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,15 +7,17 @@ on: jobs: compile: name: Install deps and compile - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -27,8 +29,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Install Elixir dependencies env: MIX_ENV: test @@ -40,15 +42,17 @@ jobs: credo: needs: compile name: Credo - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -60,8 +64,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Check code style env: MIX_ENV: test @@ -69,15 +73,17 @@ jobs: deps_audit: needs: compile name: Deps audit - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -89,8 +95,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Check for vulnerable Mix dependencies env: MIX_ENV: test @@ -98,15 +104,17 @@ jobs: dialyzer: needs: compile name: Dialyzer - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -118,14 +126,14 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Restore PLT cache uses: actions/cache@v3 with: path: priv/plts - key: plt-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: plt-${{ runner.os }}- + key: plt-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: plt- - name: Create PLTs env: MIX_ENV: test @@ -137,15 +145,17 @@ jobs: format: needs: compile name: Format - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -157,8 +167,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Check Elixir formatting env: MIX_ENV: test @@ -166,15 +176,17 @@ jobs: hex_audit: needs: compile name: Hex audit - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -186,15 +198,15 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Check for retired Hex packages env: MIX_ENV: test run: mix hex.audit prettier: name: Check formatting using Prettier - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} steps: - name: Checkout uses: actions/checkout@v4 @@ -212,15 +224,17 @@ jobs: test: needs: compile name: Test - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -232,8 +246,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Run tests env: MIX_ENV: test @@ -243,15 +257,17 @@ jobs: unused_deps: needs: compile name: Check unused deps - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.versions.runner-image }} strategy: fail-fast: false matrix: versions: - otp: 21.3 elixir: 1.11 + runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 + runner-image: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -263,8 +279,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ runner.os }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix-${{ runner.os }}- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix- - name: Check for unused Mix dependencies env: MIX_ENV: test From e852c9b2d3f932de193f169e6b7f77d794662b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:31:42 +0100 Subject: [PATCH 05/10] Fix missing flag error --- .github/github_workflows.ex | 2 +- .github/workflows/ci.yml | 2 +- mix.exs | 1 - test/test_helper.exs | 3 +++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index 0840a49..c70c3c7 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -221,7 +221,7 @@ defmodule GithubWorkflows do MUX_CREDENTIALS_EMAIL: "${{ secrets.MUX_CREDENTIALS_EMAIL }}", MUX_CREDENTIALS_PASSWORD: "${{ secrets.MUX_CREDENTIALS_PASSWORD }}" ], - run: "mix test --cover --warnings-as-errors" + run: "mix test --cover" ] ] ) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6780b28..f488f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -253,7 +253,7 @@ jobs: MIX_ENV: test MUX_CREDENTIALS_EMAIL: ${{ secrets.MUX_CREDENTIALS_EMAIL }} MUX_CREDENTIALS_PASSWORD: ${{ secrets.MUX_CREDENTIALS_PASSWORD }} - run: mix test --cover --warnings-as-errors + run: mix test --cover unused_deps: needs: compile name: Check unused deps diff --git a/mix.exs b/mix.exs index 98c1e64..196c8dc 100644 --- a/mix.exs +++ b/mix.exs @@ -59,7 +59,6 @@ defmodule GithubWorkflowsGenerator.MixProject do "hex.audit", "format --check-formatted", "cmd npx prettier -c .", - "compile --force --warnings-as-errors", "credo --strict", "dialyzer", "coveralls" diff --git a/test/test_helper.exs b/test/test_helper.exs index 869559e..79f403a 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1 +1,4 @@ +# TODO: Remove when Elixir v1.11 gets deprecated +Code.put_compiler_option(:warnings_as_errors, true) + ExUnit.start() From 0d89d387fd9a306c76ec24867995520615140def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:45:44 +0100 Subject: [PATCH 06/10] Try newer versions --- .github/github_workflows.ex | 6 +++--- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- mix.exs | 3 ++- test/test_helper.exs | 3 --- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index c70c3c7..47883a7 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -113,8 +113,8 @@ defmodule GithubWorkflows do matrix: [ versions: [ %{ - elixir: "1.11", - otp: "21.3", + elixir: "1.12", + otp: "22.3", "runner-image": "ubuntu-20.04" }, %{ @@ -221,7 +221,7 @@ defmodule GithubWorkflows do MUX_CREDENTIALS_EMAIL: "${{ secrets.MUX_CREDENTIALS_EMAIL }}", MUX_CREDENTIALS_PASSWORD: "${{ secrets.MUX_CREDENTIALS_PASSWORD }}" ], - run: "mix test --cover" + run: "mix test --cover --warnings-as-errors" ] ] ) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f488f40..b2cc3ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -47,8 +47,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -78,8 +78,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -109,8 +109,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -150,8 +150,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -181,8 +181,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -229,8 +229,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -253,7 +253,7 @@ jobs: MIX_ENV: test MUX_CREDENTIALS_EMAIL: ${{ secrets.MUX_CREDENTIALS_EMAIL }} MUX_CREDENTIALS_PASSWORD: ${{ secrets.MUX_CREDENTIALS_PASSWORD }} - run: mix test --cover + run: mix test --cover --warnings-as-errors unused_deps: needs: compile name: Check unused deps @@ -262,8 +262,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 21.3 - elixir: 1.11 + - otp: 22.3 + elixir: 1.12 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 diff --git a/mix.exs b/mix.exs index 196c8dc..9fa7674 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule GithubWorkflowsGenerator.MixProject do [ app: :github_workflows_generator, version: "0.1.0", - elixir: "~> 1.11", + elixir: "~> 1.12", start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), @@ -59,6 +59,7 @@ defmodule GithubWorkflowsGenerator.MixProject do "hex.audit", "format --check-formatted", "cmd npx prettier -c .", + "compile --force --warnings-as-errors", "credo --strict", "dialyzer", "coveralls" diff --git a/test/test_helper.exs b/test/test_helper.exs index 79f403a..869559e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,4 +1 @@ -# TODO: Remove when Elixir v1.11 gets deprecated -Code.put_compiler_option(:warnings_as_errors, true) - ExUnit.start() From dcf8fa3c61eacb46cbef6f83ca31b530b5e49532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:52:10 +0100 Subject: [PATCH 07/10] Revert "Try newer versions" This reverts commit 0d89d387fd9a306c76ec24867995520615140def. --- .github/github_workflows.ex | 6 +++--- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- mix.exs | 3 +-- test/test_helper.exs | 3 +++ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index 47883a7..c70c3c7 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -113,8 +113,8 @@ defmodule GithubWorkflows do matrix: [ versions: [ %{ - elixir: "1.12", - otp: "22.3", + elixir: "1.11", + otp: "21.3", "runner-image": "ubuntu-20.04" }, %{ @@ -221,7 +221,7 @@ defmodule GithubWorkflows do MUX_CREDENTIALS_EMAIL: "${{ secrets.MUX_CREDENTIALS_EMAIL }}", MUX_CREDENTIALS_PASSWORD: "${{ secrets.MUX_CREDENTIALS_PASSWORD }}" ], - run: "mix test --cover --warnings-as-errors" + run: "mix test --cover" ] ] ) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2cc3ea..f488f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -47,8 +47,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -78,8 +78,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -109,8 +109,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -150,8 +150,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -181,8 +181,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -229,8 +229,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 @@ -253,7 +253,7 @@ jobs: MIX_ENV: test MUX_CREDENTIALS_EMAIL: ${{ secrets.MUX_CREDENTIALS_EMAIL }} MUX_CREDENTIALS_PASSWORD: ${{ secrets.MUX_CREDENTIALS_PASSWORD }} - run: mix test --cover --warnings-as-errors + run: mix test --cover unused_deps: needs: compile name: Check unused deps @@ -262,8 +262,8 @@ jobs: fail-fast: false matrix: versions: - - otp: 22.3 - elixir: 1.12 + - otp: 21.3 + elixir: 1.11 runner-image: ubuntu-20.04 - otp: 26.2 elixir: 1.16 diff --git a/mix.exs b/mix.exs index 9fa7674..196c8dc 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule GithubWorkflowsGenerator.MixProject do [ app: :github_workflows_generator, version: "0.1.0", - elixir: "~> 1.12", + elixir: "~> 1.11", start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), @@ -59,7 +59,6 @@ defmodule GithubWorkflowsGenerator.MixProject do "hex.audit", "format --check-formatted", "cmd npx prettier -c .", - "compile --force --warnings-as-errors", "credo --strict", "dialyzer", "coveralls" diff --git a/test/test_helper.exs b/test/test_helper.exs index 869559e..79f403a 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1 +1,4 @@ +# TODO: Remove when Elixir v1.11 gets deprecated +Code.put_compiler_option(:warnings_as_errors, true) + ExUnit.start() From d8f5d596db1b1771e6e9c96b304dbfa09de3593a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:55:31 +0100 Subject: [PATCH 08/10] Fix dependecy errors caused by mixing OTP versions --- .github/github_workflows.ex | 4 ++-- .github/workflows/ci.yml | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index c70c3c7..4c7d121 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -85,7 +85,7 @@ defmodule GithubWorkflows do with: [ path: "priv/plts" - ] ++ cache_opts(prefix: "plt") + ] ++ cache_opts(prefix: "plt-${{ matrix.versions.runner-image }}") ], [ name: "Create PLTs", @@ -144,7 +144,7 @@ defmodule GithubWorkflows do _build deps """ - ] ++ cache_opts(prefix: "mix") + ] ++ cache_opts(prefix: "mix-${{ matrix.versions.runner-image }}") ] ] ++ steps ] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f488f40..9360618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,8 +29,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Install Elixir dependencies env: MIX_ENV: test @@ -64,8 +64,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check code style env: MIX_ENV: test @@ -95,8 +95,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for vulnerable Mix dependencies env: MIX_ENV: test @@ -126,14 +126,14 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Restore PLT cache uses: actions/cache@v3 with: path: priv/plts - key: plt-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: plt- + key: plt-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: plt-${{ matrix.versions.runner-image }}- - name: Create PLTs env: MIX_ENV: test @@ -167,8 +167,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check Elixir formatting env: MIX_ENV: test @@ -198,8 +198,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for retired Hex packages env: MIX_ENV: test @@ -246,8 +246,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Run tests env: MIX_ENV: test @@ -279,8 +279,8 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} - restore-keys: mix- + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for unused Mix dependencies env: MIX_ENV: test From 2e7f92429c7d4ad8bb781daf2269beae50ea5d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:58:01 +0100 Subject: [PATCH 09/10] Fix prettier job not running --- .github/github_workflows.ex | 4 ++-- .github/workflows/ci.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index 4c7d121..d4a5b0b 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -185,7 +185,7 @@ defmodule GithubWorkflows do defp prettier_job do [ name: "Check formatting using Prettier", - "runs-on": "${{ matrix.versions.runner-image }}", + "runs-on": "ubuntu-latest", steps: [ checkout_step(), [ @@ -194,7 +194,7 @@ defmodule GithubWorkflows do id: "npm-cache", with: [ path: "~/.npm", - key: "${{ runner.os }}-npm" + key: "npm-ubuntu-latest" ] ], [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9360618..343c0fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -206,7 +206,7 @@ jobs: run: mix hex.audit prettier: name: Check formatting using Prettier - runs-on: ${{ matrix.versions.runner-image }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -215,7 +215,7 @@ jobs: id: npm-cache with: path: ~/.npm - key: ${{ runner.os }}-npm + key: npm-ubuntu-latest - name: Install Prettier if: steps.npm-cache.outputs.cache-hit != 'true' run: npm i -g prettier From 58354e73ecee98858048763be23148d5e6e74c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Thu, 1 Feb 2024 18:59:25 +0100 Subject: [PATCH 10/10] Remove redundant cache key part --- .github/github_workflows.ex | 3 +-- .github/workflows/ci.yml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index d4a5b0b..4caaed8 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -251,8 +251,7 @@ defmodule GithubWorkflows do prefix = Keyword.get(opts, :prefix) [ - key: - "#{prefix}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }}", + key: "#{prefix}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }}", "restore-keys": ~s""" #{prefix}- """ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 343c0fb..a7fa00f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Install Elixir dependencies env: @@ -64,7 +64,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check code style env: @@ -95,7 +95,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for vulnerable Mix dependencies env: @@ -126,13 +126,13 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Restore PLT cache uses: actions/cache@v3 with: path: priv/plts - key: plt-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: plt-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: plt-${{ matrix.versions.runner-image }}- - name: Create PLTs env: @@ -167,7 +167,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check Elixir formatting env: @@ -198,7 +198,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for retired Hex packages env: @@ -246,7 +246,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Run tests env: @@ -279,7 +279,7 @@ jobs: - uses: actions/cache@v3 with: path: "_build\ndeps" - key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} + key: mix-${{ matrix.versions.runner-image }}-${{ matrix.versions.otp }}-${{ matrix.versions.elixir }}-${{ github.sha }} restore-keys: mix-${{ matrix.versions.runner-image }}- - name: Check for unused Mix dependencies env: