Skip to content

Commit

Permalink
CI test (#5)
Browse files Browse the repository at this point in the history
* test workflow 추가

* compose-file 이름 수정

* dependency version up

* lint

* delete test.yaml

* lint

* fmt

* cljstyle -> cljfmt

* lint deps version up

* clj-kondo ignore
  • Loading branch information
yyna authored Nov 4, 2024
1 parent 1286af9 commit e375ee5
Show file tree
Hide file tree
Showing 44 changed files with 2,610 additions and 2,607 deletions.
3 changes: 3 additions & 0 deletions .cljfmt.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{:remove-consecutive-blank-lines? false
:align-associative? false
:sort-ns-references? true}
14 changes: 0 additions & 14 deletions .cljstyle

This file was deleted.

7 changes: 0 additions & 7 deletions .github/workflows/_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ on:
workflow_call:

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- name: Fmt
run: make fmt-check

lint:
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint

on:
pull_request:
paths:
- "**.clj"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: DeLaGuardo/[email protected]
with:
cli: 1.12.0.1479
cljfmt: 0.13.0
clj-kondo: 2024.09.27

- name: Run cljfmt
run: cljfmt fix .

- name: Run clj-kondo
run: |
clj-kondo --lint . --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}" :exclude-files [".clj-kondo"]}}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lsp/
.vscode
*.iml
.idea/
.calva/

# for local testing
src/automigrate/models.edn
Expand Down
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ repl:
@clj -A:test:dev


.PHONY: fmt-check # Checking code formatting
fmt-check:
@$(INFO) "Checking code formatting..."
@cljstyle check --report $(DIRS)


.PHONY: fmt # Fixing code formatting
fmt:
@$(INFO) "Fixing code formatting..."
@cljstyle fix --report $(DIRS)


.PHONY: lint # Linting code
lint:
@$(INFO) "Linting project..."
Expand Down
6 changes: 3 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{:paths ["src"]
:deps {org.clojure/spec.alpha {:mvn/version "0.5.238"}
spec-dict/spec-dict {:mvn/version "0.2.1"}
com.github.seancorfield/honeysql {:mvn/version "2.6.1161"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"}
com.github.seancorfield/honeysql {:mvn/version "2.6.1203"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.955"}
weavejester/dependency {:mvn/version "0.2.1"}
differ/differ {:mvn/version "0.3.3"}
slingshot/slingshot {:mvn/version "0.12.2"}
Expand All @@ -26,7 +26,7 @@
:exec-args {:multithread? false
:test-warn-time 500}}

:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "2.9.1232"}
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "2.10.1241"}
; suppress logger output
org.slf4j/slf4j-nop {:mvn/version "2.0.16"}}
:main-opts ["-m" "antq.core" "--no-diff"
Expand Down
120 changes: 60 additions & 60 deletions src/automigrate/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@
(defmethod action CREATE-TABLE-ACTION
[_]
(s/keys
:req-un [::action
::model-name
::fields/fields]))
:req-un [::action
::model-name
::fields/fields]))


(defmethod action DROP-TABLE-ACTION
[_]
(s/keys
:req-un [::action
::model-name]))
:req-un [::action
::model-name]))


(s/def ::options
Expand All @@ -76,45 +76,45 @@
(defmethod action ADD-COLUMN-ACTION
[_]
(s/keys
:req-un [::action
::field-name
::model-name
::options]))
:req-un [::action
::field-name
::model-name
::options]))


(s/def ::changes
(s/and
(s/map-of keyword? map? :min-count 1)
(d/dict*
(d/->opt (model-util/generate-type-option ::fields/type))
(d/->opt (model-util/generate-changes [::fields/unique
::fields/null
::fields/primary-key
::fields/default
::fields/foreign-key
::fields/on-delete
::fields/on-update
::fields/check
::fields/array
::fields/comment])))))
(s/map-of keyword? map? :min-count 1)
(d/dict*
(d/->opt (model-util/generate-type-option ::fields/type))
(d/->opt (model-util/generate-changes [::fields/unique
::fields/null
::fields/primary-key
::fields/default
::fields/foreign-key
::fields/on-delete
::fields/on-update
::fields/check
::fields/array
::fields/comment])))))


(defmethod action ALTER-COLUMN-ACTION
[_]
(s/keys
:req-un [::action
::field-name
::model-name
::options
::changes]))
:req-un [::action
::field-name
::model-name
::options
::changes]))


(defmethod action DROP-COLUMN-ACTION
[_]
(s/keys
:req-un [::action
::field-name
::model-name]))
:req-un [::action
::field-name
::model-name]))


(s/def :automigrate.actions.indexes/options
Expand All @@ -124,27 +124,27 @@
(defmethod action CREATE-INDEX-ACTION
[_]
(s/keys
:req-un [::action
::index-name
::model-name
:automigrate.actions.indexes/options]))
:req-un [::action
::index-name
::model-name
:automigrate.actions.indexes/options]))


(defmethod action DROP-INDEX-ACTION
[_]
(s/keys
:req-un [::action
::index-name
::model-name]))
:req-un [::action
::index-name
::model-name]))


(defmethod action ALTER-INDEX-ACTION
[_]
(s/keys
:req-un [::action
::index-name
::model-name
:automigrate.actions.indexes/options]))
:req-un [::action
::index-name
::model-name
:automigrate.actions.indexes/options]))


(s/def :automigrate.actions.types/options
Expand All @@ -154,25 +154,25 @@
(defmethod action CREATE-TYPE-ACTION
[_]
(s/keys
:req-un [::action
::type-name
::model-name
:automigrate.actions.types/options]))
:req-un [::action
::type-name
::model-name
:automigrate.actions.types/options]))


(defmethod action DROP-TYPE-ACTION
[_]
(s/keys
:req-un [::action
::type-name
::model-name]))
:req-un [::action
::type-name
::model-name]))


(s/def :automigrate.actions.types/changes
(s/and
(s/map-of keyword? map? :min-count 1)
(d/dict*
(d/->opt (model-util/generate-changes [::types/choices])))))
(s/map-of keyword? map? :min-count 1)
(d/dict*
(d/->opt (model-util/generate-changes [::types/choices])))))


(s/def ::validate-type-choices-not-allow-to-remove
Expand All @@ -187,21 +187,21 @@
(let [choices-from (-> action-data :changes :choices :from)
choices-from-set (set choices-from)
choices-to (->> (get-in action-data [:changes :choices :to])
(filterv #(contains? choices-from-set %)))]
(filterv #(contains? choices-from-set %)))]
(= choices-from choices-to))))


(defmethod action ALTER-TYPE-ACTION
[_]
(s/and
(s/keys
:req-un [::action
::type-name
::model-name
:automigrate.actions.types/options
:automigrate.actions.types/changes])
::validate-type-choices-not-allow-to-remove
::validate-type-choices-not-allow-to-re-order))
(s/keys
:req-un [::action
::type-name
::model-name
:automigrate.actions.types/options
:automigrate.actions.types/changes])
::validate-type-choices-not-allow-to-remove
::validate-type-choices-not-allow-to-re-order))


; Public
Expand Down
16 changes: 8 additions & 8 deletions src/automigrate/constraints.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
(defn primary-key-constraint-name
[model-name]
(->> [(name model-name) PRIMARY-KEY-CONSTRAINT-POSTFIX]
(str/join #"-")
(keyword)))
(str/join #"-")
(keyword)))


(defn unique-constraint-name
[model-name field-name]
(->> [(name model-name) (name field-name) UNIQUE-CONSTRAINT-POSTFIX]
(str/join #"-")
(keyword)))
(str/join #"-")
(keyword)))


(defn foreign-key-constraint-name
[model-name field-name]
(->> [(name model-name) (name field-name) FOREIGN-KEY-CONSTRAINT-POSTFIX]
(str/join #"-")
(keyword)))
(str/join #"-")
(keyword)))


(defn check-constraint-name
[model-name field-name]
(->> [(name model-name) (name field-name) CHECK-CONSTRAINT-POSTFIX]
(str/join #"-")
(keyword)))
(str/join #"-")
(keyword)))
Loading

0 comments on commit e375ee5

Please sign in to comment.