fix: configure Cross release dependencies
Rust CI tiny-wb passed CI.
Gitea/tiny-wb/pipeline/head This commit looks good
Details
Rust CI tiny-wb passed CI.
Gitea/tiny-wb/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2def6e61e0
commit
6fe4286e38
|
|
@ -71,12 +71,16 @@ For Cross installation and image setup, follow the
|
||||||
`CROSS_CONTAINER_ENGINE=podman` or `docker` when necessary. Check `cross --version`,
|
`CROSS_CONTAINER_ENGINE=podman` or `docker` when necessary. Check `cross --version`,
|
||||||
`cargo binstall -V`, and the selected engine's `info` command before building.
|
`cargo binstall -V`, and the selected engine's `info` command before building.
|
||||||
|
|
||||||
The target images must provide the Linux target's libudev development files and
|
The Linux target needs libudev development files and pkg-config configuration;
|
||||||
pkg-config configuration, the linker required by `.cargo/config.toml` (`lld`),
|
the Windows target needs the GNU resource compiler used by `build.rs`
|
||||||
and the Windows GNU resource compiler required by `build.rs` (`windres`). Native
|
(`windres`). Native host compilation alone does not verify those container
|
||||||
host compilation alone does not verify those container prerequisites. Configure
|
prerequisites. [`release/Cross.toml`](../release/Cross.toml) installs
|
||||||
suitable prebuilt Cross images before building; the publisher rejects repository
|
`libudev-dev` and `pkg-config` in the Linux image. `release.sh` exports its
|
||||||
`pre-build`, `dockerfile`, and `runner` hooks, so do not silently add install hooks.
|
absolute path as `CROSS_CONFIG` for the publisher process. The file is kept away
|
||||||
|
from the repository root because the publisher rejects root `pre-build`,
|
||||||
|
`dockerfile`, and `runner` hooks. Package installation requires access to the
|
||||||
|
image's Debian/Ubuntu repositories. A caller-supplied `CROSS_CONFIG` is
|
||||||
|
intentionally replaced so releases use the reviewed, tracked configuration.
|
||||||
|
|
||||||
## Token handling and commands
|
## Token handling and commands
|
||||||
|
|
||||||
|
|
@ -88,20 +92,26 @@ newline), rejects an empty first line, and exports it as `GITEA_TOKEN` only to
|
||||||
the publisher. It never passes the token in arguments or prints it. The publisher
|
the publisher. It never passes the token in arguments or prints it. The publisher
|
||||||
is responsible for keeping it out of child builds and for download verification.
|
is responsible for keeping it out of child builds and for download verification.
|
||||||
|
|
||||||
In these examples, set `TOKEN_FILE` in your shell to the existing token file's
|
Compile-only builds do not access Gitea and need no token:
|
||||||
path; it is not a checked-in setting:
|
|
||||||
|
```console
|
||||||
|
./release.sh --compile-only
|
||||||
|
```
|
||||||
|
|
||||||
|
`--compile-only` builds local artifacts in ignored `dist/release-*/`, without
|
||||||
|
contacting Gitea. Inspect `SHA256SUMS`, archive members, executables and the
|
||||||
|
binstall layout before publication.
|
||||||
|
|
||||||
|
For authenticated dry runs and publication, set `TOKEN_FILE` in your shell to
|
||||||
|
the existing token file's path; it is not a checked-in setting:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
./release.sh "$TOKEN_FILE" --dry-run
|
./release.sh "$TOKEN_FILE" --dry-run
|
||||||
./release.sh "$TOKEN_FILE" --compile-only
|
|
||||||
```
|
```
|
||||||
|
|
||||||
A dry run must report the correct package, version, unprefixed tag, both targets,
|
A dry run must report the correct package, version, unprefixed tag, both targets,
|
||||||
asset names and public HTTPS destination without changing files, refs or releases.
|
asset names and public HTTPS destination without changing files, refs or releases.
|
||||||
A successful dry run is required but does not replace collision inspection.
|
A successful dry run is required but does not replace collision inspection.
|
||||||
`--compile-only` builds local artifacts in ignored `dist/release-*/`, without
|
|
||||||
contacting Gitea. Inspect `SHA256SUMS`, archive members, executables and the
|
|
||||||
binstall layout before publication.
|
|
||||||
|
|
||||||
After all readiness checks and separate publication authorization:
|
After all readiness checks and separate publication authorization:
|
||||||
|
|
||||||
|
|
|
||||||
43
release.sh
43
release.sh
|
|
@ -7,16 +7,22 @@ unset GITEA_TOKEN
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $0 <gitea-token-file> [rust_realease options...]" >&2
|
echo "usage: $0 <gitea-token-file> [rust_realease options...]" >&2
|
||||||
|
echo " $0 --compile-only [rust_realease options...]" >&2
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$#" -ge 1 ] || usage
|
[ "$#" -ge 1 ] || usage
|
||||||
token_file=$1
|
token_file=
|
||||||
shift
|
if [ "$1" = "--compile-only" ]; then
|
||||||
|
shift
|
||||||
if [ ! -f "$token_file" ] || [ ! -r "$token_file" ] || [ ! -s "$token_file" ]; then
|
set -- --compile-only "$@"
|
||||||
echo "token file must be readable, regular and nonempty" >&2
|
else
|
||||||
exit 2
|
token_file=$1
|
||||||
|
shift
|
||||||
|
if [ ! -f "$token_file" ] || [ ! -r "$token_file" ] || [ ! -s "$token_file" ]; then
|
||||||
|
echo "token file must be readable, regular and nonempty" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if ! command -v rust_realease >/dev/null 2>&1; then
|
if ! command -v rust_realease >/dev/null 2>&1; then
|
||||||
echo "rust_realease is not installed or not available in PATH; see docs/releases.md" >&2
|
echo "rust_realease is not installed or not available in PATH; see docs/releases.md" >&2
|
||||||
|
|
@ -49,12 +55,25 @@ case "${manifest_version%%+*}" in
|
||||||
*-*) set -- "$@" --prerelease ;;
|
*-*) set -- "$@" --prerelease ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Read after subprocess-based discovery, and export only for the publisher.
|
# Read after subprocess-based discovery, and export only when publishing or
|
||||||
GITEA_TOKEN=
|
# performing an authenticated dry run. Compile-only mode needs no token.
|
||||||
IFS= read -r GITEA_TOKEN <"$token_file" || :
|
if [ -n "$token_file" ]; then
|
||||||
if [ -z "$GITEA_TOKEN" ]; then
|
GITEA_TOKEN=
|
||||||
echo "the token file's first line must not be empty" >&2
|
IFS= read -r GITEA_TOKEN <"$token_file" || :
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "the token file's first line must not be empty" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
export GITEA_TOKEN
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cross builds in an isolated Debian/Ubuntu image, so native libraries from the
|
||||||
|
# maintainer's host are unavailable. Keep this explicitly selected file away
|
||||||
|
# from the root Cross.toml path validated by rust_realease.
|
||||||
|
CROSS_CONFIG=$repository_dir/release/Cross.toml
|
||||||
|
if [ ! -f "$CROSS_CONFIG" ] || [ ! -r "$CROSS_CONFIG" ]; then
|
||||||
|
echo "release Cross configuration is missing or unreadable: $CROSS_CONFIG" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
export GITEA_TOKEN
|
export CROSS_CONFIG
|
||||||
exec rust_realease "$@"
|
exec rust_realease "$@"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Native dependencies required by the GNU/Linux release target. This file is
|
||||||
|
# selected explicitly by release.sh because rust_realease reserves a root
|
||||||
|
# Cross.toml for its validated repository configuration.
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
pre-build = [
|
||||||
|
"apt-get update && apt-get install --assume-yes --no-install-recommends libudev-dev pkg-config",
|
||||||
|
]
|
||||||
|
|
@ -5,7 +5,8 @@ tag-prefix = ""
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
# Desktop targets. Linux uses glibc because serialport links system libudev.
|
# Desktop targets. Linux uses glibc because serialport links system libudev.
|
||||||
# Cross images must provide target libudev/pkg-config, lld and Windows windres.
|
# release/Cross.toml injects target libudev/pkg-config; the base images provide
|
||||||
|
# the remaining target toolchains, including the Windows windres executable.
|
||||||
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]
|
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]
|
||||||
profile = "release"
|
profile = "release"
|
||||||
locked = true
|
locked = true
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ class ReleaseWrapperTests(unittest.TestCase):
|
||||||
self.project.mkdir()
|
self.project.mkdir()
|
||||||
for name in ('release.sh', 'Cargo.toml', 'rust-release.toml'):
|
for name in ('release.sh', 'Cargo.toml', 'rust-release.toml'):
|
||||||
shutil.copy2(REPO / name, self.project / name)
|
shutil.copy2(REPO / name, self.project / name)
|
||||||
|
(self.project / 'release').mkdir()
|
||||||
|
shutil.copy2(REPO / 'release' / 'Cross.toml', self.project / 'release' / 'Cross.toml')
|
||||||
self.tools = self.root / 'tools'
|
self.tools = self.root / 'tools'
|
||||||
self.tools.mkdir()
|
self.tools.mkdir()
|
||||||
# An isolated PATH tests missing publishers without relying on the host.
|
# An isolated PATH tests missing publishers without relying on the host.
|
||||||
|
|
@ -31,8 +33,11 @@ class ReleaseWrapperTests(unittest.TestCase):
|
||||||
self.fake = self.tools / 'rust_realease'
|
self.fake = self.tools / 'rust_realease'
|
||||||
self.fake.write_text('#!' + sys.executable + '\n' + '''import json, os, pathlib, sys
|
self.fake.write_text('#!' + sys.executable + '\n' + '''import json, os, pathlib, sys
|
||||||
repository = pathlib.Path(sys.argv[1])
|
repository = pathlib.Path(sys.argv[1])
|
||||||
|
cross_config = pathlib.Path(os.environ["CROSS_CONFIG"])
|
||||||
record = {"args": sys.argv[1:], "token": os.environ.get("GITEA_TOKEN"),
|
record = {"args": sys.argv[1:], "token": os.environ.get("GITEA_TOKEN"),
|
||||||
"fallback": (repository / "rust-release.toml").read_text()}
|
"fallback": (repository / "rust-release.toml").read_text(),
|
||||||
|
"cross_config": str(cross_config),
|
||||||
|
"cross_config_contents": cross_config.read_text()}
|
||||||
pathlib.Path(os.environ["CAPTURE"]).write_text(json.dumps(record))
|
pathlib.Path(os.environ["CAPTURE"]).write_text(json.dumps(record))
|
||||||
sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
||||||
''')
|
''')
|
||||||
|
|
@ -74,6 +79,13 @@ sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
||||||
'--artifact-format', 'both', *extra, *prerelease])
|
'--artifact-format', 'both', *extra, *prerelease])
|
||||||
self.assertEqual(record['token'], 'inert-test-token-123')
|
self.assertEqual(record['token'], 'inert-test-token-123')
|
||||||
self.assertNotIn(record['token'], '\n'.join(record['args']))
|
self.assertNotIn(record['token'], '\n'.join(record['args']))
|
||||||
|
self.assertEqual(tomllib.loads(record['cross_config_contents']), {
|
||||||
|
'target': {'x86_64-unknown-linux-gnu': {
|
||||||
|
'pre-build': [
|
||||||
|
'apt-get update && apt-get install --assume-yes '
|
||||||
|
'--no-install-recommends libudev-dev pkg-config']}}})
|
||||||
|
self.assertEqual(Path(record['cross_config']), self.project / 'release' / 'Cross.toml')
|
||||||
|
self.assertTrue(Path(record['cross_config']).is_file())
|
||||||
config = tomllib.loads(record['fallback'])
|
config = tomllib.loads(record['fallback'])
|
||||||
self.assertEqual(config['repository']['fallbacks'], [{
|
self.assertEqual(config['repository']['fallbacks'], [{
|
||||||
'origin': before.decode().strip(),
|
'origin': before.decode().strip(),
|
||||||
|
|
@ -93,7 +105,24 @@ sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
||||||
self.env['PUBLISHER_EXIT'] = '37'
|
self.env['PUBLISHER_EXIT'] = '37'
|
||||||
self.token.write_text('inert-test-token-123')
|
self.token.write_text('inert-test-token-123')
|
||||||
self.run_wrapper([str(self.token), '--compile-only'], expected=37)
|
self.run_wrapper([str(self.token), '--compile-only'], expected=37)
|
||||||
self.assertEqual(json.loads(self.capture.read_text())['token'], 'inert-test-token-123')
|
record = json.loads(self.capture.read_text())
|
||||||
|
self.assertEqual(record['token'], 'inert-test-token-123')
|
||||||
|
|
||||||
|
def test_compile_only_needs_no_token(self):
|
||||||
|
self.run_wrapper(['--compile-only', '--recompile'])
|
||||||
|
record = json.loads(self.capture.read_text())
|
||||||
|
version = tomllib.loads((self.project / 'Cargo.toml').read_text())['package']['version']
|
||||||
|
prerelease = ['--prerelease'] if '-' in version.split('+', 1)[0] else []
|
||||||
|
self.assertEqual(record['args'], [str(self.project), '--package', 'tiny-wb',
|
||||||
|
'--artifact-format', 'both', '--compile-only',
|
||||||
|
'--recompile', *prerelease])
|
||||||
|
self.assertIsNone(record['token'])
|
||||||
|
|
||||||
|
def test_missing_release_cross_config_never_invokes_publisher(self):
|
||||||
|
(self.project / 'release' / 'Cross.toml').unlink()
|
||||||
|
result = self.run_wrapper(['--compile-only'], expected=2)
|
||||||
|
self.assertIn('release Cross configuration is missing or unreadable', result.stderr)
|
||||||
|
self.assertFalse(self.capture.exists())
|
||||||
|
|
||||||
def test_invalid_token_inputs_never_invoke_publisher(self):
|
def test_invalid_token_inputs_never_invoke_publisher(self):
|
||||||
self.run_wrapper([], expected=2)
|
self.run_wrapper([], expected=2)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue