Skip to content

Commit 705d0f3

Browse files
Update things (#69)
* Update things Made by Open AI Codex with GPT-5.5 * Use official mill script * Manage Mill version from build.mill * Tweak workflow
1 parent 922375b commit 705d0f3

13 files changed

Lines changed: 842 additions & 337 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: coursier/cache-action@v3
17+
with:
18+
disableFallback: true
19+
20+
- run: ./mill __.compile

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
target/
2+
out/
3+
.container/

.travis.yml

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

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@
22

33
Minimal JVM HTTP server, à la [`http.server`](https://docs.python.org/3/library/http.server.html), mainly only for coursier's own tests' purposes
44

5-
[![Build Status](https://travis-ci.org/coursier/http-server.svg?branch=master)](https://travis-ci.org/coursier/http-server)
6-
[![Maven Central](https://img.shields.io/maven-central/v/io.get-coursier/http-server_2.12.svg)](https://maven-badges.herokuapp.com/maven-central/io.get-coursier/http-server_2.12)
5+
[![CI](https://github.com/coursier/http-server/actions/workflows/ci.yml/badge.svg)](https://github.com/coursier/http-server/actions/workflows/ci.yml)
6+
[![Maven Central](https://img.shields.io/maven-central/v/io.get-coursier/http-server_3.svg)](https://central.sonatype.com/artifact/io.get-coursier/http-server_3)
77

88
Relies on [http4s](https://github.com/http4s/http4s)
99

1010
Use like
1111
```
12-
$ coursier launch io.get-coursier:http-server_2.12:1.0.0
12+
$ coursier launch io.get-coursier:http-server_3:1.0.2
1313
```
1414
(spawns a web server serving files in the current directory).
1515

1616
See the available options with
1717
```
18-
$ coursier launch io.get-coursier:http-server_2.12:1.0.0 -- --help
18+
$ coursier launch io.get-coursier:http-server_3:1.0.2 -- --help
19+
```
20+
21+
Build with
22+
```
23+
$ ./mill compile
24+
```
25+
26+
Run from sources with
27+
```
28+
$ ./mill run --help
1929
```

build.mill

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//| mill-version: 1.1.6
2+
3+
package build
4+
5+
import mill.*
6+
import mill.api.*
7+
import mill.scalalib.*
8+
import mill.scalalib.publish.*
9+
10+
object `package` extends SbtModule, PublishModule {
11+
def scalaVersion = "3.8.3"
12+
def publishVersion = "1.0.2-SNAPSHOT"
13+
def artifactName = "http-server"
14+
def mainClass = Some("coursier.HttpServerApp")
15+
16+
def scalacOptions = Seq("-feature", "-deprecation")
17+
18+
def mvnDeps = Seq(
19+
mvn"org.http4s::http4s-ember-server:0.23.34",
20+
mvn"org.http4s::http4s-dsl:0.23.34",
21+
mvn"org.slf4j:slf4j-nop:2.0.18"
22+
)
23+
24+
def pomSettings = PomSettings(
25+
description = "Minimal JVM HTTP server",
26+
organization = "io.get-coursier",
27+
url = "https://github.com/coursier/http-server",
28+
licenses = Seq(License.`Apache-2.0`),
29+
versionControl = VersionControl.github("coursier", "http-server"),
30+
developers = Seq(
31+
Developer(
32+
id = "alexarchambault",
33+
name = "Alexandre Archambault",
34+
url = "https://github.com/alexarchambault"
35+
)
36+
)
37+
)
38+
}

build.sbt

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

mill

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then DEFAULT_MILL_VERSION="1.1.6-20-5bb57d"; fi
6+
7+
if [ -z "${GITHUB_RELEASE_CDN}" ] ; then GITHUB_RELEASE_CDN=""; fi
8+
9+
if [ -z "$MILL_MAIN_CLI" ] ; then MILL_MAIN_CLI="${0}"; fi
10+
11+
MILL_REPO_URL="https://github.com/com-lihaoyi/mill"
12+
13+
MILL_BUILD_SCRIPT=""
14+
15+
if [ -f "build.mill" ] ; then
16+
MILL_BUILD_SCRIPT="build.mill"
17+
elif [ -f "build.mill.scala" ] ; then
18+
MILL_BUILD_SCRIPT="build.mill.scala"
19+
elif [ -f "build.sc" ] ; then
20+
MILL_BUILD_SCRIPT="build.sc"
21+
fi
22+
23+
# `s/.*://`:
24+
# This is a greedy match that removes everything from the beginning of the line up to (and including) the last
25+
# colon (:). This effectively isolates the value part of the declaration.
26+
#
27+
# `s/#.*//`:
28+
# This removes any comments at the end of the line.
29+
#
30+
# `s/['\"]//g`:
31+
# This removes all single and double quotes from the string, wherever they appear (g is for "global").
32+
#
33+
# `s/^[[:space:]]*//; s/[[:space:]]*$//`:
34+
# These two expressions trim any leading or trailing whitespace ([[:space:]] matches spaces and tabs).
35+
TRIM_VALUE_SED="s/.*://; s/#.*//; s/['\"]//g; s/^[[:space:]]*//; s/[[:space:]]*$//"
36+
37+
if [ -z "${MILL_VERSION}" ] ; then
38+
if [ -f ".mill-version" ] ; then
39+
MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)"
40+
elif [ -f ".config/mill-version" ] ; then
41+
MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)"
42+
elif [ -f "build.mill.yaml" ] ; then
43+
MILL_VERSION="$(grep -E "mill-version:" "build.mill.yaml" | sed -E "$TRIM_VALUE_SED")"
44+
elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then
45+
MILL_VERSION="$(grep -E "//\|.*mill-version" "${MILL_BUILD_SCRIPT}" | sed -E "$TRIM_VALUE_SED")"
46+
fi
47+
fi
48+
49+
if [ -z "${MILL_VERSION}" ] ; then MILL_VERSION="${DEFAULT_MILL_VERSION}"; fi
50+
51+
MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill"
52+
53+
if [ -z "${MILL_FINAL_DOWNLOAD_FOLDER}" ] ; then MILL_FINAL_DOWNLOAD_FOLDER="${MILL_USER_CACHE_DIR}/download"; fi
54+
55+
MILL_NATIVE_SUFFIX="-native"
56+
MILL_JVM_SUFFIX="-jvm"
57+
ARTIFACT_SUFFIX=""
58+
59+
# Check if GLIBC version is at least the required version
60+
# Returns 0 (true) if GLIBC >= required version, 1 (false) otherwise
61+
check_glibc_version() {
62+
required_version="2.39"
63+
required_major=$(echo "$required_version" | cut -d. -f1)
64+
required_minor=$(echo "$required_version" | cut -d. -f2)
65+
# Get GLIBC version from ldd --version (first line contains version like "ldd (GNU libc) 2.31")
66+
glibc_version=$(ldd --version 2>/dev/null | head -n 1 | grep -oE '[0-9]+\.[0-9]+$' || echo "")
67+
if [ -z "$glibc_version" ]; then
68+
# If we can't determine GLIBC version, assume it's too old
69+
return 1
70+
fi
71+
glibc_major=$(echo "$glibc_version" | cut -d. -f1)
72+
glibc_minor=$(echo "$glibc_version" | cut -d. -f2)
73+
if [ "$glibc_major" -gt "$required_major" ]; then
74+
return 0
75+
elif [ "$glibc_major" -eq "$required_major" ] && [ "$glibc_minor" -ge "$required_minor" ]; then
76+
return 0
77+
else
78+
return 1
79+
fi
80+
}
81+
82+
set_artifact_suffix() {
83+
if [ "$(uname -s 2>/dev/null | cut -c 1-5)" = "Linux" ]; then
84+
# Native binaries require new enough GLIBC; fall back to JVM launcher if older
85+
if ! check_glibc_version; then
86+
return
87+
fi
88+
if [ "$(uname -m)" = "aarch64" ]; then ARTIFACT_SUFFIX="-native-linux-aarch64"
89+
else ARTIFACT_SUFFIX="-native-linux-amd64"; fi
90+
elif [ "$(uname)" = "Darwin" ]; then
91+
if [ "$(uname -m)" = "arm64" ]; then ARTIFACT_SUFFIX="-native-mac-aarch64"
92+
else ARTIFACT_SUFFIX="-native-mac-amd64"; fi
93+
else
94+
echo "This native mill launcher supports only Linux and macOS." 1>&2
95+
exit 1
96+
fi
97+
}
98+
99+
case "$MILL_VERSION" in
100+
*"$MILL_NATIVE_SUFFIX")
101+
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"}
102+
set_artifact_suffix
103+
;;
104+
105+
*"$MILL_JVM_SUFFIX")
106+
MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"}
107+
;;
108+
109+
*)
110+
case "$MILL_VERSION" in
111+
0.1.* | 0.2.* | 0.3.* | 0.4.* | 0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.* | 0.12.*)
112+
;;
113+
*)
114+
set_artifact_suffix
115+
;;
116+
esac
117+
;;
118+
esac
119+
120+
MILL="${MILL_FINAL_DOWNLOAD_FOLDER}/$MILL_VERSION$ARTIFACT_SUFFIX"
121+
122+
# If not already downloaded, download it
123+
if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
124+
case $MILL_VERSION in
125+
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.*)
126+
MILL_DOWNLOAD_SUFFIX=""
127+
MILL_DOWNLOAD_FROM_MAVEN=0
128+
;;
129+
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M*)
130+
MILL_DOWNLOAD_SUFFIX="-assembly"
131+
MILL_DOWNLOAD_FROM_MAVEN=0
132+
;;
133+
*)
134+
MILL_DOWNLOAD_SUFFIX="-assembly"
135+
MILL_DOWNLOAD_FROM_MAVEN=1
136+
;;
137+
esac
138+
case $MILL_VERSION in
139+
0.12.0 | 0.12.1 | 0.12.2 | 0.12.3 | 0.12.4 | 0.12.5 | 0.12.6 | 0.12.7 | 0.12.8 | 0.12.9 | 0.12.10 | 0.12.11)
140+
MILL_DOWNLOAD_EXT="jar"
141+
;;
142+
0.12.*)
143+
MILL_DOWNLOAD_EXT="exe"
144+
;;
145+
0.*)
146+
MILL_DOWNLOAD_EXT="jar"
147+
;;
148+
*)
149+
MILL_DOWNLOAD_EXT="exe"
150+
;;
151+
esac
152+
153+
MILL_TEMP_DOWNLOAD_FILE="${MILL_OUTPUT_DIR:-out}/mill-temp-download"
154+
mkdir -p "$(dirname "${MILL_TEMP_DOWNLOAD_FILE}")"
155+
156+
if [ "$MILL_DOWNLOAD_FROM_MAVEN" = "1" ] ; then
157+
MILL_DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${MILL_DOWNLOAD_EXT}"
158+
else
159+
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
160+
MILL_DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${MILL_DOWNLOAD_SUFFIX}"
161+
unset MILL_VERSION_TAG
162+
fi
163+
164+
165+
if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
166+
echo "$MILL_DOWNLOAD_URL"
167+
echo "$MILL"
168+
exit 0
169+
fi
170+
171+
echo "Downloading mill ${MILL_VERSION} from ${MILL_DOWNLOAD_URL} ..." 1>&2
172+
curl -f -L -o "${MILL_TEMP_DOWNLOAD_FILE}" "${MILL_DOWNLOAD_URL}"
173+
174+
chmod +x "${MILL_TEMP_DOWNLOAD_FILE}"
175+
176+
mkdir -p "${MILL_FINAL_DOWNLOAD_FOLDER}"
177+
mv "${MILL_TEMP_DOWNLOAD_FILE}" "${MILL}"
178+
179+
unset MILL_TEMP_DOWNLOAD_FILE
180+
unset MILL_DOWNLOAD_SUFFIX
181+
fi
182+
183+
MILL_FIRST_ARG=""
184+
if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--no-daemon" ] || [ "$1" = "--help" ] ; then
185+
# Need to preserve the first position of those listed options
186+
MILL_FIRST_ARG=$1
187+
shift
188+
fi
189+
190+
unset MILL_FINAL_DOWNLOAD_FOLDER
191+
unset MILL_OLD_DOWNLOAD_PATH
192+
unset OLD_MILL
193+
unset MILL_VERSION
194+
unset MILL_REPO_URL
195+
196+
# -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2
197+
# We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes
198+
# shellcheck disable=SC2086
199+
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"

0 commit comments

Comments
 (0)