first functionality

This commit is contained in:
Michael Jerger 2024-08-16 12:32:59 +02:00
parent 8c175a3d89
commit ca6a34bbc3
8 changed files with 45 additions and 212 deletions

View file

@ -1,101 +0,0 @@
;; ---------------------------------------------------------
;; Clojure Linter - clj-kondo configuration for Continuous Integration
;;
;; Essential linter checks during CI workflows
;; disabling non-essential checks to optimise workflow feedback
;; ---------------------------------------------------------
{;; Ignore code in comment blocks
:skip-comments true
:linters {:invalid-arity {:level :error
:skip-args [#_riemann.test/test-stream]}
:not-a-function {:level :error
:skip-args [#_user/foo]}
:private-call {:level :error}
:inline-def {:level :error}
:redundant-do {:level :off}
:redundant-let {:level :warning}
:cond-else {:level :off}
:syntax {:level :warning}
:file {:level :error}
:missing-test-assertion {:level :warning}
:conflicting-alias {:level :error}
:duplicate-map-key {:level :error}
:duplicate-set-key {:level :error}
:missing-map-value {:level :error}
:redefined-var {:level :off}
:unreachable-code {:level :warning}
:datalog-syntax {:level :off}
:unbound-destructuring-default {:level :warning}
:unused-binding {:level :off
;; :exclude-destructured-keys-in-fn-args false
;; :exclude-destructured-as false
;; :exclude-unused-as true
}
:unsorted-required-namespaces {:level :off}
:unused-namespace {:level :off
;; don't warn about these namespaces:
:exclude [#_clj-kondo.impl.var-info-gen]}
;; :simple-libspec true
:unresolved-symbol {:level :error
:exclude [;; ignore globally:
#_js*
;; ignore occurrences of service and event in call to riemann.streams/where:
#_(riemann.streams/where [service event])
;; ignore all unresolved symbols in one-of:
#_(clj-kondo.impl.utils/one-of)
#_(user/defproject) ; ignore project.clj's defproject
#_(clojure.test/are [thrown? thrown-with-msg?])
#_(cljs.test/are [thrown? thrown-with-msg?])
#_(clojure.test/is [thrown? thrown-with-msg?])
#_(cljs.test/is [thrown? thrown-with-msg?])]}
:unresolved-var {:level :warning}
:unresolved-namespace {:level :warning
:exclude [#_foo.bar]}
;; for example: foo.bar is always loaded in a user profile
:misplaced-docstring {:level :warning}
:not-empty? {:level :off}
:deprecated-var {:level :off
#_:exclude
#_{foo.foo/deprecated-fn
;; suppress warnings in the following namespaces
{:namespaces [foo.bar "bar\\.*"]
;; or in these definitions:
:defs [foo.baz/allowed "foo.baz/ign\\.*"]}}}
:unused-referred-var {:level :off
:exclude {#_#_taoensso.timbre [debug]}}
:unused-private-var {:level :off}
:duplicate-require {:level :warning}
:refer {:level :off}
:refer-all {:level :warning
:exclude #{}}
:use {:level :error}
:missing-else-branch {:level :warning}
:type-mismatch {:level :error}
:missing-docstring {:level :warning}
:consistent-alias {:level :off
;; warn when alias for clojure.string is
;; different from str
:aliases {#_clojure.string #_str}}
:unused-import {:level :off}
:single-operand-comparison {:level :off}
:single-logical-operand {:level :off}
:single-key-in {:level :off}
:missing-clause-in-try {:level :off}
:missing-body-in-when {:level :off}
:hook {:level :error}
:format {:level :error}
:shadowed-var {:level :off
#_#_:suggestions {clojure.core/type tajpu
clojure.core/name nomspaco}
#_#_:exclude [frequencies]
#_#_:include [name]}
:deps.edn {:level :warning}}
;; Format the output of clj-kondo for GitHub actions
:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}

View file

@ -1,37 +0,0 @@
---
# Clojure Lint with clj-kondo and reviewdog
#
# Lint errors raised as comments on pull request conversation
name: Lint Review
on: [pull_request]
jobs:
clj-kondo:
name: runner / clj-kondo
runs-on: ubuntu-latest
steps:
- run: echo "🚀 Job automatically triggered by ${{ github.event_name }}"
- run: echo "🐧 Job running on ${{ runner.os }} server"
- run: echo "🐙 Using ${{ github.ref }} branch from ${{ github.repository }} repository"
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v4
with:
token: "${{ secrets.PAT || secrets.GITHUB_TOKEN }}"
- run: echo "🐙 ${{ github.repository }} repository was cloned to the runner."
- name: clj-kondo
uses: nnichols/clojure-lint-action@v2
with:
pattern: "*.clj"
clj_kondo_config: ".github/config/clj-kondo-ci-config.edn"
level: "error"
exclude: ".cljstyle"
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
# Summary and status
- run: echo "🎨 Lint Review checks completed"
- run: echo "🍏 Job status is ${{ job.status }}."

View file

@ -1,4 +1,4 @@
# practicalli/playground Changelog
# dda-backup Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

View file

@ -0,0 +1,6 @@
(ns dda.backup.management
(:require
[orchestra.core :refer [defn-spec]]
[clojure.spec.alpha :as s]
[dda.build.devops.domain :as domain]
[dda.build.infrastructure :as i]))

View file

@ -0,0 +1,21 @@
(ns dda.backup.management.domain
(:require
[orchestra.core :refer [defn-spec]]
[clojure.spec.alpha :as s]))
(s/def ::certificate-file string?)
(s/def ::restic-repository string?)
(s/def ::backup-file-path string?)
(s/def ::config
(s/keys :req-un [::restic-repository ::backup-file-path]
:opt-un [::certificate-file]))
; TODO: specify output better
(defn-spec init-repo-command seq?
[config ::config]
(let [{:keys [certificate-file restic-repository backup-file-path]} config]
(if (some? certificate-file)
["restic" "-r" (str restic-repository "/" backup-file-path) "-v" "init" "--cacert" certificate-file]
["restic" "-r" (str restic-repository "/" backup-file-path) "-v" "init"]
)))

View file

@ -1,46 +0,0 @@
;; ---------------------------------------------------------
;; practicalli.playground
;;
;; TODO: Provide a meaningful description of the project
;; ---------------------------------------------------------
(ns practicalli.playground
(:gen-class)
(:require
[com.brunobonacci.mulog :as mulog]))
;; ---------------------------------------------------------
;; Application
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn greet
"Greeting message via Clojure CLI clojure.exec"
([] (greet {:team-name "secret engineering"}))
([{:keys [team-name]}]
(str "practicalli playground service developed by the " team-name " team")))
(defn -main
"Entry point into the application via clojure.main -M"
[& args]
(let [team (first args)]
(mulog/set-global-context!
{:app-name "practicalli playground" :version "0.1.0-SNAPSHOT"})
(mulog/log ::application-starup :arguments args)
(if team
(println (greet team))
(println (greet)))))
;; ---------------------------------------------------------
;; ---------------------------------------------------------
;; Rick Comment
#_{:clj-kondo/ignore [:redefined-var]}
(comment
(-main)
(-main {:team-name "Clojure Engineering"})
#_()) ; End of rich comment block
;; ---------------------------------------------------------

View file

@ -0,0 +1,17 @@
(ns dda.backup.management.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.management.domain :as cut]))
(st/instrument `cut/init-repo-command)
(deftest should-calculate-init-repo-command
(is (= ["restic" "-r" "repo/dir" "-v" "init" "--cacert" "ca"]
(cut/init-repo-command {:certificate-file "ca"
:restic-repository "repo"
:backup-file-path "dir"})))
(is (= ["restic" "-r" "repo/dir" "-v" "init"]
(cut/init-repo-command {:restic-repository "repo"
:backup-file-path "dir"})))
)

View file

@ -1,27 +0,0 @@
;; ---------------------------------------------------------
;; practicalli.playground.-test
;;
;; Example unit tests for practicalli.playground
;;
;; - `deftest` - test a specific function
;; - `testing` logically group assertions within a function test
;; - `is` assertion: expected value then function call
;; ---------------------------------------------------------
(ns practicalli.playground-test
(:require
[clojure.test :refer [deftest is testing]]
[practicalli.playground :as playground]))
(deftest application-test
(testing "TODO: Start with a failing test, make it pass, then refactor"
;; TODO: fix greet function to pass test
(is (= "practicalli application developed by the secret engineering team"
(playground/greet)))
;; TODO: fix test by calling greet with {:team-name "Practicalli Engineering"}
(is (= (playground/greet "Practicalli Engineering")
"practicalli service developed by the Practicalli Engineering team"))))