Skip to content

Commit

Permalink
[DOP-18232] Replace SBT with Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Sep 25, 2024
1 parent 338ead4 commit 347fb8d
Show file tree
Hide file tree
Showing 17 changed files with 564 additions and 176 deletions.
1 change: 1 addition & 0 deletions .bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"sbt","version":"1.8.3","bspVersion":"2.1.0-M1","languages":["scala"],"argv":["/home/maxim/.sdkman/candidates/java/11.0.22-tem/bin/java","-Xms100m","-Xmx100m","-classpath","/home/maxim/.sdkman/candidates/sbt/1.7.1/bin/sbt-launch.jar","-Dsbt.script=/home/maxim/.sdkman/candidates/sbt/current/bin/sbt","xsbt.boot.Boot","-bsp"]}
67 changes: 8 additions & 59 deletions .github/workflows/codeql-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Setup JDK 8
- name: Setup JDK 11
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '11'
distribution: 'temurin'

- name: Setup Scala and SBT
uses: olafurpg/setup-scala@v14
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
java-version: '8'

- name: Check and format code with Scalafmt
run: sbt scalafmtAll
cache-read-only: false
cache-overwrite-existing: true

- name: Check and fix code with Scalafix
run: sbt scalafixAll

- name: Check for changes and commit
id: git-check
run: |
if [ -n "$(git status --porcelain | grep -v '^??')" ]; then
echo "changes=true" >> $GITHUB_ENV # Use environment file to set output
git config --global user.name 'GitHub Actions Bot'
git config --global user.email '[email protected]'
git add -u
git commit -m "Apply code quality checks (auto-formatted)"
git fetch --prune
git pull --rebase origin ${{ github.head_ref }}
git push origin HEAD:${{ github.head_ref }}
else
echo "No changes to commit."
fi
env:
CI: true

- name: Post retry comment
if: env.changes == 'true'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
if (prNumber) {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const newBody = pr.body + '\n\nAuto-commit applied. A retry was triggered due to a failure in formatting/linting checks.';
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: newBody
});
} else {
console.log('No pull request context found, unable to update PR description.');
}
- name: Run all checks
run: ./gradlew check
32 changes: 18 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,33 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'MobileTeleSystems/spark-dialect-extension' # prevent running on forks

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
- name: Setup JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt
java-version: '11'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Cache SBT
uses: actions/cache@v3
name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_PASSPHRASE }}
fingerprint: ${{ secrets.GPG_PUBLIC_KEY_ID }}

- run: sbt ci-release
- run: ./gradlew publishToSonatype -Psigning.gnupg.keyName="${GPG_PUBLIC_KEY_ID_SHORT}" -Psigning.gnupg.passphrase="${GPG_PRIVATE_PASSPHRASE}"
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.GPG_PRIVATE_PASSPHRASE }}
GPG_PUBLIC_KEY_ID_SHORT: ${{ secrets.GPG_PUBLIC_KEY_ID_SHORT }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

Expand All @@ -41,4 +45,4 @@ jobs:
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
target/scala-2.12/*.jar
build/libs/*.jar
30 changes: 11 additions & 19 deletions .github/workflows/tests_clickhouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,28 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Setup JDK 8
- name: Setup JDK 11
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '11'
distribution: 'temurin'

- name: Setup Scala and SBT
uses: olafurpg/setup-scala@v14
with:
java-version: '8'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Compile .jar package with SBT
run: |
sbt package
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
cache-overwrite-existing: true

- name: Run Integration Tests with Coverage
run: |
sbt clean coverage test coverageReport
./gradlew test
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/scala-2.12/scoverage-report/scoverage.xml
files: build/reports/jacoco/test/*.xml
fail_ci_if_error: true
17 changes: 4 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
*.log
*~

# sbt specific
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
project/local-plugins.sbt
.history
.bsp
.metals
.bloop

# Scala-IDE specific
.scala_dependencies
.cache
Expand All @@ -35,3 +22,7 @@ classes/

# Visual Studio Code
.vscode

# Gradle-specific
.gradle/
build/
27 changes: 10 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ This document provides detailed steps to build the Spark Dialect Extension from

Before you start, ensure you have the following installed:
- **Java**: Java 8 or higher. [Java Installation Guide](https://adoptopenjdk.net/)
- **Scala**: [Scala Installation Guide](https://scala-lang.org/download/)
- **SBT**: [SBT Installation Guide](https://www.scala-sbt.org/download.html)
- **Gradle**: [Gradle Installation Guide](https://docs.gradle.org/current/userguide/installation.html)

### Compile the Project

To compile the project and generate a JAR file, run the following command in the project's root directory:

```bash
sbt package
./gradlew crossBuildV212Jar crossBuildV213Jar
```

This command compiles the source code and packages it into a .jar file located in the ``target/scala-2.12`` directory.
This command compiles the source code and packages it into a .jar files located in the ``build/libs`` directory.


## Running Scala Tests
Expand All @@ -33,20 +32,14 @@ docker-compose -f docker-compose.test.yml up -d
```

### Execute Tests
To run the Scala tests, execute:

```bash
sbt test
```

### With Coverage Report
To run the tests with coverage and generate a report, use:
To run the Scala tests, execute:

```bash
sbt clean coverage test coverageReport
./gradlew test
```

After the tests, you can view the coverage report by opening the ``target/scala-2.12/scoverage-report/index.html`` file in your web browser.
After the tests, you can view the coverage report by opening the ``build/reports/tests/test/index.html`` file in your web browser.

### Stopping Docker Containers
After completing the tests, you can stop the Docker containers with:
Expand All @@ -61,14 +54,14 @@ docker-compose -f docker-compose.test.yml down

To format all Scala source files in the project, execute the following command from the project's root directory:
```bash
sbt scalafmtAll
./gradlew scalafmtAll
```

## Using Scalafix for Linting and Refactoring

To lint and refactor the code, run Scalafix using the following command:
```bash
sbt scalafixAll
./gradlew scalafix
```
This command checks the code against various rules specified in the ```.scalafix.conf``` file and applies fixes where possible.

Expand All @@ -86,7 +79,7 @@ git pull -p
2. Copy version (it must start with **v**, e.g. **v1.0.0**)

```bash
VERSION=$(cat VERSION)
VERSION=$(./gradlew -q printVersion)
```

3. Commit and push changes to ``develop`` branch
Expand Down Expand Up @@ -118,7 +111,7 @@ git push origin "$VERSION"
```bash
git checkout develop
NEXT_VERSION=$(echo "$VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
echo "$NEXT_VERSION" > VERSION
sed -i "s/version = \".*\"/version = \"$NEXT_VERSION\"/" build.gradle
git add .
git commit -m "Bump version"
git push
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

Loading

0 comments on commit 347fb8d

Please sign in to comment.