Skip to content

Commit

Permalink
Merge pull request #3 from celadari/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
celadari authored Nov 23, 2021
2 parents 5f8020e + af7d880 commit 5d89afc
Show file tree
Hide file tree
Showing 305 changed files with 16,399 additions and 778 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2019 celadari. All rights reserved. MIT license.
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache Java modules
uses: actions/cache@v2
env:
cache-name: cache-java-modules
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Scala modules
uses: actions/cache@v2
env:
cache-name: cache-scala-modules
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Sbt modules
uses: actions/cache@v2
env:
cache-name: cache-sbt-modules
with:
path: ~/.sbt/1.0
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
run: |
sbt +package
17 changes: 17 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2019 celadari. All rights reserved. MIT license.
name: Linter
on: [push]
jobs:
linter:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Run Scalastyle Linter
run: |
sbt +scalastyle
sbt +test:scalastyle
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2019 celadari. All rights reserved. MIT license.
name: Publish documentation to project website and Package to Maven Central Repository
on:
release:
types: [created]
jobs:
publish-doc:
runs-on: ubuntu-20.04
steps:
- name: Install ansi2txt tool
run: |
sudo apt-get update
sudo apt-get install colorized-logs
- uses: actions/checkout@v2
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Generate API Doc
run: sbt +doc
- name: Make API Doc directory outside repository
run: mkdir -p ../api_docs
- name: Move API Docs to outside directory
run: |
source .workflow-scripts/put_scala_docs_aside.sh ./target ../api_docs
cp .workflow-scripts/move_scala_docs.sh ../api_docs/
cp .workflow-scripts/update_json_api_versions.py ../api_docs/
echo "scala_versions=$scala_versions" >> $GITHUB_ENV
echo "api_version=$api_version" >> $GITHUB_ENV
- name: Git checkout on gh-pages
run: |
git fetch
git checkout gh-pages
- name: Move API Docs to website API Docs directory
run: |
cd ..
export scala_versions="${{ env.scala_versions }}"
export api_version="${{ env.api_version }}"
bash api_docs/move_scala_docs.sh ./api_docs "./${GITHUB_REPOSITORY#*/}/docs/_api" ./api_docs "./${GITHUB_REPOSITORY#*/}/docs/_data/api_versions.json"
- name: Git add and commit on gh-pages
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add docs/_api/.
git add docs/_data/api_versions.json
git commit -m "[RELEASE] Update doc version from branch \"$GITHUB_REF\" commit \"$GITHUB_REF\""
git push
publish-package:
runs-on: ubuntu-latest
needs: [publish-doc]
steps:
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.SONATYPE_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Publish package
run: |
sbt +publishSigned
sbt +sonatypeBundleRelease
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
99 changes: 99 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright 2019 celadari. All rights reserved. MIT license.
name: Unittests
on: [push]
jobs:
retrieve-scala-versions:
runs-on: ubuntu-20.04
steps:
- name: Install ansi2txt tool
run: |
sudo apt-get update
sudo apt-get install colorized-logs
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Retrieve Scala Versions from build.sbt file
id: set-matrix
run: |
scalaVersionPref=$(sbt +scalaBinaryVersion | ansi2txt | grep -Eo '\[info\] [0-9]\.[0-9][0-9]' | sed -r 's/\[info\] ([0-9]\.[0-9][0-9])/\1/')
scala_versions=$(echo "$scalaVersionPref" | tr '\n' ',')
scala_versions="[${scala_versions%?}]"
echo ::set-output name=matrix::"$scala_versions"
outputs:
scala_versions: ${{ steps.set-matrix.outputs.matrix }}

test-coverage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache Java modules
uses: actions/cache@v2
env:
cache-name: cache-java-modules
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Scala modules
uses: actions/cache@v2
env:
cache-name: cache-scala-modules
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Sbt modules
uses: actions/cache@v2
env:
cache-name: cache-sbt-modules
with:
path: ~/.sbt/1.0
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
run: |
sbt +coverage +test
sbt +coverageReport
- uses: actions/upload-artifact@v2
with:
name: coverage-report
path: ./target/scala-[0-9].[0-9][0-9]

upload-coverage:
runs-on: ubuntu-latest
needs: [retrieve-scala-versions, test-coverage]
strategy:
fail-fast: false
matrix:
scala_version: ${{ fromJSON(needs.retrieve-scala-versions.outputs.scala_versions) }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage-report
path: ./target/
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./target/scala-${{ matrix.scala_version }}/
flags: unittests,${{ matrix.scala_version }}/scoverage-report/scoverage.xml
name: codecov-json-logic-scala
fail_ci_if_error: true
verbose: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2019 celadari. All rights reserved. MIT license.

*.class
*.log

Expand All @@ -13,4 +15,6 @@ project/plugins/project/
.scala_dependencies

# IntelliJ stuff
.idea/
.idea/

.bsp
Binary file modified .img/boolean_logical_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .img/jsonlogicscala_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions .workflow-scripts/move_scala_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2019 celadari. All rights reserved. MIT license.

# shellcheck disable=SC2154
for scala_version in $scala_versions
do
mkdir -p "$2/scala-$scala_version"
rm -rf "$2/scala-$scala_version/latest"
cp -r "$1/scala-$scala_version/$api_version" "$2/scala-$scala_version/latest"
mv "$1/scala-$scala_version/$api_version" "$2/scala-$scala_version/"
python "$3/update_json_api_versions.py" "$4" "$api_version" --scala-versions "$scala_versions"
done
14 changes: 14 additions & 0 deletions .workflow-scripts/put_scala_docs_aside.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 celadari. All rights reserved. MIT license.

# shellcheck disable=SC2010
scala_versions=$(ls "$1" | grep -Eo "[0-9]\.[0-9][0-9]" | tr '\n' ' ')
api_version=$(sbt version | ansi2txt | tail -n1 | sed -r 's/^\[info\] (.+)$/\1/')

export scala_versions
export api_version

for scala_version in $scala_versions
do
mkdir -p "$2/scala-$scala_version/$api_version"
mv "$1/scala-$scala_version/api/" "$2/scala-$scala_version/$api_version/"
done
29 changes: 29 additions & 0 deletions .workflow-scripts/update_json_api_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2019 celadari. All rights reserved. MIT license.

import argparse
import json
import os


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('path_json')
parser.add_argument('api_version')
parser.add_argument('--scala-versions', dest='scala_versions', nargs='+')
args = parser.parse_args()

if os.path.isfile(args.path_json):
with open(args.path_json, 'r') as f:
data = json.load(f)
else:
data = {}
for scala_version in args.scala_versions:
scala_version_indices = [i for i, data_version in enumerate(data) if data_version['scala-version'] == scala_version]
if scala_version_indices:
scala_version_index = scala_version_indices[0]
data[scala_version_index]['json-logic-versions'] = [args.api_version] + data[scala_version_index]['json-logic-versions']
else:
data.append({'scala-version': scala_version, 'json-logic-versions': [args.api_version]})
with open(args.path_json, 'w') as f:
json.dump(data, f)
Loading

0 comments on commit 5d89afc

Please sign in to comment.