Skip to content

Commit f4f1409

Browse files
committed
. e move to Mise
1 parent 40e6593 commit f4f1409

File tree

9 files changed

+92
-105
lines changed

9 files changed

+92
-105
lines changed

.github/workflows/test-ea.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/test-jdk-8.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,17 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v5
14-
- uses: actions/[email protected]
15-
with:
16-
path: ~/.m2/repository
17-
key: ubuntu-maven-${{ hashFiles('**/pom.xml') }}
18-
restore-keys: |
19-
ubuntu-maven-
20-
- name: Set up JDK21
21-
uses: actions/setup-java@v5
22-
with:
23-
distribution: 'zulu'
24-
java-version: 21
14+
- uses: jdx/mise-action@v2
15+
- name: Set Java version for building (JDK 21)
16+
run: echo "21" > .java-version
17+
shell: bash
2518
- name: Turn off formatting
26-
run: |
27-
./set_formatting_off.sh
28-
- name: Build with Maven
29-
run: |
30-
mvn -B install --file pom.xml
31-
- name: Set up JDK8
19+
run: ./set_formatting_off.sh
20+
shell: bash
21+
- name: Build with Mise
22+
run: ./build_and_test.sh
23+
shell: bash
24+
- name: Set up JDK8 for runtime testing
3225
uses: actions/setup-java@v5
3326
with:
3427
distribution: 'zulu'

.github/workflows/test.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@ jobs:
3030

3131
steps:
3232
- uses: actions/checkout@v5
33-
- uses: actions/[email protected]
34-
with:
35-
path: ~/.m2/repository
36-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
37-
restore-keys: |
38-
${{ runner.os }}-maven-
39-
- name: Set up JDK
40-
uses: actions/setup-java@v5
41-
with:
42-
distribution: 'zulu'
43-
java-version: ${{ matrix.java }}
44-
- name: Build with Maven
33+
- uses: jdx/mise-action@v2
34+
- name: Set Java version for matrix testing
35+
run: echo "${{ matrix.java }}" > .java-version
36+
shell: bash
37+
- name: Build and Test
4538
run: |
4639
./set_formatting_off.sh
4740
./build_and_test.sh

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17

.mise.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tools]
2+
maven = "latest"
3+
dotnet = "latest"
4+
5+
[tasks]
6+
build_and_test = "mvn --quiet -B verify --file pom.xml"
7+
format = "mvn --quiet formatter:format"
8+
9+
[settings]
10+
# we put the java version in the .java-version file instead of here so that it's easy to override in the CI matrix
11+
idiomatic_version_file_enable_tools = ["java"]

build_and_test.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
@echo off
2-
3-
call mvn -B verify --file pom.xml
2+
"C:\Program Files\Git\bin\bash.exe" build_and_test.sh

build_and_test.sh

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
TMP_OUTPUT=$(mktemp)
5-
if mvn -B verify --file pom.xml > "$TMP_OUTPUT" 2>&1; then
6-
# Extract the number of tests run from Maven output
7-
TESTS_TOTAL=$(awk '
8-
/Results:/ {
9-
for(i=0;i<3;i++) {
10-
if(getline>0) {
11-
if($0 ~ /Tests run: [0-9]+/) {
12-
line = $0
13-
sub(/.*Tests run: /, "", line)
14-
sub(/[^0-9].*$/, "", line)
15-
sum += line
16-
break
17-
}
18-
}
19-
}
20-
}
21-
END {print sum}' "$TMP_OUTPUT")
22-
23-
# Count unique Maven warnings
24-
WARNING_COUNT=$(grep -E "^\[WARNING\]" "$TMP_OUTPUT" | sort -u | wc -l | tr -d ' ')
25-
26-
echo "✅ Built: $TESTS_TOTAL tests passed, $WARNING_COUNT unique Maven warnings."
27-
EXIT_CODE=0
28-
else
29-
cat "$TMP_OUTPUT"
30-
echo "❌ Build failed."
31-
EXIT_CODE=1
4+
# Check if Mise is available
5+
if ! command -v mise &> /dev/null; then
6+
echo "❌ Mise is required but not installed. Please install Mise: https://mise.jdx.dev/"
7+
exit 1
328
fi
33-
rm "$TMP_OUTPUT"
34-
exit $EXIT_CODE
9+
10+
mise task run build_and_test

format_code.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
mise task run format
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Repo Setup
2+
3+
## Concept
4+
5+
These are the basic dev scripts that every repo should have. They provide a standardized interface for common development tasks that works across different platforms and environments.
6+
7+
The underlying tool is Mise-en-Place, aka "Mise" (https://mise.jdx.dev/), which manages tools and tasks within the project scope without requiring system-wide installations.
8+
9+
The idea is that you can clone a repo on a clean machine, then run one of these scripts, and it will just work (assuming Mise is already installed).
10+
11+
## Prerequisites
12+
13+
1. **Mise** - The only system requirement. All other tools are managed by Mise per-project.
14+
15+
Mise automatically:
16+
- Installs required tools (defined in `.mise.toml`)
17+
- Creates and manages virtual environments
18+
- Handles dependencies
19+
- Runs tasks with proper environment setup
20+
21+
## Implemented Scripts
22+
23+
### Core Scripts
24+
25+
1. **`build_and_test.sh/.cmd`** - Runs the full build pipeline including tests, type checking, linting, and integration tests
26+
2. **`format_code.sh`** - Formats code using configured formatters
27+
3. **`run_mdsnippets.sh/.cmd`** - Updates markdown documentation with code snippets
28+
29+
### Script Implementation Details
30+
31+
Prefer to name scripts and tasks using `snake_case`.
32+
33+
**Bash Scripts (.sh):**
34+
- Include error handling (`set -euo pipefail`)
35+
- Check for Mise availability with helpful error messages
36+
- Use `mise task run` to execute configured tasks
37+
- Support parallel task execution where appropriate
38+
39+
**Windows Scripts (.cmd):**
40+
- Use Git Bash to execute the corresponding `.sh` file
41+
- Provide cross-platform compatibility without duplicating logic
42+
43+
### Configuration
44+
45+
Tasks are defined in `.mise.toml`.
46+
47+
**Tool Version Management:**
48+
- Use idiomatic version files (e.g., `.java-version`, `.python-version`) for language runtimes to enable easy overrides in CI matrix testing
49+
- Configure `idiomatic_version_file_enable_tools` in `.mise.toml` to automatically detect these version files
50+
- This allows testing against multiple language versions without modifying the main configuration
51+
52+
**CI Integration:**
53+
- CI workflows can override tool versions by writing to the version files before running tasks (e.g., `echo "11" > .java-version`)
54+
- Use matrix builds to test multiple versions: each matrix job writes its target version to the appropriate file

0 commit comments

Comments
 (0)