Skip to content

Commit 5d89afc

Browse files
authored
Merge pull request #3 from celadari/v2
V2
2 parents 5f8020e + af7d880 commit 5d89afc

File tree

305 files changed

+16399
-778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+16399
-778
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
name: Build
3+
on: [push]
4+
jobs:
5+
build:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: Set up JDK 11
10+
uses: actions/setup-java@v2
11+
with:
12+
java-version: '11'
13+
distribution: 'adopt'
14+
- name: Cache Java modules
15+
uses: actions/cache@v2
16+
env:
17+
cache-name: cache-java-modules
18+
with:
19+
path: ~/.m2
20+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
21+
restore-keys: |
22+
${{ runner.os }}-build-${{ env.cache-name }}-
23+
${{ runner.os }}-build-
24+
${{ runner.os }}-
25+
- name: Cache Scala modules
26+
uses: actions/cache@v2
27+
env:
28+
cache-name: cache-scala-modules
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
32+
restore-keys: |
33+
${{ runner.os }}-build-${{ env.cache-name }}-
34+
${{ runner.os }}-build-
35+
${{ runner.os }}-
36+
- name: Cache Sbt modules
37+
uses: actions/cache@v2
38+
env:
39+
cache-name: cache-sbt-modules
40+
with:
41+
path: ~/.sbt/1.0
42+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
43+
restore-keys: |
44+
${{ runner.os }}-build-${{ env.cache-name }}-
45+
${{ runner.os }}-build-
46+
${{ runner.os }}-
47+
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
48+
run: |
49+
sbt +package

.github/workflows/linter.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
name: Linter
3+
on: [push]
4+
jobs:
5+
linter:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: Set up JDK 11
10+
uses: actions/setup-java@v2
11+
with:
12+
java-version: '11'
13+
distribution: 'adopt'
14+
- name: Run Scalastyle Linter
15+
run: |
16+
sbt +scalastyle
17+
sbt +test:scalastyle

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
name: Publish documentation to project website and Package to Maven Central Repository
3+
on:
4+
release:
5+
types: [created]
6+
jobs:
7+
publish-doc:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Install ansi2txt tool
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install colorized-logs
14+
- uses: actions/checkout@v2
15+
with:
16+
token: ${{ secrets.PAT_TOKEN }}
17+
- name: Generate API Doc
18+
run: sbt +doc
19+
- name: Make API Doc directory outside repository
20+
run: mkdir -p ../api_docs
21+
- name: Move API Docs to outside directory
22+
run: |
23+
source .workflow-scripts/put_scala_docs_aside.sh ./target ../api_docs
24+
cp .workflow-scripts/move_scala_docs.sh ../api_docs/
25+
cp .workflow-scripts/update_json_api_versions.py ../api_docs/
26+
echo "scala_versions=$scala_versions" >> $GITHUB_ENV
27+
echo "api_version=$api_version" >> $GITHUB_ENV
28+
- name: Git checkout on gh-pages
29+
run: |
30+
git fetch
31+
git checkout gh-pages
32+
- name: Move API Docs to website API Docs directory
33+
run: |
34+
cd ..
35+
export scala_versions="${{ env.scala_versions }}"
36+
export api_version="${{ env.api_version }}"
37+
bash api_docs/move_scala_docs.sh ./api_docs "./${GITHUB_REPOSITORY#*/}/docs/_api" ./api_docs "./${GITHUB_REPOSITORY#*/}/docs/_data/api_versions.json"
38+
- name: Git add and commit on gh-pages
39+
run: |
40+
git config user.name "$GITHUB_ACTOR"
41+
git config user.email "$GITHUB_ACTOR+github-actions@users.noreply.github.com"
42+
git add docs/_api/.
43+
git add docs/_data/api_versions.json
44+
git commit -m "[RELEASE] Update doc version from branch \"$GITHUB_REF\" commit \"$GITHUB_REF\""
45+
git push
46+
47+
publish-package:
48+
runs-on: ubuntu-latest
49+
needs: [publish-doc]
50+
steps:
51+
- name: Install gpg secret key
52+
run: |
53+
cat <(echo -e "${{ secrets.SONATYPE_GPG_SECRET_KEY }}") | gpg --batch --import
54+
gpg --list-secret-keys --keyid-format LONG
55+
- uses: actions/checkout@v2
56+
- name: Set up Java
57+
uses: actions/setup-java@v2
58+
with:
59+
java-version: '11'
60+
distribution: 'adopt'
61+
- name: Publish package
62+
run: |
63+
sbt +publishSigned
64+
sbt +sonatypeBundleRelease
65+
env:
66+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
67+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

.github/workflows/tests.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
name: Unittests
3+
on: [push]
4+
jobs:
5+
retrieve-scala-versions:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: Install ansi2txt tool
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install colorized-logs
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 11
14+
uses: actions/setup-java@v2
15+
with:
16+
java-version: '11'
17+
distribution: 'adopt'
18+
- name: Retrieve Scala Versions from build.sbt file
19+
id: set-matrix
20+
run: |
21+
scalaVersionPref=$(sbt +scalaBinaryVersion | ansi2txt | grep -Eo '\[info\] [0-9]\.[0-9][0-9]' | sed -r 's/\[info\] ([0-9]\.[0-9][0-9])/\1/')
22+
scala_versions=$(echo "$scalaVersionPref" | tr '\n' ',')
23+
scala_versions="[${scala_versions%?}]"
24+
echo ::set-output name=matrix::"$scala_versions"
25+
outputs:
26+
scala_versions: ${{ steps.set-matrix.outputs.matrix }}
27+
28+
test-coverage:
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v2
34+
with:
35+
java-version: '11'
36+
distribution: 'adopt'
37+
- name: Cache Java modules
38+
uses: actions/cache@v2
39+
env:
40+
cache-name: cache-java-modules
41+
with:
42+
path: ~/.m2
43+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
44+
restore-keys: |
45+
${{ runner.os }}-build-${{ env.cache-name }}-
46+
${{ runner.os }}-build-
47+
${{ runner.os }}-
48+
- name: Cache Scala modules
49+
uses: actions/cache@v2
50+
env:
51+
cache-name: cache-scala-modules
52+
with:
53+
path: ~/.m2
54+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
55+
restore-keys: |
56+
${{ runner.os }}-build-${{ env.cache-name }}-
57+
${{ runner.os }}-build-
58+
${{ runner.os }}-
59+
- name: Cache Sbt modules
60+
uses: actions/cache@v2
61+
env:
62+
cache-name: cache-sbt-modules
63+
with:
64+
path: ~/.sbt/1.0
65+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
66+
restore-keys: |
67+
${{ runner.os }}-build-${{ env.cache-name }}-
68+
${{ runner.os }}-build-
69+
${{ runner.os }}-
70+
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
71+
run: |
72+
sbt +coverage +test
73+
sbt +coverageReport
74+
- uses: actions/upload-artifact@v2
75+
with:
76+
name: coverage-report
77+
path: ./target/scala-[0-9].[0-9][0-9]
78+
79+
upload-coverage:
80+
runs-on: ubuntu-latest
81+
needs: [retrieve-scala-versions, test-coverage]
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
scala_version: ${{ fromJSON(needs.retrieve-scala-versions.outputs.scala_versions) }}
86+
steps:
87+
- uses: actions/checkout@v2
88+
- uses: actions/download-artifact@v2
89+
with:
90+
name: coverage-report
91+
path: ./target/
92+
- uses: codecov/codecov-action@v2
93+
with:
94+
token: ${{ secrets.CODECOV_TOKEN }}
95+
directory: ./target/scala-${{ matrix.scala_version }}/
96+
flags: unittests,${{ matrix.scala_version }}/scoverage-report/scoverage.xml
97+
name: codecov-json-logic-scala
98+
fail_ci_if_error: true
99+
verbose: true

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
13
*.class
24
*.log
35

@@ -13,4 +15,6 @@ project/plugins/project/
1315
.scala_dependencies
1416

1517
# IntelliJ stuff
16-
.idea/
18+
.idea/
19+
20+
.bsp

.img/boolean_logical_tree.png

-55.7 KB
Loading

.img/jsonlogicscala_logo.jpg

638 KB
Loading

.workflow-scripts/move_scala_docs.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
3+
# shellcheck disable=SC2154
4+
for scala_version in $scala_versions
5+
do
6+
mkdir -p "$2/scala-$scala_version"
7+
rm -rf "$2/scala-$scala_version/latest"
8+
cp -r "$1/scala-$scala_version/$api_version" "$2/scala-$scala_version/latest"
9+
mv "$1/scala-$scala_version/$api_version" "$2/scala-$scala_version/"
10+
python "$3/update_json_api_versions.py" "$4" "$api_version" --scala-versions "$scala_versions"
11+
done
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019 celadari. All rights reserved. MIT license.
2+
3+
# shellcheck disable=SC2010
4+
scala_versions=$(ls "$1" | grep -Eo "[0-9]\.[0-9][0-9]" | tr '\n' ' ')
5+
api_version=$(sbt version | ansi2txt | tail -n1 | sed -r 's/^\[info\] (.+)$/\1/')
6+
7+
export scala_versions
8+
export api_version
9+
10+
for scala_version in $scala_versions
11+
do
12+
mkdir -p "$2/scala-$scala_version/$api_version"
13+
mv "$1/scala-$scala_version/api/" "$2/scala-$scala_version/$api_version/"
14+
done
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2019 celadari. All rights reserved. MIT license.
3+
4+
import argparse
5+
import json
6+
import os
7+
8+
9+
if __name__ == '__main__':
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument('path_json')
12+
parser.add_argument('api_version')
13+
parser.add_argument('--scala-versions', dest='scala_versions', nargs='+')
14+
args = parser.parse_args()
15+
16+
if os.path.isfile(args.path_json):
17+
with open(args.path_json, 'r') as f:
18+
data = json.load(f)
19+
else:
20+
data = {}
21+
for scala_version in args.scala_versions:
22+
scala_version_indices = [i for i, data_version in enumerate(data) if data_version['scala-version'] == scala_version]
23+
if scala_version_indices:
24+
scala_version_index = scala_version_indices[0]
25+
data[scala_version_index]['json-logic-versions'] = [args.api_version] + data[scala_version_index]['json-logic-versions']
26+
else:
27+
data.append({'scala-version': scala_version, 'json-logic-versions': [args.api_version]})
28+
with open(args.path_json, 'w') as f:
29+
json.dump(data, f)

0 commit comments

Comments
 (0)