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..a4ca890 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,96 @@ +name: CI +on: + push: + branches: [main,master] + pull_request: + branches: [main,master] +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 (Dry Run) + 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 + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + run: mix hex.publish --organization ${{ vars.HEX_ORG }} --dry-run --replace --yes diff --git a/test/zexbox/metrics/metric_handler_test.exs b/test/zexbox/metrics/metric_handler_test.exs index 3844c83..94d7840 100644 --- a/test/zexbox/metrics/metric_handler_test.exs +++ b/test/zexbox/metrics/metric_handler_test.exs @@ -96,8 +96,7 @@ defmodule Zexbox.Metrics.MetricHandlerTest do 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" + end) =~ "Exception creating controller series: %BadMapError" end end end