Skip to content

Commit

Permalink
Run tests on GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Dec 8, 2023
1 parent 0e67000 commit aa8ded1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 34 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: testsuite

on:
push:
pull_request:

jobs:
build-clj:
strategy:
matrix:
# Supported Java versions: LTS releases 8 and 11 and the latest release
jdk: [8, 11, 17, 21]

name: Clojure (Java ${{ matrix.jdk }})

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-clj-${{ hashFiles('**/project.clj') }}
restore-keys: |
${{ runner.os }}-clj-
- name: Setup Java ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.jdk }}
- name: Setup Clojure
uses: DeLaGuardo/[email protected]
with:
lein: 2.9.5
- name: Run tests
run: lein test

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
.lein*
doc
pom.xml*
test-out/
71 changes: 37 additions & 34 deletions test/loiste/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,42 @@
{:a 2 :b 3 :c 4}]))))

(deftest write-new-file-test
(let [file (File/createTempFile "test-file" ".xlsx")]
(with-open [wb (l/workbook)]
(let [sheet (l/sheet wb)]
(println "Test file " (.getPath file))
(l/write-rows!
wb
sheet
{:styles {:date {:data-format {:type :date :pattern "dd.MM.yyyy HH.MM" :locale "fi"}}
:currency {:data-format {:type :custom :format-str "#0\\,00 €"}}
:header {:font {:bold true}
:border-bottom :thick
:border-right :thin
:fill-pattern :solid
:foreground-color (l/color 200 200 200)}
:wrapping-text {:wrap true}}
:columns [{:width (l/column-width 10)}
{:width (l/column-width 15) :style :date}
{:width (l/column-width 10) :style :currency}]}
[[{:style :header :value "Stuff"}
{:style :header :value "Date"}
{:style :header :value "Money"}]
{:height 100
:values [{:style :wrapping-text
:value "This is a long text that should wrap"}
#inst "2016-03-09T14:05:00"]}
["Bar" #inst "2016-03-09T14:05:00" 15]
["Qux" 100000 100]
["Integer" (count '(1 2 3)) 10000]
["Keyword" :foo nil]])

(l/to-file! file wb)))
;; Keep the file around after tests for testing opening,
;; but remove on the start.
(let [file (io/file "test-out" "new-file-test.xslx")]
(doseq [wb* [(l/workbook)
(l/streaming-workbook)]]
(.delete file)
(with-open [wb wb*]
(let [sheet (l/sheet wb)]
(println "Test file " (.getPath file))
(l/write-rows!
wb
sheet
{:styles {:date {:data-format {:type :date :pattern "dd.MM.yyyy HH.MM" :locale "fi"}}
:currency {:data-format {:type :custom :format-str "#0\\,00 €"}}
:header {:font {:bold true}
:border-bottom :thick
:border-right :thin
:fill-pattern :solid
:foreground-color (l/color 200 200 200)}
:wrapping-text {:wrap true}}
:columns [{:width (l/column-width 10)}
{:width (l/column-width 15) :style :date}
{:width (l/column-width 10) :style :currency}]}
[[{:style :header :value "Stuff"}
{:style :header :value "Date"}
{:style :header :value "Money"}]
{:height 100
:values [{:style :wrapping-text
:value "This is a long text that should wrap"}
#inst "2016-03-09T14:05:00"]}
["Bar" #inst "2016-03-09T14:05:00" 15]
["Qux" 100000 100]
["Integer" (count '(1 2 3)) 10000]
["Keyword" :foo nil]])

(l/to-file! file wb))))

(with-open [wb (l/workbook file)]
(let [read-sheet (l/sheet wb 0)]
Expand All @@ -100,9 +105,7 @@
{:Stuff "Qux" :Date #inst "2173-10-13T21:00:00.000-00:00" :Money 100.0}
{:Stuff "Integer" :Date #inst "1900-01-02T22:20:11.000-00:00" :Money 10000.0}
{:Stuff "Keyword" :Date "foo" :Money nil}]
(l/read-sheet read-sheet)))))

(.delete file)))
(l/read-sheet read-sheet)))))))

(deftest color-test
(is (= (unchecked-byte 200)
Expand Down

0 comments on commit aa8ded1

Please sign in to comment.