Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated entries in config when using both #kaocha/v1 and #include #297

Open
NoahTheDuke opened this issue Jun 27, 2022 · 4 comments
Open
Labels
documentation An issue or improvement related to documentation first issue only These tickets are only for first-time contributors.

Comments

@NoahTheDuke
Copy link
Contributor

NoahTheDuke commented Jun 27, 2022

Hey friends!

I was a little confused about how to best write a tests.edn config that uses #include while also relying on the #kaocha/v1 transformer.

Given tests.edn:

#kaocha/v1
 {:capture-output? true
  :color? true
  :plugins [:capture-output :filter :randomize]
  :reporter [kaocha.report/dots]
  :tests [{:id :all
           :ns-patterns ["-test$"]
           :source-paths ["src"]
           :test-paths ["test"]}]}

The docs recommend writing a tests-ci.edn like:

#kaocha/v1
 #meta-merge
  [{:color? false
    :kaocha.plugin.junit-xml/target-file "junit.xml"
    :plugins ^:append [:kaocha.plugin/junit-xml]}
   #include "tests.edn"]

which then prints a config with:

{:kaocha/tests
 [{:kaocha.testable/desc "all (clojure.test)",
   :kaocha.testable/type :kaocha.type/clojure.test,
   :kaocha.testable/id :all,
   :kaocha/ns-patterns ["-test$"],
   :kaocha/source-paths ["src"],
   :kaocha/test-paths ["test"],
   :kaocha.filter/skip-meta [:kaocha/skip]}],
 :kaocha.plugin.junit-xml/target-file "junit.xml",
 :kaocha/fail-fast? false,
 :kaocha/color? true,
 :kaocha/cli-options {:config-file "tests-ci.edn", :print-config true},
 :kaocha.plugin.randomize/seed 997097312,
 :kaocha.plugin.randomize/randomize? true,
 :kaocha/plugins
 [:kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :capture-output
  :filter
  :randomize],
 :kaocha.plugin.capture-output/capture-output? true,
 :kaocha/reporter [kaocha.report/dots],
 :capture-output? true}

Note that the :kaocha/plugins list has duplicates and is missing the junit plugin.

After much trial and error, this tests-ci.edn works (leave off #kaocha/v1 and qualify all of the keywords):

#meta-merge
 [#include "tests.edn"
  {:kaocha/color? false
   :kaocha.plugin.junit-xml/target-file "junit.xml"
   :kaocha/plugins ^:append [:kaocha.plugin/junit-xml]}]

which produces this config:

{:kaocha/tests
 [{:kaocha.testable/desc "all (clojure.test)",
   :kaocha.testable/type :kaocha.type/clojure.test,
   :kaocha.testable/id :all,
   :kaocha/ns-patterns ["-test$"],
   :kaocha/source-paths ["src"],
   :kaocha/test-paths ["test"],
   :kaocha.filter/skip-meta [:kaocha/skip]}],
 :kaocha.plugin.junit-xml/target-file "junit.xml",
 :kaocha/fail-fast? false,
 :kaocha/color? false,
 :kaocha/cli-options {:config-file "tests-ci.edn", :print-config true},
 :kaocha.plugin.randomize/seed 1405326847,
 :kaocha.plugin.randomize/randomize? true,
 :kaocha/plugins
 [:kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :capture-output
  :filter
  :randomize
  :kaocha.plugin/junit-xml],
 :kaocha.plugin.capture-output/capture-output? true,
 :kaocha/reporter [kaocha.report/dots],
 :capture-output? true}

I don't know exactly how exactly the meta-merge works or when/how the conversion of plain keywords to qualified keywords works, but it seems that there's something funky happening and the docs should probably be updated.

Thanks so much!

@alysbrooks
Copy link
Member

Thanks for the report! I believe this the intended behavior of #meta-merge but applying #kaocha/v1 to both is going to result in duplicates like you discovered.

I'm not able to find a recommendation for tests-ci.edn in our docs. Can you provide a link? If it is in there somewhere, it probably is wrong like you discovered or at the very least needs to be clarified.

I think our actual current recommendation is to use profiles for CI instead: https://cljdoc.org/d/lambdaisland/kaocha/1.68.1059/doc/3-configuration#profiles. It's certainly possible a forgotten corner of our documentation is suggesting something else, though.

@NoahTheDuke
Copy link
Contributor Author

Oh profiles look like exactly what I hoping for! I should have been more clear that I read between the lines a little. The docs recommend a "tests.user.edn" file to be included, so I took that to mean it was the best way to handle CI config.

@alysbrooks
Copy link
Member

Oh okay. I think we can clarify that the tests.user.edn file should not itself include #kaocha/v1. We also have a meta-merge issue #184, so that's already covered.

@alysbrooks alysbrooks added first issue only These tickets are only for first-time contributors. documentation An issue or improvement related to documentation labels Jun 28, 2022
@alysbrooks
Copy link
Member

This is a one-line documentation fix since #184 was fixed by #192.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation An issue or improvement related to documentation first issue only These tickets are only for first-time contributors.
Projects
Status: Candidate
Development

No branches or pull requests

2 participants