Skip to content

Commit 6319d54

Browse files
build: configure commitlint, editorconfig and dry run release (#100)
1 parent 33007e5 commit 6319d54

11 files changed

+307
-9
lines changed

.commitlintrc.json

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"rules": {
3+
"body-leading-blank": [1, "always"],
4+
"body-max-line-length": [2, "always", 100],
5+
"footer-leading-blank": [1, "always"],
6+
"footer-max-line-length": [2, "always", 100],
7+
"header-max-length": [2, "always", 100],
8+
"subject-case": [
9+
2,
10+
"never",
11+
["sentence-case", "start-case", "pascal-case", "upper-case"]
12+
],
13+
"subject-empty": [2, "never"],
14+
"subject-full-stop": [2, "never", "."],
15+
"type-case": [2, "always", "lower-case"],
16+
"type-empty": [2, "never"],
17+
"type-enum": [
18+
2,
19+
"always",
20+
[
21+
"build",
22+
"chore",
23+
"ci",
24+
"docs",
25+
"feat",
26+
"fix",
27+
"perf",
28+
"refactor",
29+
"revert",
30+
"style",
31+
"test"
32+
]
33+
]
34+
},
35+
"prompt": {
36+
"questions": {
37+
"type": {
38+
"description": "Select the type of change that you're committing",
39+
"enum": {
40+
"feat": {
41+
"description": "A new feature",
42+
"title": "Features",
43+
"emoji": ""
44+
},
45+
"fix": {
46+
"description": "A bug fix",
47+
"title": "Bug Fixes",
48+
"emoji": "🐛"
49+
},
50+
"docs": {
51+
"description": "Documentation only changes",
52+
"title": "Documentation",
53+
"emoji": "📚"
54+
},
55+
"style": {
56+
"description": "Changes that do not affect the meaning of the code (whitespace, formatting, missing semi-colons, etc)",
57+
"title": "Styles",
58+
"emoji": "💎"
59+
},
60+
"refactor": {
61+
"description": "A code change that neither fixes a bug nor adds a feature",
62+
"title": "Code Refactoring",
63+
"emoji": "📦"
64+
},
65+
"perf": {
66+
"description": "A code change that improves performance",
67+
"title": "Performance Improvements",
68+
"emoji": "🚀"
69+
},
70+
"test": {
71+
"description": "Adding missing tests or fixing existing tests",
72+
"title": "Tests",
73+
"emoji": "🚨"
74+
},
75+
"build": {
76+
"description": "Changes that affect the build system or external dependencies (example scopes: poetry, nix)",
77+
"title": "Builds",
78+
"emoji": "🛠"
79+
},
80+
"ci": {
81+
"description": "Changes to our CI configuration files and scripts (example scopes: actions, gh-actions, github-actions)",
82+
"title": "Continuous Integrations",
83+
"emoji": "⚙️"
84+
},
85+
"chore": {
86+
"description": "Other changes that don't modify source or test files",
87+
"title": "Chores",
88+
"emoji": "♻️"
89+
},
90+
"revert": {
91+
"description": "Reverts a previous commit",
92+
"title": "Reverts",
93+
"emoji": "🗑"
94+
}
95+
}
96+
},
97+
"scope": {
98+
"description": "What is the scope of this change (e.g. component or file name)"
99+
},
100+
"subject": {
101+
"description": "Write a short, imperative tense description of the change"
102+
},
103+
"body": {
104+
"description": "Provide a longer description of the change"
105+
},
106+
"isBreaking": {
107+
"description": "Are there any breaking changes?"
108+
},
109+
"breakingBody": {
110+
"description": "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself"
111+
},
112+
"breaking": {
113+
"description": "Describe the breaking changes"
114+
},
115+
"isIssueAffected": {
116+
"description": "Does this change affect any open issues?"
117+
},
118+
"issuesBody": {
119+
"description": "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself"
120+
},
121+
"issues": {
122+
"description": "Add issue references (e.g. \"fix #123\", \"re #123\".)"
123+
}
124+
}
125+
}
126+
}

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
trim_trailing_whitespace = true
9+
10+
[*.{yaml,yml}]
11+
indent_size = 2
12+
13+
[{**/*.sql,**/OuterReferenceResolver.md,gradlew.bat}]
14+
charset = unset
15+
end_of_line = unset
16+
insert_final_newline = unset
17+
indent_style = unset
18+
trim_trailing_whitespace = unset

.github/workflows/pr.yml

+38-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
name: PR Build Check
22

33
on:
4-
pull_request:
4+
pull_request:
55
jobs:
6+
editorconfig-checker:
7+
name: Check editorconfig
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- uses: editorconfig-checker/action-editorconfig-checker@main
14+
- run: editorconfig-checker
15+
commitlint:
16+
name: Lint commits for semantic-release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: "16"
25+
- run: npx commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.sha }} --verbose
626
java:
727
name: Build and Test Java
828
runs-on: ubuntu-latest
929
steps:
10-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
1131
with:
1232
submodules: recursive
1333
- name: Set up JDK 17
14-
uses: actions/setup-java@v2
34+
uses: actions/setup-java@v3
1535
with:
1636
java-version: '17'
1737
distribution: 'adopt'
@@ -21,14 +41,15 @@ jobs:
2141
run: gradle build
2242
isthmus-native-image-mac-linux:
2343
name: Build Isthmus Native Image
44+
needs: java
2445
runs-on: ${{ matrix.os }}
2546
strategy:
2647
matrix:
2748
os: [ubuntu-latest, macOS-latest]
2849
steps:
2950
- uses: actions/checkout@v2
3051
with:
31-
submodules: recursive
52+
submodules: recursive
3253
- uses: DeLaGuardo/[email protected]
3354
with:
3455
graalvm: '22.0.0.2'
@@ -43,7 +64,7 @@ jobs:
4364
run: gradle nativeImage
4465
- name: Smoke Test
4566
run: ./isthmus/src/test/script/smoke.sh
46-
./isthmus/src/test/script/tpch_smoke.sh
67+
./isthmus/src/test/script/tpch_smoke.sh
4768
- name: Rename the artifact to OS-unique name
4869
shell: bash
4970
run: |
@@ -53,3 +74,15 @@ jobs:
5374
with:
5475
name: isthmus-${{ matrix.os }}
5576
path: isthmus/build/graal/isthmus-${{ matrix.os }}
77+
dry-run-release:
78+
name: Dry-run release
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v3
82+
with:
83+
fetch-depth: 0
84+
- uses: actions/setup-node@v3
85+
with:
86+
node-version: "16"
87+
- name: Check current status before next release
88+
run: ./ci/release/dry_run.sh

.pre-commit-config.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: https://github.com/adrienverge/yamllint.git
3+
rev: v1.26.0
4+
hooks:
5+
- id: yamllint
6+
args: [-c=.yamllint.yaml]
7+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
8+
rev: v8.0.0
9+
hooks:
10+
- id: commitlint
11+
stages: [commit-msg]

.releaserc.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"branches": ["main"],
3+
"preset": "conventionalcommits",
4+
"plugins": [
5+
[
6+
"@semantic-release/commit-analyzer",
7+
{
8+
"releaseRules": [
9+
{"breaking": true, "release": "minor"}
10+
]
11+
}
12+
],
13+
"@semantic-release/release-notes-generator",
14+
[
15+
"@semantic-release/changelog",
16+
{
17+
"changelogTitle": "Release Notes\n---",
18+
"changelogFile": "CHANGELOG.md"
19+
}
20+
],
21+
[
22+
"@semantic-release/exec",
23+
{
24+
}
25+
],
26+
[
27+
"@semantic-release/github",
28+
{
29+
"successComment": false
30+
}
31+
],
32+
[
33+
"@semantic-release/git",
34+
{
35+
"assets": ["CHANGELOG.md"],
36+
"message": "chore(release): ${nextRelease.version}"
37+
}
38+
]
39+
]
40+
}

.yamllint.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rules:
2+
line-length:
3+
max: 120
4+
brackets:
5+
forbid: false
6+
min-spaces-inside: 0
7+
max-spaces-inside: 1
8+
min-spaces-inside-empty: 0
9+
max-spaces-inside-empty: 0

CONTRIBUTING.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# Contributing to Substrait Java
2+
3+
This page provides some orientation and recommendations on how to get the best results when engaging with the community.
4+
5+
1. [Commit conventions](#commit-conventions)
6+
2. [Style Guide](#style-guide)
7+
8+
## Commit Conventions
9+
10+
Substrait Java follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit message structure. You can use [`pre-commit`](https://pre-commit.com/) to check your messages for you, but note that you must install pre-commit using `pre-commit install --hook-type commit-msg` for this to work. CI will also lint your commit messages. Please also ensure that your PR title and initial comment together form a valid commit message; that will save us some work formatting the merge commit message when we merge your PR.
11+
12+
```bash
13+
$ pre-commit install --hook-type commit-msg
14+
pre-commit installed at .git/hooks/commit-msg
15+
```
16+
17+
Examples of commit messages can be seen [here](https://www.conventionalcommits.org/en/v1.0.0/#examples).
18+
119
## Style guide
220

321
Changes must adhere to the style guide and this will be verified by the continuous integration build.
@@ -29,4 +47,4 @@ org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAME
2947
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
3048
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
3149
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
32-
```
50+
```

bom/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ dependencies {
5454
// dependency on it during compilation
5555

5656
}
57-
}
57+
}

ci/release/dry_run.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# shellcheck shell=bash
3+
4+
set -euo pipefail
5+
6+
curdir="$PWD"
7+
worktree="$(mktemp -d)"
8+
branch="$(basename "$worktree")"
9+
10+
git worktree add "$worktree"
11+
12+
function cleanup() {
13+
cd "$curdir" || exit 1
14+
git worktree remove "$worktree"
15+
git worktree prune
16+
git branch -D "$branch"
17+
}
18+
19+
trap cleanup EXIT ERR
20+
21+
cd "$worktree" || exit 1
22+
23+
export GITHUB_REF="$branch"
24+
25+
npx --yes \
26+
-p semantic-release \
27+
-p "@semantic-release/commit-analyzer" \
28+
-p "@semantic-release/release-notes-generator" \
29+
-p "@semantic-release/changelog" \
30+
-p "@semantic-release/exec" \
31+
-p "@semantic-release/git" \
32+
-p "conventional-changelog-conventionalcommits" \
33+
semantic-release \
34+
--ci false \
35+
--dry-run \
36+
--preset conventionalcommits \
37+
--plugins \
38+
--analyze-commits "@semantic-release/commit-analyzer" \
39+
--generate-notes "@semantic-release/release-notes-generator" \
40+
--verify-conditions "@semantic-release/changelog,@semantic-release/exec,@semantic-release/git" \
41+
--prepare "@semantic-release/changelog,@semantic-release/exec" \
42+
--branches "$branch" \
43+
--repository-url "file://$PWD"

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ calcite.version=1.28.0
1717
junit5.version=5.8.1
1818
protobuf.version=3.17.1
1919
slf4j.version=1.7.25
20-
jackson.version=2.12.4
20+
jackson.version=2.12.4

isthmus/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ Converts a SQL query to a Substrait Plan
154154
}],
155155
"expectedTypeUrls": []
156156
}
157-
```
157+
```

0 commit comments

Comments
 (0)