Skip to content

Commit

Permalink
Merge pull request #2950 from CSCfi/into-shadow
Browse files Browse the repository at this point in the history
Into shadow
  • Loading branch information
Macroz authored Jun 3, 2022
2 parents e5fadd1 + d480615 commit 7306518
Show file tree
Hide file tree
Showing 26 changed files with 222 additions and 227 deletions.
31 changes: 14 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ defaults: &defaults
JVM_OPTS: -Xmx3200m

orbs:
browser-tools: circleci/browser-tools@1.2.4
browser-tools: circleci/browser-tools@1.3.0

executors:
clojure:
docker:
- image: cimg/clojure:1.10.3-browsers
- image: cimg/clojure:1.11.1-browsers
db:
docker:
- image: cimg/clojure:1.10.3-browsers
- image: cimg/clojure:1.11.1-browsers
- image: postgres:13
environment:
POSTGRES_HOST_AUTH_METHOD: trust
Expand All @@ -34,20 +34,17 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v3-dependencies-{{ checksum "project.clj" }}
- v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
# fallback to using the latest cache if no exact match is found
- v3-dependencies-
- run: lein deps
- run: lein cljsbuild deps
- run: npm install
# TODO using persist_to_workspace might be more robust than using cache
- save_cache:
paths:
- ~/.m2
# node_modules won't pick up updates to sub dependencies
# unless the project.clj is changed. This might create differences
# between dev, CI and actual deployment.
- node_modules
key: v3-dependencies-{{ checksum "project.clj" }}
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}

unit-test:
executor: clojure
Expand All @@ -56,11 +53,11 @@ jobs:
- browser-tools/install-chromedriver
- checkout
- restore_cache:
key: v3-dependencies-{{ checksum "project.clj" }}
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
# verify that we can run unit tests without the database:
- run: DATABASE_URL=invalid lein kaocha --reporter kaocha.report/documentation unit
- run: lein cljsbuild once
- run: lein doo chrome-headless test once
- run: lein shadow-build
- run: lein shadow-test
- store_test_results:
path: target/test-results

Expand All @@ -69,7 +66,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v3-dependencies-{{ checksum "project.clj" }}
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
- run: lein cljfmt check

integration-test:
Expand All @@ -79,7 +76,7 @@ jobs:
- browser-tools/install-chromedriver
- checkout
- restore_cache:
key: v3-dependencies-{{ checksum "project.clj" }}
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
- run: lein kaocha --reporter kaocha.report/documentation integration
- store_test_results:
path: target/test-results
Expand All @@ -91,8 +88,8 @@ jobs:
- browser-tools/install-chromedriver
- checkout
- restore_cache:
key: v3-dependencies-{{ checksum "project.clj" }}
- run: lein cljsbuild once
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
- run: lein shadow-build
- run: lein kaocha --reporter kaocha.report/documentation browser
- store_test_results:
path: target/test-results
Expand All @@ -108,7 +105,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v3-dependencies-{{ checksum "project.clj" }}
key: v3-dependencies-{{ checksum "project.clj" }}-{{ checksum "package.json" }}-{{ checksum "shadow-cljs.edn" }}
- run: lein uberjar
- store_artifacts:
path: target/uberjar/rems.jar
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
/.lsp/
/.clj-kondo/
/.vscode/
/.shadow-cljs/
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ have notable changes.

Changes since v2.26

NB: This is the first release with a new build tool – Shadow-CLJS.

### Additions
- Shopping cart can now be enabled or disabled in user interface with configuration option `:enable-cart`, which defaults to `true`. (#2720)

Expand Down
1 change: 0 additions & 1 deletion dev-config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
{:attribute "organizations"}]
:languages [:en :fi :sv]
:public-url "http://localhost:3000/"
:render-css-file? true
:extra-pages [{:id "about"
:translations {:fi {:title "Info"
:filename "about-fi.md"}
Expand Down
4 changes: 2 additions & 2 deletions docs/bots.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Bots

REMS has a number of features implemented as _bots_, automatic
handlers that can be attached to a workflow.
users, such as handlers that can be attached to a workflow.

To use a bot, create a user with the corresponding user id, and add
that user as a handler to a workflow. The 'email' attribute for the
that user as a handler to a workflow, if necessary. The 'email' attribute for the
user can be null, or the attribute can be left out completely. The
name of the bot will be visible to the applicants in the event log
as the person who approved or rejected their application so make it
Expand Down
42 changes: 22 additions & 20 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ In order to get started with REMS, you need to have the following software insta

- Docker
- Java. Currently REMS should be working with Java versions 11 to 17
- leiningen. As of 2021-11-01, the project should work with lein version Leiningen 2.9.7 on Java 17 OpenJDK 64-Bit Server VM.
- Leiningen. As of 2022-06-01, the project should work with lein version Leiningen 2.9.8 on Java 17 OpenJDK 64-Bit Server VM.
- npm and npx

### Mac OS installation for Apple M1 Chip (Apple Silicon M1)

1. Java Installation: install Java via Azul, make sure you download the version of [Java for MacOS for ARM architecture](https://www.azul.com/downloads/zulu-community/?os=macos&architecture=arm-64-bit&package=jdk).
Expand Down Expand Up @@ -43,25 +45,28 @@ lein run test-data

## Running the application

To start the (clojure) backend:
To start the (Clojure) backend:

```
lein run
```

To start the (clojurescript) frontend, run in another terminal:
To start the (ClojureScript) frontend, run in another terminal:

```
lein figwheel
lein shadow-watch
```

Point your browser to <http://localhost:3000>
Normally we run the application in port 3000. Point your browser to <http://localhost:3000>.
This supports live reload. Shadow-CLJS also exposes port 3100 for development.
The API and the static files are all served from the port 3000.
Shadow-CLJS has its own console in <http://localhost:9630>.

You can also use e.g. Emacs with CIDER integration and `cider-jack-in-clj&cljs`.
### Editor setup

You should start in the development profile i.e. set `Cider Lein Parameters` to `with-profile +dev repl :headless`
You can also use e.g. Emacs with CIDER integration and `cider-jack-in-clj&cljs`. Calva and Cursive have also been used successfully. And we regularly use Linux and Mac for development. YMMV.

We have had success with other editors as well.
In whatever editor you decide, you should start in the development profile, i.e., in Emacs set `Cider Lein Parameters` to `with-profile +dev repl :headless`.

## Building an uberjar

Expand Down Expand Up @@ -101,7 +106,7 @@ To run build the JS bundle and run browser tests (requires chromedriver in $PATH
lein browsertests
```

If browser tests fail, screenshots and DOM are written in the directory `browsertest-errors`.
As the tests run, and especially if browser tests fail, screenshots and DOM are written in the directory `browsertest-errors`.

For fixing or especially the development of the browser tests, you can run a windowed regular browser and see what the tests are doing.

Expand All @@ -116,21 +121,15 @@ HEADLESS=0 lein browsertests # to see all br
HEADLESS=0 lein kaocha --focus rems.test-browser/test-blacklist # to see a specific browser test
```

### Clojurescript tests

First make sure you have the npm depenencies with

```
lein deps
```
### ClojureScript tests

and then just run
We have some tests for specifically ClojureScript code. A helper runs them with

```
lein doo once
lein shadow-test
```

which will run the tests in a headless Chrome via Karma.
They will run the tests in a headless Chrome via Karma and Shadow-CLJS.

You may need to run `npm install karma karma-cljs-test karma-chrome-launcher` first to install the necessary tools and packages.

Expand All @@ -141,6 +140,7 @@ To conveniently run all the tests you can run the lein alias
```
lein alltests
```

### Automated accessibility test report

We use [axe](https://www.deque.com/axe/) for automated accessibility tests.
Expand Down Expand Up @@ -189,4 +189,6 @@ lein migratus down 20211105110533
To run specific migration up:
```sh
lein migratus up 20211105110533
```
```

NB: The migrations can also be written in Clojure. Then you should replace the `.sql` files with a `.edn` file. See examples in the migrations-directory.
17 changes: 17 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'target/shadow',
files: ['cljs-test.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher', 'karma-junit-reporter'],
reporters: ['progress', 'junit'],
junitReporter: {outputDir: 'target/test-results'},
colors: true,
logLevel: config.LOG_INFO,
singleRun: true,
client: {
args: ["shadow.test.karma.init"],
}
})
};
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"dependencies": {
"react": "16.9.0",
"react-dom": "16.9.0",
"react-select": "2.4.4"
},
"devDependencies": {
"karma": "^6.3.20",
"karma-chrome-launcher": "^3.1.1",
"karma-cljs-test": "^0.1.0",
"karma-junit-reporter": "^2.0.1",
"puppeteer": "^14.1.2",
"shadow-cljs": "^2.16.6"
},
"scripts": {
"dev": "shadow-cljs watch app"
}
}
Loading

0 comments on commit 7306518

Please sign in to comment.