Skip to content

Commit

Permalink
Move elixir source checks to a separate step
Browse files Browse the repository at this point in the history
This is to help unblock 3.3 windows build so make check doesn't choke on
re-formatting elixir files for Windows.
  • Loading branch information
nickva authored and janl committed Dec 21, 2022
1 parent e6b1be7 commit 088cb3f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
22 changes: 9 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ exunit: export ERL_LIBS = $(shell pwd)/src
exunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
exunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
exunit: couch elixir-init setup-eunit
@mix test --trace $(EXUNIT_OPTS)

setup-eunit: export BUILDDIR = $(shell pwd)
Expand Down Expand Up @@ -235,50 +235,46 @@ python-black-update: .venv/bin/black
.PHONY: elixir
elixir: export MIX_ENV=integration
elixir: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
elixir: elixir-init elixir-check-formatted elixir-credo devclean
elixir: elixir-init devclean
@dev/run "$(TEST_OPTS)" -a adm:pass -n 1 \
--enable-erlang-views \
--locald-config test/elixir/test/config/test-config.ini \
--no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-init
elixir-init: MIX_ENV=test
elixir-init: MIX_ENV=integration
elixir-init: config.erl
@mix local.rebar --force rebar ./bin/rebar && mix local.rebar --force rebar3 ./bin/rebar3 && mix local.hex --force && mix deps.get

.PHONY: elixir-cluster-without-quorum
elixir-cluster-without-quorum: export MIX_ENV=integration
elixir-cluster-without-quorum: elixir-init elixir-check-formatted elixir-credo devclean
elixir-cluster-without-quorum: elixir-init devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 2 \
--no-eval 'mix test --trace --only without_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-cluster-with-quorum
elixir-cluster-with-quorum: export MIX_ENV=integration
elixir-cluster-with-quorum: elixir-init elixir-check-formatted elixir-credo devclean
elixir-cluster-with-quorum: elixir-init devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 1 \
--no-eval 'mix test --trace --only with_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-suite
elixir-suite: export MIX_ENV=integration
elixir-suite: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
elixir-suite: elixir-init elixir-check-formatted elixir-credo devclean
elixir-suite: elixir-init devclean
@dev/run -n 1 -q -a adm:pass \
--enable-erlang-views \
--no-join \
--locald-config test/elixir/test/config/test-config.ini \
--erlang-config rel/files/eunit.config \
--no-eval 'mix test --trace --include test/elixir/test/config/suite.elixir --exclude test/elixir/test/config/skip.elixir'

.PHONY: elixir-check-formatted
elixir-check-formatted: elixir-init
.PHONY: elixir-source-checks
elixir-source-checks: export MIX_ENV=integration
elixir-source-checks: elixir-init
@mix format --check-formatted

# Credo is a static code analysis tool for Elixir.
# We use it in our tests
.PHONY: elixir-credo
elixir-credo: elixir-init
@mix credo

.PHONY: build-report
Expand Down
1 change: 1 addition & 0 deletions build-aux/Jenkinsfile.pr
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pipeline {
rm -rf apache-couchdb-*
./configure --skip-deps
make erlfmt-check
make elixir-source-checks
make python-black
'''
}
Expand Down
12 changes: 11 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ defmodule CouchDBTest.Mixfile do

# Run "mix help deps" to learn about dependencies.
defp deps() do
[
deps_list = [
{:junit_formatter, "~> 3.0", only: [:dev, :test, :integration]},
{:httpotion, ">= 3.1.3", only: [:dev, :test, :integration], runtime: false},
{:excoveralls, "~> 0.12", only: :test},
Expand All @@ -94,6 +94,16 @@ defmodule CouchDBTest.Mixfile do
{:ibrowse, path: path("ibrowse"), override: true},
{:credo, "~> 1.6.4", only: [:dev, :test, :integration], runtime: false}
]

# Some deps may be missing during source check
# Besides we don't want to spend time checking them anyway
List.foldl([:b64url, :jiffy, :jwtf, :ibrowse], deps_list, fn dep, acc ->
if File.dir?(acc[dep][:path]) do
acc
else
List.keydelete(acc, dep, 0)
end
end)
end

defp path(app) do
Expand Down

0 comments on commit 088cb3f

Please sign in to comment.