From 09e5ffc6bcd55bc0ab0d35bcf090f7a5cef60583 Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 20:41:19 +0000 Subject: [PATCH 1/6] Remove Circle CI and move to Github Actions --- .circleci/config.yml | 144 --------------------------------------- .github/workflows/ci.yml | 94 +++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 144 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a826375..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,144 +0,0 @@ -version: 2.1 - -jobs: - build: - docker: - - image: cimg/elixir:1.15.5-erlang-26.0.2 - environment: - MIX_ENV: test - steps: - - checkout - - run: - name: Install tools - command: | - mix local.hex --force && \ - mix local.rebar --force - - restore_cache: - keys: - - v2-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} - - v2-mix-cache-{{ .Branch }} - - v2-mix-cache - - run: - name: Get dependencies - command: mix deps.get - - save_cache: - key: v2-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} - paths: - - deps - - restore_cache: - keys: - - v4-build-cache-{{ .Branch }} - - v4-build-cache - - run: - name: Compile - command: mix do deps.compile, compile --warnings-as-errors, dialyzer --plt - - save_cache: - key: v4-build-cache-{{ .Branch }} - paths: - - _build - - persist_to_workspace: - root: ~/ - paths: - - .mix - - project/_build - - project/deps - - test: - docker: - - image: cimg/elixir:1.15.5-erlang-26.0.2 - environment: - MIX_ENV: test - - image: cimg/postgres:14.6 - steps: - - checkout - - attach_workspace: - at: ~/ - - run: - name: Run tests - command: mix test --cover --export-coverage default - - run: - name: Check coverage - command: mix test.coverage - - store_test_results: - path: /tmp/test/results.xml - - lint: - docker: - - image: cimg/elixir:1.15.5-erlang-26.0.2 - environment: - MIX_ENV: test - steps: - - checkout - - attach_workspace: - at: ~/ - - run: - name: Check formatting - command: mix format --check-formatted --dry-run - - run: - name: Check for retired dependencies - command: mix hex.audit - - run: - name: Check unused dependencies - command: mix deps.unlock --check-unused - - run: - name: Check outdated dependencies - command: mix hex.outdated --within-requirements || true - - run: - name: Credo - command: mix credo --all - - run: - name: Dialyzer - command: mix dialyzer - - run: - name: Check documentation - command: mix doctor - - security: - docker: - - image: cimg/elixir:1.15.5-erlang-26.0.2 - environment: - MIX_ENV: test - steps: - - checkout - - attach_workspace: - at: ~/ - - run: - name: Audit dependencies - command: mix deps.audit - - run: - name: Sobelow - command: mix sobelow --config - - slscan: - docker: - - image: shiftleft/sast-scan:maven385 - environment: - FETCH_LICENSE: "true" - working_directory: /tmp/shiftleft-scan - steps: - - checkout - - run: - name: Scan - command: scan --no-error - - store_artifacts: - path: reports - destination: sast-scan-reports - -workflows: - test: - jobs: - - build - - test: - requires: - - build - - lint: - requires: - - build - - security: - requires: - - build - - slscan: - filters: - branches: - only: - - master diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a90b9fe --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: Test +on: + push: + branches: [main] + pull_request: + branches: [main] +jobs: + test: + name: Test (Elixir ${{ matrix.elixir }} | OTP ${{ matrix.otp }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - elixir: 1.17.x + otp: 27 + os: ubuntu-22.04 + - elixir: 1.18.x + otp: 27 + os: ubuntu-22.04 + - elixir: 1.19.x + otp: 28 + os: ubuntu-22.04 + env: + MIX_ENV: test + steps: + - name: Setup Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v4 + id: cache-deps + with: + path: | + deps + _build + key: | + mix-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + mix-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}- + - name: Install dependencies + run: mix deps.get + + - name: Compile + run: mix compile + + - name: Check for unused packages + run: mix deps.unlock --check-unused + + - run: mix format --check-formatted + + - run: mix credo --strict + + - run: mix dialyzer + + - name: Check for abandonded packages + run: mix hex.audit + + - name: Check outdated dependencies + run: mix hex.outdated --within-requirements || true + + - name: Check for vulnerable packages + run: mix hex.audit + + - name: Run tests + run: mix test + + - name: Run tests (with coverage) + run: mix test --cover --export-coverage default + + - name: Scan for security vulnerabilities + run: mix sobelow --exit --threshold medium + + publish: + name: Publish + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + elixir-version: 1.18 + otp-version: 27 + - name: Fetch dependencies + run: mix deps.get + - name: Compile + run: mix compile + - name: Publish package (Dry Run) + run: mix hex.publish --dry-run --replace --yes From e3488327730f54fe7d6d2107ae228a2ef30f61eb Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 20:44:47 +0000 Subject: [PATCH 2/6] Include master --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a90b9fe..f13aea8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ name: Test on: push: - branches: [main] + branches: [main,master] pull_request: - branches: [main] + branches: [main,master] jobs: test: name: Test (Elixir ${{ matrix.elixir }} | OTP ${{ matrix.otp }}) From 83fa7f931e4608b5299d119fd514dfe4fb87ac0d Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 20:46:08 +0000 Subject: [PATCH 3/6] Rename Pipelines to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f13aea8..c0e2232 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Test +name: CI on: push: branches: [main,master] From a9a6bf23e3ba6bcb6ac6752d4f06d2f09e3eadc1 Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 20:50:16 +0000 Subject: [PATCH 4/6] Authorise publish --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0e2232..a4ca890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: run: mix sobelow --exit --threshold medium publish: - name: Publish + name: Publish (Dry Run) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -90,5 +90,7 @@ jobs: run: mix deps.get - name: Compile run: mix compile - - name: Publish package (Dry Run) - run: mix hex.publish --dry-run --replace --yes + - name: Publish package + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + run: mix hex.publish --organization ${{ vars.HEX_ORG }} --dry-run --replace --yes From e2895fedc617dcb598f10805e997ab444fa4b6dc Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 21:04:04 +0000 Subject: [PATCH 5/6] Fix test fo Elixir 1.19 OTP 28 --- test/zexbox/metrics/metric_handler_test.exs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/zexbox/metrics/metric_handler_test.exs b/test/zexbox/metrics/metric_handler_test.exs index 3844c83..e489bef 100644 --- a/test/zexbox/metrics/metric_handler_test.exs +++ b/test/zexbox/metrics/metric_handler_test.exs @@ -94,10 +94,12 @@ defmodule Zexbox.Metrics.MetricHandlerTest do end test "captures and logs any exceptions", %{event: event, metadata: metadata} do - assert capture_log(fn -> - MetricHandler.handle_event(event, nil, metadata, nil) - end) =~ - "Exception creating controller series: %KeyError" + log = capture_log(fn -> + MetricHandler.handle_event(event, nil, metadata, nil) + end) + + assert log =~ "Exception creating controller series:" and + (log =~ "KeyError" or log =~ "BadMapError") end end end From 878ba8cb7811bce6d3a1bbac2777e521d7c08400 Mon Sep 17 00:00:00 2001 From: Kent Hawkings Date: Sun, 9 Nov 2025 21:05:28 +0000 Subject: [PATCH 6/6] Update metric_handler_test.exs --- test/zexbox/metrics/metric_handler_test.exs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/zexbox/metrics/metric_handler_test.exs b/test/zexbox/metrics/metric_handler_test.exs index e489bef..94d7840 100644 --- a/test/zexbox/metrics/metric_handler_test.exs +++ b/test/zexbox/metrics/metric_handler_test.exs @@ -94,12 +94,9 @@ defmodule Zexbox.Metrics.MetricHandlerTest do end test "captures and logs any exceptions", %{event: event, metadata: metadata} do - log = capture_log(fn -> - MetricHandler.handle_event(event, nil, metadata, nil) - end) - - assert log =~ "Exception creating controller series:" and - (log =~ "KeyError" or log =~ "BadMapError") + assert capture_log(fn -> + MetricHandler.handle_event(event, nil, metadata, nil) + end) =~ "Exception creating controller series: %BadMapError" end end end