Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Vyshniak <[email protected]>
  • Loading branch information
abanias authored and molekyla committed Aug 21, 2023
0 parents commit 3382a2b
Show file tree
Hide file tree
Showing 40 changed files with 1,634 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -ev

export GPG_TTY=$(tty)
export SONATYPE_USERNAME=$OSSRH_USERNAME
export SONATYPE_PASSWORD=$OSSRH_PASSWORD
export PGP_PASSPHRASE=$GPG_PASSPHRASE

gpg --version

# Import gpg key
echo $GPG_PRIVATE_KEY | base64 -d > private.key
gpg --import --batch private.key

# Deploy to Maven Central
sbt sonatypeDropAll
sbt publishSigned
sbt sonatypeRelease
17 changes: 17 additions & 0 deletions .github/scripts/push-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -ev

# Prepare release
git config user.name "GitHub Action"
git config user.email "[email protected]"

PREVIOUS_RELEASE_TAG=$(git describe --abbrev=0)
if [[ ${PREVIOUS_RELEASE_TAG} =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
# Set current released version
sbt -DcurrentVersion=${PREVIOUS_RELEASE_TAG} prepareRelease
else
echo "Cannot parse the latest release tag: ${PREVIOUS_RELEASE_TAG}. Aborting release."
exit 1
fi

git push origin --tags
43 changes: 43 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check

# Controls when the workflow will run
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


jobs:
check:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'

- name: Cache SBT
uses: actions/cache@v3
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt', 'project/**') }}

- name: sbt-header-check
run: sbt headerCheck

- name: sbt-scala-formatter-check
run: sbt scalafmtCheck scalafmtSbtCheck
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
workflow_run:
workflows: ["Test"]
branches: [ master ]
types:
- completed

jobs:
release:

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip release]')"

steps:
- uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Cache SBT
uses: actions/cache@v3
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt', 'project/**') }}
- name: Push git tag
run: ./.github/scripts/push-tag.sh
- name: Deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_KEY }}
run: ./.github/scripts/deploy.sh
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test

# Controls when the workflow will run
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'

- name: Cache SBT
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt', 'project/**') }}

- name: load-here-secret
env:
OLP_CREDENTIALS: ${{ secrets.OLP_CREDENTIALS }}
run: mkdir -p ~/.here/ && echo $OLP_CREDENTIALS | base64 --decode > ~/.here/credentials.properties

- name: load-ivy2-secret
env:
SBT_CREDENTIALS: ${{ secrets.SBT_CREDENTIALS }}
run: mkdir -p ~/.ivy2/ && echo $SBT_CREDENTIALS | base64 --decode > ~/.ivy2/.credentials

- name: build
run: sbt ';sbt-bom / scripted' -Dsbt.boot.credentials="~/.ivy2/.credentials"

- name: test
run: sbt clean coverageOn coverage test coverageReport

- name: update-version
run: |
CURRENT_VERSION=$(git fetch &>/dev/null; git tag -l --sort=taggerdate | grep -vE '[a-zA-Z]' | tail -n 1)
echo "CURRENT_VERSION=${CURRENT_VERSION}" | tee current-version.env
sed -i "s/0.0.0-SNAPSHOT/$CURRENT_VERSION/g" version.sbt
- name: package
run: sbt package
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/*
target/
project/target/*
project/project/target/*
.bsp/*

12 changes: 12 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
style = default
align.tokens = []
assumeStandardLibraryStripMargin = true
maxColumn = 100
rewrite.rules = [
sortimports,
sortModifiers,
prefercurlyfors
]
version = 3.7.3
runner.dialect = scala212
docstrings.style = Asterisk
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing Guide

## Introduction

The team gratefully accepts contributions via [pull requests](https://help.github.com/articles/about-pull-requests/).

## Tests

The project has integration tests based on `scripted test framework`.
See https://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html
Command to run the tests: `sbt ';sbt-bom / scripted'`

## Coding Standards

Styles conventions:

- Each Scala class should have a **Copyright Notice**:
```text
/*
* Copyright (C) 20<x>-20<y> HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
```
replace the `<x>` and `<y>` with numbers to denote the years in which the materials were created and modified.
- The package name should start with `com.here`
- The folder structure should reflect the package name
- Basic Scala stylistic guidelines can be found [here](https://docs.scala-lang.org/style/).
- It is recommended to use [Scalafmt](https://scalameta.org/scalafmt/) code formatter. The configuration is in `.scalafmt.conf` file.

You may use [IntelliJ IDEA scalfmt plugin](https://plugins.jetbrains.com/plugin/8236-scalafmt)
or the following SBT commands available in the project:

* `scalafmtSrcAll` - formats compile sources, test sources and sbt sources
* `scalafmt` - formats compile sources.
* `scalafmtSbt` - formats sbt sources.
* `scalafmtCheckAll` - checks that all project sources are properly formatted and fails otherwise.

# Commit Signing

As part of filing a pull request we ask you to sign off the
[Developer Certificate of Origin](https://developercertificate.org/) (DCO) in each commit.
Any Pull Request with commits that are not signed off will be reject by the
[DCO check](https://probot.github.io/apps/dco/).

A DCO is lightweight way for contributors to confirm that they wrote or otherwise have the right
to submit code or documentation to a project. Simply add `Signed-off-by` as shown in the example below
to indicate that you agree with the DCO.

An example signed commit message:

```
README.md: Fix minor spelling mistake
Signed-off-by: John Doe <[email protected]>
```

Git has the `-s` flag that can sign a commit for you, see example below:

`$ git commit -s -m 'README.md: Fix minor spelling mistake'`

# GitHub Actions
All opened pull requests are tested by GitHub Actions before they can be merged into the target branch.
After the new code is pushed to `master` GitHub Actions will run the test suite again, build the artifacts and release them
to Maven Central repository. The job will automatically increase patch version during this process.
If you do not want your changes to trigger a release, add the `[skip release]` flag to your commit message,
e.g., `git commit -s -m "[skip release] Fixed proxy configuration"`. We recommend this for example when you update
CI scripts or documentation such as README.md and CONTRIBUTING.md.
16 changes: 16 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Copyright (C) 2019-2023 HERE Europe B.V.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache-2.0
License-Filename: LICENSE
Loading

0 comments on commit 3382a2b

Please sign in to comment.