From dcefa6e7983cefd00dc96700a5761d573635b675 Mon Sep 17 00:00:00 2001 From: Argonus Date: Thu, 30 Nov 2023 13:13:15 +0100 Subject: [PATCH 1/2] Update workflows to follow same pattern as kafak ex --- .github/workflows/checks.yml | 104 +++++++++++++++++++++++++++++++++ .github/workflows/elixir.yml | 49 ---------------- .github/workflows/test.yml | 110 +++++++++++++++++++++++++++++++++++ .gitignore | 4 ++ 4 files changed, 218 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/checks.yml delete mode 100644 .github/workflows/elixir.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..733330d --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,104 @@ +name: CI Checks + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + dependencies: + name: check | setup dependencies + runs-on: ubuntu-20.04 + env: + MIX_ENV: dev + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + strategy: + matrix: + elixir: ['1.12.3'] + otp: ['24.3.4'] + + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.0 + with: + access_token: ${{ github.token }} + + - name: Checkout Github repo + uses: actions/checkout@v2 + + - name: Setup elixir & erlang environment + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{matrix.elixir}} # Define the elixir version [required] + otp-version: ${{matrix.otp}} # Define the OTP version [required] + experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31 + + - name: Retrieve Cached Dependencies + uses: actions/cache@v2 + id: mix-cache + with: + path: | + deps + _build + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} + + - name: Install Dependencies + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + mix deps.compile + + static_code_analysis: + name: Static Code Analysis + runs-on: ubuntu-20.04 + needs: [dependencies] + env: + MIX_ENV: dev + + strategy: + fail-fast: false + matrix: + elixir: ['1.12.3'] + otp: ['24.3.4'] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup elixir & erlang environment + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{matrix.elixir}} # Define the elixir version [required] + otp-version: ${{matrix.otp}} # Define the OTP version [required] + experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31 + + - name: Retrieve Cached Dependencies + uses: actions/cache@v2 + id: mix-cache + with: + path: | + deps + _build + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} + + - name: Compile + run: mix compile --force + + - name: Check Code Format + run: mix format --check-formatted + + - name: Run Credo + run: mix credo + + - name: Run Dialyzer + run: mix dialyzer --no-check \ No newline at end of file diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml deleted file mode 100644 index e63c63f..0000000 --- a/.github/workflows/elixir.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Elixir CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -env: - MIX_ENV: test - -jobs: - build: - - runs-on: ubuntu-18.04 - - strategy: - matrix: - include: - - elixir: 1.11.2 - erlang: 23.1 - - elixir: 1.10.2 - erlang: 22.3 - - elixir: 1.9.1 - erlang: 22.3 - - elixir: 1.8.1 - erlang: 21.1 - - elixir: 1.7.4 - erlang: 21.1 - - steps: - - uses: actions/checkout@v2 - - name: Setup elixir - uses: actions/setup-elixir@v1 - with: - elixir-version: ${{matrix.elixir}} # Define the elixir version [required] - otp-version: ${{matrix.erlang}} # Define the OTP version [required] - - name: Install Dependencies - run: mix deps.get - - name: Build Dependencies - run: mix deps.compile - - name: Compile - run: mix compile --warnings-as-errors - - name: Check format - run: mix format --check-formatted - - name: Credo - run: mix credo --strict - - name: Run Tests - run: mix test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f957d13 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,110 @@ +name: CI Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + setup: + name: test / setup + runs-on: ubuntu-20.04 + env: + MIX_ENV: test + strategy: + matrix: + pair: + - elixir: 1.14 + otp: 25.2 + - elixir: 1.13 + otp: 24.3 + - elixir: 1.11 + otp: 21.3 + - elixir: 1.8 + otp: 20.3 + + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.0 + with: + access_token: ${{ github.token }} + - name: Checkout Github repo + uses: actions/checkout@v2 + - name: Setup elixir & erlang environment + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required] + otp-version: ${{matrix.pair.otp}} # Define the OTP version [required] + experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31 + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v2 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Retrieve Mix Dependencies Compilation Cache + uses: actions/cache@v2 + id: mix-deps-compile-cache # id to use in retrieve action + with: + path: _build + key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + - name: Install Mix Dependencies + if: steps.mix-cache.outputs.cache-hit != 'true' + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + + - name: Compile Mix Dependencies + if: steps.mix-deps-compile-cache.outputs.cache-hit != 'true' + run: mix deps.compile + + test: + name: runner / Test + needs: [setup] + + runs-on: ubuntu-20.04 + env: + MIX_ENV: test + + strategy: + fail-fast: false + matrix: + pair: + - elixir: 1.14 + otp: 25.2 + - elixir: 1.13 + otp: 24.3 + - elixir: 1.11 + otp: 21.3 + - elixir: 1.8 + otp: 20.3 + + steps: + - uses: actions/checkout@v2 + - name: Setup elixir & erlang environment + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{matrix.pair.elixir}} # Define the elixir version [required] + otp-version: ${{matrix.pair.otp}} # Define the OTP version [required] + experimental-otp: true # More info https://github.com/actions/setup-elixir/issues/31 + + - name: Retrieve Mix Dependencies Cache + uses: actions/cache@v2 + id: mix-cache # id to use in retrieve action + with: + path: deps + key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Retrieve Mix Dependencies Compilation Cache + uses: actions/cache@v2 + id: mix-deps-compile-cache # id to use in retrieve action + with: + path: _build + key: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + + - name: Run unit tests + run: mix test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 20a50d3..f788d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,10 @@ # If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump +# Idea +/.idea +*.iml + # Also ignore archive artifacts (built via "mix archive.build"). *.ez From 79d6a91a0065ef2ce79f149ef1a94a78c429a65c Mon Sep 17 00:00:00 2001 From: Argonus Date: Fri, 1 Dec 2023 15:22:28 +0100 Subject: [PATCH 2/2] Setup formatter and dialyzer --- .formatter.exs | 8 +++++++- .github/workflows/checks.yml | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.formatter.exs b/.formatter.exs index d2cda26..7455561 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,10 @@ # Used by "mix format" [ - inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: [ + "{mix,.formatter}.exs", + "{config,test}/**/*.{ex,exs}", + "lib/kayrock/*.{ex,exs}", + "lib/mix/**/*.{ex,exs}", + "lib/kayrock.ex" + ] ] diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 733330d..46db08e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -41,15 +41,18 @@ jobs: path: | deps _build + priv/plts key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - name: Install Dependencies if: steps.mix-cache.outputs.cache-hit != 'true' run: | + mkdir -p priv/plts mix local.rebar --force mix local.hex --force mix deps.get mix deps.compile + mix dialyzer --plt static_code_analysis: name: Static Code Analysis @@ -89,6 +92,7 @@ jobs: path: | deps _build + priv/plts key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - name: Compile