Skip to content

Commit

Permalink
build: move from lein to clj+deps.edn
Browse files Browse the repository at this point in the history
Lein with deps.edn does not work on Windows, so we're moving to clj+deps.edn.

See RickMoynihan/lein-tools-deps#85
  • Loading branch information
filipesilva committed Oct 8, 2021
1 parent 805cc41 commit af8cfc9
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 198 deletions.
File renamed without changes.
16 changes: 12 additions & 4 deletions .github/custom-actions/clojure-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ runs:
id: restore-maven
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
key: ${{ runner.os }}-maven-${{ hashFiles('deps.edn') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Restore gitlibs
uses: actions/cache@v2
id: restore-gitlibs
with:
path: ~/.gitlibs
key: ${{ runner.os }}-gitlibs-${{ hashFiles('deps.edn') }}
restore-keys: |
${{ runner.os }}-gitlibs-
- name: Prepare java
uses: actions/setup-java@v2
with:
Expand All @@ -21,20 +30,19 @@ runs:
- uses: DeLaGuardo/[email protected]
with:
cli: 1.10.3.986
lein: 2.9.7

- name: Fetch maven dependencies
shell: bash
# 'if' not supported yet, workaround in bash
# https://github.com/actions/runner/issues/834
# if: steps.restore-maven.outputs.cache-hit != 'true'
# run: lein deps
# run: clj -P
run: |
if echo ${{ steps.restore-maven.outputs.cache-hit }} | grep -c "true"
then
echo "Cache hit - skipping dependency installation"
else
${{ runner.os != 'Windows' && 'lein deps' || 'pwsh -c "lein deps"' }}
${{ runner.os != 'Windows' && 'clj -P' || 'pwsh -c "clj -P"' }}
fi
42 changes: 12 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:
- 'docs/**'

env:
REGISTRY: ghcr.io # Github container registry https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
# Github container registry https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
REGISTRY: ghcr.io

jobs:

Expand All @@ -28,14 +29,11 @@ jobs:
- uses: ./.github/custom-actions/node-env

- name: Run JVM tests
run: script/test/jvm

- name: Compile components
run: yarn components
run: yarn server:test

# TODO: re-enable once web build is fixed
# - name: Run Karma tests
# run: script/test/karma
# run: yarn client:test

lint:
runs-on: ubuntu-latest
Expand All @@ -46,27 +44,14 @@ jobs:
fetch-depth: 1
submodules: 'true'

# We don't use yarn lint here in order to have faster CI.
# Keep version and script up to date!
- uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2021.03.03'
version: '2021.08.06'

- name: Lint
run: script/lint

# # ignore for now
# deps-check:
# runs-on: ubuntu-18.04
# steps:
# - name: Git checkout
# uses: actions/checkout@v1
# with:
# fetch-depth: 1
# submodules: 'true'
#
# - uses: ./.github/custom-actions/clojure-env
#
# - name: Check Dependencies
# run: lein ancient
run: clj-kondo --lint src

style:
runs-on: ubuntu-latest
Expand All @@ -80,7 +65,7 @@ jobs:
- uses: ./.github/custom-actions/clojure-env

- name: Style
run: script/style
run: yarn lint

carve:
runs-on: ubuntu-latest
Expand All @@ -94,7 +79,7 @@ jobs:
- uses: ./.github/custom-actions/clojure-env

- name: Carve unused vars
run: script/carve
run: yarn carve

build-app:
needs: [test, lint, style, carve]
Expand All @@ -110,11 +95,8 @@ jobs:
- uses: ./.github/custom-actions/clojure-env
- uses: ./.github/custom-actions/node-env

- name: Compile components
run: yarn components

- name: Compile JS Assets
run: lein run -m shadow.cljs.devtools.cli --npm release main renderer --config-merge "{:closure-defines {athens.core/SENTRY_DSN \"${SENTRY_DSN}\" athens.util/COMMIT_URL \"${COMMIT_URL}\" athens.main.core/AUTO_UPDATE ${AUTO_UPDATE}}}"
run: yarn prod --config-merge "{:closure-defines {athens.core/SENTRY_DSN \"${SENTRY_DSN}\" athens.util/COMMIT_URL \"${COMMIT_URL}\" athens.main.core/AUTO_UPDATE ${AUTO_UPDATE}}}"
env:
SENTRY_DSN: ${{ secrets.sentry_dsn }}
AUTO_UPDATE: ${{ github.ref == 'refs/heads/main' }}
Expand Down Expand Up @@ -234,7 +216,7 @@ jobs:
- uses: ./.github/custom-actions/clojure-env

- name: Build server JAR
run: lein uberjar
run: yarn server

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
10 changes: 5 additions & 5 deletions README.self-hosted.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Use DB Picker -> join with `localhost:3010` as URL, no password.

To create uberjar:
``` shell
lein uberjar
yarn server
```

This will create `target/athens-lan-party-standalone.jar`.
Expand Down Expand Up @@ -39,10 +39,10 @@ In the output you can notice `Starting WebServer with config: {:port 3010}`,
this **3010** is the port number that Athens Lan-Party runs on,
notice it might be different number if you've changed configuration.

### Running Athens Self-Hosted Server (using `lein`)
### Running Athens Self-Hosted Server

``` shell
lein run
yarn server:run
```

This will start HTTP server on port 3010, unless you've modified `src/clj/config.edn`.
Expand All @@ -54,7 +54,7 @@ Also nREPL server is started on port 8877, unless you've modified `src/clj/confi
Start REPL:

``` shell
lein repl
yarn server:repl
```

Start the system:
Expand All @@ -76,7 +76,7 @@ After starting HTTP & nREPL servers are running on default ports or changes in `

**Clean the Datahike DB**

Stop the Self-Hosted server. [ctrl+c] if using `lein run` or [ctrl+d] if repl.
Stop the Self-Hosted server. [ctrl+c] if using `yarn server:run` or [ctrl+d] if repl.
By default Datahike DB is stored in `/tmp/exmaple`, remove this forlder
start the srever and Bob's your unkle.

Expand Down
2 changes: 1 addition & 1 deletion athens-data/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# athens-data

This is where `lein run` and `docker compose up` will place data files while working in dev setups.
This is where `yarn server:run` and `docker compose up` will place data files while working in dev setups.
19 changes: 19 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns build
"Build the Athens server uberjar.
From https://clojure.org/guides/tools_build#_compiled_uberjar_application_build"
(:require [clojure.tools.build.api :as b]))

(def version (format "1.0.0-alpha.rtc.xx"))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file "target/athens-lan-party-standalone.jar")

(defn uber [_]
(b/delete {:path "target"})
(b/compile-clj {:basis basis
:src-dirs ["src/clj" "src/cljc"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis
:main 'athens.self-hosted.core}))
68 changes: 56 additions & 12 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{:aliases
{:carve
{:extra-deps
#:borkdude{carve
{:git/url "https://github.com/borkdude/carve"
:sha "4b5010a09e030dbd998faff718d12400748ab3b9"}}
:main-opts ["-m" "carve.main"]}}

:paths ["src" "target/classes"]
{:paths ["src/clj" "src/cljs" "src/cljc" "src/js" "src/gen"]

:deps
{org.clojure/clojure #:mvn{:version "1.10.3"}
Expand All @@ -29,9 +21,12 @@
tick/tick #:mvn{:version "0.4.26-alpha"}
com.rpl/specter #:mvn{:version "1.1.3"}
com.taoensso/sente #:mvn{:version "1.16.2"}
binaryage/devtools #:mvn{:version "1.0.3"}
day8.re-frame/re-frame-10x #:mvn{:version "1.1.13"}
day8.re-frame/tracing #:mvn{:version "0.6.2"}
;; TODO: use released version after >1.5.9 release.
org.flatland/ordered {:git/url "https://github.com/clj-commons/ordered.git"
:sha "c6612e46a596842336b24f0bc6fac2d638c46224"}
org.flatland/ordered #:git{:url "https://github.com/clj-commons/ordered.git"
:sha "c6612e46a596842336b24f0bc6fac2d638c46224"}
;; backend
;; logging hell
org.clojure/tools.logging #:mvn{:version "1.1.0"}
Expand All @@ -51,4 +46,53 @@
metosin/malli #:mvn{:version "0.5.1"}
;; networked repl
com.stuartsierra/component.repl #:mvn{:version "0.2.0"}
nrepl/nrepl #:mvn{:version "0.8.3"}}}
nrepl/nrepl #:mvn{:version "0.8.3"}
cider/cider-nrepl #:mvn{:version "0.27.2"}}

:aliases
{:carve
{:extra-deps {borkdude/carve
#:git{:url "https://github.com/borkdude/carve"
:sha "c9a4dec89032f2003cc439c473fcd3c41e809669"}}
:main-opts ["-m" "carve.main"]}

:cljstyle
{:deps {mvxcvi/cljstyle
#:git{:url "https://github.com/greglook/cljstyle.git"
:sha "13fd2a3ff4097f1ed5c7ec96baf13e547ac2a26b"}

;; Workaround for https://github.com/greglook/cljstyle/issues/79
rewrite-clj/rewrite-clj
#:mvn{:version "1.0.594-alpha"}}
:main-opts ["-m" "cljstyle.main"]}

:clj-kondo
{:extra-deps {borkdude/clj-kondo
#:git{:url "https://github.com/borkdude/clj-kondo"
:sha "9bb69c3188f7efe6e17d392def89e89ec9d85ae5"
:tag "v2021.08.06"}}
:main-opts ["-m" "clj-kondo.main"]}

:outdated
{:extra-deps {com.github.liquidz/antq
#:mvn{:version "1.1.0"}}
;; Very noisy, due to https://github.com/liquidz/antq/issues/108
:main-opts ["-m" "antq.core"]}

:build
{:deps {io.github.clojure/tools.build
#:git{:sha "599be6c8c94a6ac6cc02fc9b43536f9052225b60"
:tag "v0.5.1"}}
:ns-default build}

:test
{:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
#:git{:url "https://github.com/cognitect-labs/test-runner.git"
:sha "48c3c67f98362ba1e20526db4eeb6996209c050a"
:tag "v0.5.0"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}

:athens
{:main-opts ["-m" "athens.self-hosted.core"]}}}
4 changes: 2 additions & 2 deletions dev/Brewfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
brew 'openjdk@11'
brew 'leiningen'
brew 'yarn'
brew 'clojure'
brew 'yarn'
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,34 @@
"url": "https://github.com/athensresearch/athens/"
},
"scripts": {
"//repo scripts": "",
"update:dry": "standard-version --dry-run -p --releaseCommitMessageFormat v{{currentTag}}",
"update": "standard-version -p --releaseCommitMessageFormat v{{currentTag}}",
"clean": "rm -rf resources/public/**/*.js target .shadow-cljs src/gen",
"lint": "clj -M:clj-kondo --lint src",
"style": "clj -M:cljstyle check",
"style:fix": "clj -M:cljstyle fix",
"carve": "clj -M:carve --opts '{:paths [\"src\" \"test\"] :report {:format :text}}'",
"carve:interactive": "clj -M:carve --opts '{:paths [\"src\" \"test\"]}'",
"clj:outdated": "clj -M:outdated",
"//client scripts": "",
"dev": "yarn components && concurrently \"yarn components:watch\" \"yarn client:watch\"",
"client:watch": "shadow-cljs watch main renderer app",
"client:test": "yarn components && shadow-cljs compile karma-test && karma start --single-run",
"client:electron": "electron .",
"components": "babel ./src/js/components/ --extensions \".ts,.tsx\" --out-dir ./src/gen/components/",
"components:watch": "yarn components --watch",
"compile": "yarn components && shadow-cljs compile main renderer app",
"prod": "yarn components && shadow-cljs release main renderer app",
"clean": "rm -rf resources/public/**/*.js target .shadow-cljs src/gen",
"dist": "electron-builder -p always",
"storybook:watch": "start-storybook -p 6006",
"storybook": "build-storybook",
"vercel-build": "yarn storybook"
"vercel-build": "yarn storybook",
"//server scripts": "",
"server": "clj -T:build uber",
"server:run": "clj -M:athens",
"server:test": "clj -X:test :excludes '[:stress]'",
"server:test:only": "clj -M:test --var",
"server:repl": "clj"
},
"main": "resources/main.js",
"build": {
Expand Down
Loading

0 comments on commit af8cfc9

Please sign in to comment.