Skip to content

Commit

Permalink
Add Github actions workflow for running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pekka Kaitaniemi authored and kaitanie committed Feb 5, 2024
1 parent 698fa65 commit 7158132
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Run tests

on:
push:
branches: [master]
pull_request:
branches: [master]

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

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

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Java ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.jdk }}
cache: maven
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: latest
- name: Run tests
run: CLOJURE_ALIAS=clojure-${{ matrix.clojure }} bin/run-clojure-tests

build-cljs:
name: ClojureScript
strategy:
matrix:
mode: [none, advanced, cherry-none, cherry-advanced]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java 11
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
cache: maven
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: latest
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 16
- name: Run tests on ${{ matrix.mode }}
run: bin/run-cljs-tests ${{ matrix.mode }}
32 changes: 32 additions & 0 deletions bin/run-cljs-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -eo pipefail

none() {
echo 'Running CLJS test in Node with optimizations :none'
TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :none}' "$@"
}

advanced() {
echo 'Running CLJS test in Node with optimizations :advanced'
TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :advanced}' -e :simple "$@"
}

cherry-none() {
echo 'Running CLJS test in Node with cherry + optimizations :none'
clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :none}' "$@"
}

cherry-advanced() {
echo 'Running CLJS test in Node with cherry + optimizations :advanced'
# :optimize-constants is set to false until https://clojure.atlassian.net/browse/CLJS-3401 is fixed
clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :advanced :optimize-constants false}' -e :simple "$@"
}

case $1 in
none) none ;;
advanced) advanced ;;
cherry-none) cherry-none ;;
cherry-advanced) cherry-advanced ;;
*) none; advanced; cherry; cherry-advanced ;;
esac
3 changes: 3 additions & 0 deletions bin/run-clojure-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# Should work if the env var is empty
clojure -A:$CLOJURE_ALIAS -M:test -m kaocha.runner "$@"
57 changes: 57 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>metosin</groupId>
<artifactId>virhe</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>virhe</name>
<licenses>
<license>
<name>Eclipse Public License 2.0</name>
<url>https://www.eclipse.org/legal/epl-2.0/</url>
</license>
</licenses>
<scm>
<url>https://github.com/metosin/virhe</url>
<connection>scm:git:git://github.com/metosin/virhe.git</connection>
<developerConnection>scm:git:ssh://[email protected]/metosin/virhe.git</developerConnection>
</scm>
<dependencies>
<dependency>
<groupId>fipp</groupId>
<artifactId>fipp</artifactId>
<version>0.6.26</version>
</dependency>
<dependency>
<groupId>mvxcvi</groupId>
<artifactId>arrangement</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>test.check</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>clojars</id>
<name>Clojars repository</name>
<url>https://clojars.org/repo</url>
</repository>
</distributionManagement>
</project>

0 comments on commit 7158132

Please sign in to comment.