Skip to content

Commit

Permalink
Setup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mynomoto committed Oct 30, 2023
1 parent da1049a commit 71884db
Show file tree
Hide file tree
Showing 21 changed files with 1,920 additions and 218 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release Version

on:
push:
tags:
- "release-v*"

jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.11.1.1208'
- name: Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Cache All The Things
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.npm
~/.gitlibs
~/.clojure
~/.cpcache
key: cljdeps-${{ hashFiles('deps.edn', 'package.json') }}
- name: Install node dependencies
run: npm install
- name: Install karma cli globally
run: npm install -g karma-cli
- name: Run Tests
run: clojure -T:build ci :snapshot false
- name: Deploy Release
run: clojure -T:build deploy :snapshot false
env:
CLOJARS_PASSWORD: ${{secrets.DEPLOY_TOKEN}}
CLOJARS_USERNAME: ${{secrets.DEPLOY_USERNAME}}
46 changes: 46 additions & 0 deletions .github/workflows/test-and-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Develop & Snapshot

on:
push:
branches:
- "master"

jobs:
build-and-snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.11.1.1208'
- name: Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Cache All The Things
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.npm
~/.gitlibs
~/.clojure
~/.cpcache
key: cljdeps-${{ hashFiles('deps.edn', 'package.json') }}
- name: Install node dependencies
run: npm install
- name: Install karma cli globally
run: npm install -g karma-cli
- name: Run Tests
run: clojure -T:build ci :snapshot true
- name: Deploy Snapshot
run: clojure -T:build deploy :snapshot true
env:
CLOJARS_PASSWORD: ${{secrets.DEPLOY_TOKEN}}
CLOJARS_USERNAME: ${{secrets.DEPLOY_USERNAME}}
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pull Request

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Clojure CLI
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.11.1.1208'
- name: Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Cache All The Things
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.npm
~/.gitlibs
~/.clojure
~/.cpcache
key: cljdeps-${{ hashFiles('deps.edn', 'package.json') }}
- name: Install node dependencies
run: npm install
- name: Install karma cli globally
run: npm install -g karma-cli
- name: Run Tests
run: clojure -T:build test
27 changes: 7 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
*.class
*.jar
.clj-kondo/**/
.cpcache/
.nrepl-*
/target
/lib
/classes
/checkouts
cljs-test-runner-out/
node_modules/
pom.xml
pom.xml.asc
*.swn
*.swo
*.swp
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
.lein-repl-history
.DS_Store
.nrepl-port
/test/test.js
/test/firefox-profile
.nrepl-*
.idea/
*.iml
project.clj
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions FAQ.md

This file was deleted.

55 changes: 0 additions & 55 deletions build.boot

This file was deleted.

86 changes: 86 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
(ns build
(:refer-clojure :exclude [test])
(:require [clojure.string :as str]
[clojure.tools.build.api :as b]
[clojure.tools.deps :as t]
[deps-deploy.deps-deploy :as dd]))

(def lib 'hoplon/javelin)
(def version "3.9.1")
(def snapshot (format "%s-SNAPSHOT" version))
#_ ; alternatively, use MAJOR.MINOR.COMMITS:
(def version (format "1.0.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")

(defn- run-task [aliases]
(println "\nRunning task for" (str/join "," (map name aliases)))
(let [basis (b/create-basis {:aliases aliases})
combined (t/combine-aliases basis aliases)
cmds (b/java-command
{:basis basis
:main 'clojure.main
:main-args (:main-opts combined)})
{:keys [exit]} (b/process cmds)]
(when-not (zero? exit) (throw (ex-info "Task failed" {})))))

(defn node-test
"Run cljs tests using node"
[opts]
(run-task [:cljs-node])
opts)

(defn chrome-test
"Run cljs tests using chrome"
[opts]
(run-task [:cljs-chrome])
opts)

(defn clojure-test
"Run cljs tests using chrome"
[opts]
(run-task [:test :runner])
opts)

(defn test
"Run all the tests."
[opts]
(clojure-test opts)
(node-test opts)
(chrome-test opts)
opts)

(defn- jar-opts [opts]
(let [version (if (:snapshot opts) snapshot version)]
(println "\nVersion:" version)
(assoc opts
:lib lib :version version
:jar-file (format "target/%s-%s.jar" lib version)
:scm {:tag (str "v" version)
:url "[email protected]:hoplon/javelin.git"}
:basis (b/create-basis {})
:class-dir class-dir
:target "target"
:src-dirs ["src" "clj-kondo"])))

(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(test opts)
(b/delete {:path "target"})
(let [opts (jar-opts opts)]
(println "\nWriting pom.xml...")
(b/write-pom opts)
(println "\nCopying source...")
(b/copy-dir {:src-dirs ["src" "clj-kondo"] :target-dir class-dir})
(println "\nBuilding JAR...")
(b/jar opts))
opts)

(defn install "Install the JAR locally." [opts]
(let [opts (jar-opts opts)]
(b/install opts))
opts)

(defn deploy "Deploy the JAR to Clojars." [opts]
(let [{:keys [jar-file] :as opts} (jar-opts opts)]
(dd/deploy {:installer :remote :artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))}))
opts)
6 changes: 6 additions & 0 deletions clj-kondo/clj-kondo.exports/hoplon/javelin/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{:lint-as {javelin.core/cell-let clojure.core/let
javelin.core/cell-doseq clojure.core/doseq
javelin.core/defc clojure.core/def
javelin.core/defc= clojure.core/def
javelin.core/formulet clojure.core/let
javelin.core/with-let clojure.core/let}}
19 changes: 19 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{:deps {org.clojure/clojurescript {:mvn/version "1.11.60"}
org.clojure/clojure {:mvn/version "1.11.1"}
tailrecursion/cljs-priority-map {:mvn/version "1.0.3"}
org.clojure/data.priority-map {:mvn/version "0.0.2"}
riddley/riddley {:mvn/version "0.1.6"}}
:paths ["src" "clj-kondo"]
:aliases {:cljs-node {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
:extra-paths ["test"]
:main-opts ["-m" "cljs-test-runner.main"]}
:cljs-chrome {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
:extra-paths ["test"]
:main-opts ["-m" "cljs-test-runner.main" "-x" "chrome-headless"]}
:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:exec-fn cognitect.test-runner.api/test}
:runner {:main-opts ["-m" "cognitect.test-runner"]}
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.2" :git/sha "fe6b140"}
slipset/deps-deploy {:mvn/version "0.2.0"}}
:ns-default build}}}
Loading

0 comments on commit 71884db

Please sign in to comment.