Skip to content

Commit

Permalink
Use babashka tasks for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Apr 23, 2024
1 parent 31b80e2 commit 8c4eb16
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 39 deletions.
74 changes: 41 additions & 33 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,59 @@ name: ci
on: [push]

jobs:

test:

name: Test
runs-on: ubuntu-20.04

runs-on: ubuntu-22.04

container:
# Source: https://github.com/day8/dockerfiles-for-dev-ci-images
image: ghcr.io/day8/chrome-56:2
image: ghcr.io/day8/chrome-87:6.0.8
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v1
- name: Maven cache
uses: actions/cache@v1
id: maven-cache
with:
path: /root/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj', 'deps.edn', '.github/workflows/**') }}
restore-keys: |
${{ runner.os }}-maven-
- name: npm cache
uses: actions/cache@v1
- uses: actions/checkout@v4

- name: Install clojure tools
uses: DeLaGuardo/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: shadow-cljs compiler cache
uses: actions/cache@v1
cli: 'latest'
bb: 'latest'

- name: Cache clojure dependencies
uses: actions/cache@v3
with:
path: .shadow-cljs
key: ${{ runner.os }}-shadow-cljs-${{ github.sha }}
restore-keys: |
${{ runner.os }}-shadow-cljs-
- if: steps.maven-cache.outputs.cache-hit != 'true'
run: |
lein ci
lein build-report-ci
- if: steps.maven-cache.outputs.cache-hit == 'true'
run: |
lein -o ci
lein -o build-report-ci
- uses: actions/upload-artifact@v2
path: |
~/.m2/repository
~/.gitlibs
~/.deps.clj
~/.npm
.shadow-cljs
key: cljdeps-${{ hashFiles('deps.edn') }}
restore-keys: cljdeps-

- name: Fix git dubious directory ownership error
run: git config --global --add safe.directory /__w/re-com/re-com

- run: mkdir -p run/resources/public/compiled_prod/demo
- run: id
- run: ls -lah
- run: ls -lah run/
- run: ls -lah run/resources/
- run: ls -lah run/resources/public/
- run: ls -lah run/resources/public/compiled_prod/
- run: bb ci

- run: bb build-report-ci

- uses: actions/upload-artifact@v4
with:
name: build-report
path: target/build-report.html

- name: Slack notification
uses: homoluctus/[email protected]
if: failure() || cancelled()
Expand Down
25 changes: 25 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{:min-bb-version "0.4.0"
:tasks
{:requires ([babashka.fs :as fs])
clean (let [clean-targets ["node_modules"
"run/resources/public/compiled_dev "
"run/resources/public/compiled_prod"
"run/resources/public/compiled_test"]]
(doseq [target clean-targets]
(println "bb clean: deleting" target)
(fs/delete-tree target)))
install (shell "npm install")
test {:depends [clean install]
:task (do (shell "npx shadow-cljs compile karma-test")
(shell "npx karma start --single-run --reporters junit,dots"))}
release-demo {:depends [clean install]
:task (shell "npx shadow-cljs release demo")}
prod-once {:depends [release-demo]}
ci {:depends [clean install release-demo]}
build-report-ci {:depends [clean install]
:task (shell
"npx shadow-cljs clj-run shadow.cljs.build-report demo target/build-report.html")}
watch {:depends [clean install]
:task (shell "npx shadow-cljs watch demo browser-test karma-test")}
deploy-aws {:depends [ci]
:task (shell "aws s3 sync run/resources/public s3://re-demo/ --acl public-read --cache-control max-age=2592000,public")}}}
9 changes: 3 additions & 6 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:lein {:profile "+demo"}
{:deps true
:nrepl {:port 7777}

:builds {:demo
Expand All @@ -14,17 +14,14 @@
;; symbols for display in validation error logging.
:pseudo-names true
:externs ["externs/detect-element-resize-externs.js"]}
:dev {:asset-path "/compiled_dev/demo"
:output-dir "run/resources/public/compiled_dev/demo"
:compiler-options
:dev {:compiler-options
{:closure-defines {;; When re-com produces validation errors it tries to provide links
;; to source code. These links require that you provide the root URL
;; to the ClojureScript compiler output with source maps.
re-com.config/root-url-for-compiler-output
"http://localhost:3449/compiled_dev/demo/cljs-runtime/"}
:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}}
:release {:output-dir "run/resources/public/compiled_prod/demo"
:compiler-options {:closure-defines {;; For production builds, such as the demo website, there is no source
:release {:compiler-options {:closure-defines {;; For production builds, such as the demo website, there is no source
;; code to link to in validation errors or component stacks, so we set
;; it to an empty string to cause links to not be displayed at all.
re-com.config/root-url-for-compiler-output ""}}}
Expand Down

0 comments on commit 8c4eb16

Please sign in to comment.