Skip to content

Commit 8549a0d

Browse files
committed
Define CI workflow to be directly usable when cloning
1 parent 474dafc commit 8549a0d

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

.github/workflows/continuous_integration.yml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ jobs:
3838
- name: Checkout code
3939
uses: actions/checkout@v6
4040

41-
- name: Setup Elixir and OTP
42-
uses: erlef/[email protected]
41+
- name: Read Elixir and Erlang versions from mise.toml
42+
id: versions
43+
run: |
44+
echo "elixir=$(sed -n 's|elixir = \"\(.*\)\"|\1|p' mise.toml)" >> "$GITHUB_OUTPUT"
45+
echo "erlang=$(sed -n 's|erlang = \"\(.*\)\"|\1|p' mise.toml)" >> "$GITHUB_OUTPUT"
46+
47+
- name: Setup Elixir and Erlang
48+
uses: erlef/setup-beam@v1
4349
id: setup-beam
4450
with:
45-
otp-version: '28'
46-
elixir-version: '1.19.2'
51+
otp-version: ${{ steps.versions.outputs.erlang }}
52+
elixir-version: ${{ steps.versions.outputs.elixir }}
4753

4854
# Whenever a cache hit occurs for the exact `key` match defined below, this step sets the `cache-hit` outputs to 'true'.
4955
# With `if: steps.cache-deps.outputs.cache-hit != 'true'`, this can be used in steps to run or ignore them based on the cache hit.
@@ -63,7 +69,7 @@ jobs:
6369
# Whenever a cache hit occurs for the exact `key` match defined below, this step sets the `cache-hit` outputs to 'true'.
6470
# With `if: steps.cache-build.outputs.cache-hit != 'true'`, this can be used in steps to run or ignore them based on the cache hit.
6571
# A partial key match via `restore-keys` or a cache miss will set `cache-hit` to 'false'.
66-
- name: Restore dependencies from cache if possible
72+
- name: Restore build from cache if possible
6773
uses: actions/cache@v5
6874
id: cache-build
6975
env:
@@ -76,15 +82,7 @@ jobs:
7682
${{ env.cache-name }}
7783
7884
79-
# CHANGEME: Remove this step, it's not needed for your project. It's only for the CI to run, while avoiding to track this code with Git
80-
- name: Create an empty Elixir project and add dependencies for the CI to run
81-
run: >
82-
mix new . &&
83-
mix escript.install --force hex mix_audit 2.1.5 &&
84-
mix escript.install --force hex credo 1.7.13 &&
85-
mix escript.install --force hex sobelow 0.14.1
86-
87-
- name: Install and compile dependencies
85+
- name: Install and compile dependencies # https://hexdocs.pm/mix/Mix.Tasks.Deps.Get.html & https://hexdocs.pm/mix/Mix.Tasks.Deps.Compile.html
8886
run: mix do deps.get + deps.compile
8987

9088
- name: Find unused dependencies # https://hexdocs.pm/mix/Mix.Tasks.Deps.Unlock.html
@@ -94,9 +92,7 @@ jobs:
9492
run: mix hex.audit
9593

9694
- name: Check for vulnerable dependencies # https://github.com/mirego/mix_audit
97-
run: mix_audit
98-
# CHANGEME: Replace the `run` line above with the `run` line below
99-
# run: mix deps.audit
95+
run: mix deps.audit
10096

10197
- name: Ensure Elixir code is formatted # https://hexdocs.pm/mix/Mix.Tasks.Format.html
10298
run: mix format --check-formatted
@@ -105,19 +101,17 @@ jobs:
105101
run: mix compile --all-warnings --warning-as-errors
106102

107103
- name: Lint Elixir code to enforce code consistency # Credo's strict analysis: https://hexdocs.pm/credo/basic_usage.html#strict-analysis
108-
run: credo --strict
109-
# CHANGEME: Replace the `run` line above with the `run` line below
110-
# run: mix credo --strict
104+
run: mix credo --strict
111105

112106
- name: Check Elixir code for security vulnerabilities # https://github.com/nccgroup/sobelow
113-
# `--private` is to prevent Sobelow from checking for updates, this is handled by Dependabot
114-
run: sobelow --private
115-
# CHANGEME: Replace the `run` line above with the `run` line below
116-
# run: mix sobelow --private
117-
118-
# CHANGEME: Uncomment this step if the project uses Ecto, otherwise delete this step
119-
# - name: Verify database migrations and if they can fully rollback # https://hexdocs.pm/ecto_sql/Mix.Tasks.Ecto.Rollback.html
120-
# run: mix ecto.create && mix ecto.migrate && mix ecto.rollback --all
107+
# `--private` is to prevent Sobelow from checking for updates, this does not belong in the CI
108+
run: mix sobelow --private
109+
110+
- name: Check Elixir code for type mismatches, unreachable code and other issues # https://hexdocs.pm/dialyxir/Mix.Tasks.Dialyzer.html
111+
run: mix dialyzer --list-unused-filters --format github
112+
113+
- name: Verify database migrations and if they can fully rollback # https://hexdocs.pm/ecto_sql/Mix.Tasks.Ecto.Rollback.html
114+
run: mix ecto.create && mix ecto.migrate && mix ecto.rollback --all
121115

122116
- name: Run tests # https://hexdocs.pm/mix/Mix.Tasks.Test.html
123117
run: mix test

0 commit comments

Comments
 (0)