mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
ci: update deployment for doc rearrangement
This fixes CI to handle the new documentation files. We also continue to do more cleanup. In particular, we devise a nicer way of detecting the most recent Cargo OUT_DIR by writing a dummy file, and looking for the most recently modified version of that file.
This commit is contained in:
parent
904c75bd30
commit
09c5b2c4ea
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,6 +6,7 @@ target
|
|||||||
/ignore/Cargo.lock
|
/ignore/Cargo.lock
|
||||||
/termcolor/Cargo.lock
|
/termcolor/Cargo.lock
|
||||||
/wincolor/Cargo.lock
|
/wincolor/Cargo.lock
|
||||||
|
/deployment
|
||||||
|
|
||||||
# Snapcraft files
|
# Snapcraft files
|
||||||
stage
|
stage
|
||||||
@ -13,4 +14,4 @@ prime
|
|||||||
parts
|
parts
|
||||||
*.snap
|
*.snap
|
||||||
*.pyc
|
*.pyc
|
||||||
ripgrep*_source.tar.bz2
|
ripgrep*_source.tar.bz2
|
||||||
|
@ -73,7 +73,7 @@ before_deploy: ci/before_deploy.sh
|
|||||||
deploy:
|
deploy:
|
||||||
provider: releases
|
provider: releases
|
||||||
file_glob: true
|
file_glob: true
|
||||||
file: deployment/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
|
file: deployment/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
condition: $TRAVIS_RUST_VERSION = nightly
|
condition: $TRAVIS_RUST_VERSION = nightly
|
||||||
|
9
build.rs
9
build.rs
@ -31,6 +31,11 @@ fn main() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fs::create_dir_all(&outdir).unwrap();
|
fs::create_dir_all(&outdir).unwrap();
|
||||||
|
|
||||||
|
let stamp_path = Path::new(&outdir).join("ripgrep-stamp");
|
||||||
|
if let Err(err) = File::create(&stamp_path) {
|
||||||
|
panic!("failed to write {}: {}", stamp_path.display(), err);
|
||||||
|
}
|
||||||
if let Err(err) = generate_man_page(&outdir) {
|
if let Err(err) = generate_man_page(&outdir) {
|
||||||
eprintln!("failed to generate man page: {}", err);
|
eprintln!("failed to generate man page: {}", err);
|
||||||
}
|
}
|
||||||
@ -65,6 +70,10 @@ fn generate_man_page<P: AsRef<Path>>(outdir: P) -> io::Result<()> {
|
|||||||
eprintln!("Error from running 'a2x': {}", err);
|
eprintln!("Error from running 'a2x': {}", err);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
// 1. Read asciidoc template.
|
||||||
|
// 2. Interpolate template with auto-generated docs.
|
||||||
|
// 3. Save interpolation to disk.
|
||||||
|
// 4. Use a2x (part of asciidoc) to convert to man page.
|
||||||
let outdir = outdir.as_ref();
|
let outdir = outdir.as_ref();
|
||||||
let cwd = env::current_dir()?;
|
let cwd = env::current_dir()?;
|
||||||
let tpl_path = cwd.join("doc").join("rg.1.txt.tpl");
|
let tpl_path = cwd.join("doc").join("rg.1.txt.tpl");
|
||||||
|
@ -17,31 +17,39 @@ mk_artifacts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mk_tarball() {
|
mk_tarball() {
|
||||||
|
# When cross-compiling, use the right `strip` tool on the binary.
|
||||||
local gcc_prefix="$(gcc_prefix)"
|
local gcc_prefix="$(gcc_prefix)"
|
||||||
local td="$(mktemp -d)"
|
# Create a temporary dir that contains our staging area.
|
||||||
|
# $tmpdir/$name is what eventually ends up as the deployed archive.
|
||||||
|
local tmpdir="$(mktemp -d)"
|
||||||
local name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
|
local name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
|
||||||
local staging="$td/$name"
|
local staging="$tmpdir/$name"
|
||||||
mkdir -p "$staging/complete"
|
mkdir -p "$staging"/{complete,doc}
|
||||||
|
# The deployment directory is where the final archive will reside.
|
||||||
|
# This path is known by the .travis.yml configuration.
|
||||||
local out_dir="$(pwd)/deployment"
|
local out_dir="$(pwd)/deployment"
|
||||||
mkdir -p "$out_dir"
|
mkdir -p "$out_dir"
|
||||||
|
# Find the correct (most recent) Cargo "out" directory. The out directory
|
||||||
|
# contains shell completion files and the man page.
|
||||||
|
local cargo_out_dir="$(cargo_out_dir "target/$TARGET")"
|
||||||
|
|
||||||
# Copy the ripgrep binary and strip it.
|
# Copy the ripgrep binary and strip it.
|
||||||
cp target/$TARGET/release/rg "$staging/rg"
|
cp "target/$TARGET/release/rg" "$staging/rg"
|
||||||
"${gcc_prefix}strip" "$staging/rg"
|
"${gcc_prefix}strip" "$staging/rg"
|
||||||
# Copy the README and licenses.
|
# Copy the licenses and README.
|
||||||
cp {README.md,UNLICENSE,COPYING,LICENSE-MIT} "$staging/"
|
cp {README.md,UNLICENSE,COPYING,LICENSE-MIT} "$staging/"
|
||||||
|
# Copy documentation and man page.
|
||||||
|
cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$staging/doc/"
|
||||||
|
if command -V a2x 2>&1 > /dev/null; then
|
||||||
|
# The man page should only exist if we have asciidoc installed.
|
||||||
|
cp "$cargo_out_dir/rg.1" "$staging/doc/"
|
||||||
|
fi
|
||||||
# Copy shell completion files.
|
# Copy shell completion files.
|
||||||
cp \
|
cp "$cargo_out_dir"/{rg.bash,rg.fish,_rg.ps1} "$staging/complete/"
|
||||||
target/"$TARGET"/release/build/ripgrep-*/out/{rg.bash,rg.fish,_rg.ps1} \
|
cp complete/_rg "$staging/complete/"
|
||||||
"$staging/complete/"
|
|
||||||
cp complete/_rg "$td/$name/complete/"
|
|
||||||
# Copy man page.
|
|
||||||
cp \
|
|
||||||
target/"$TARGET"/release/build/ripgrep-*/out/rg.1 \
|
|
||||||
"$td/$name/"
|
|
||||||
|
|
||||||
(cd "$td" && tar czf "$out_dir/$name.tar.gz" *)
|
(cd "$tmpdir" && tar czf "$out_dir/$name.tar.gz" "$name")
|
||||||
rm -rf "$td"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -22,6 +22,14 @@ install_targets() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_osx_dependencies() {
|
||||||
|
if ! is_osx; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
brew install asciidoc
|
||||||
|
}
|
||||||
|
|
||||||
configure_cargo() {
|
configure_cargo() {
|
||||||
local prefix=$(gcc_prefix)
|
local prefix=$(gcc_prefix)
|
||||||
if [ -n "${prefix}" ]; then
|
if [ -n "${prefix}" ]; then
|
||||||
@ -44,6 +52,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
install_osx_dependencies
|
||||||
install_rustup
|
install_rustup
|
||||||
install_targets
|
install_targets
|
||||||
configure_cargo
|
configure_cargo
|
||||||
|
36
ci/script.sh
36
ci/script.sh
@ -11,17 +11,16 @@ main() {
|
|||||||
# output of cargo a little trickier. So just wipe it.
|
# output of cargo a little trickier. So just wipe it.
|
||||||
cargo clean
|
cargo clean
|
||||||
# Test a normal debug build.
|
# Test a normal debug build.
|
||||||
cargo build --target "${TARGET}" --verbose --all
|
cargo build --target "$TARGET" --verbose --all
|
||||||
|
|
||||||
# Show the output of build.rs stderr.
|
# Show the output of the most recent build.rs stderr.
|
||||||
set +x
|
set +x
|
||||||
find ./target/"$TARGET"/debug -name stderr | while read stderr; do
|
stderr="$(find "target/$TARGET/debug" -name stderr -print0 | xargs -0 ls -t | head -n1)"
|
||||||
if [ -s "$stderr" ]; then
|
if [ -s "$stderr" ]; then
|
||||||
echo "===== $stderr ====="
|
echo "===== $stderr ====="
|
||||||
cat "$stderr"
|
cat "$stderr"
|
||||||
echo "====="
|
echo "====="
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# sanity check the file type
|
# sanity check the file type
|
||||||
@ -37,19 +36,16 @@ main() {
|
|||||||
"$(dirname "${0}")/test_complete.sh"
|
"$(dirname "${0}")/test_complete.sh"
|
||||||
|
|
||||||
# Check that we've generated man page and other shell completions.
|
# Check that we've generated man page and other shell completions.
|
||||||
find ./target/"$TARGET"/debug/build/ripgrep-* -name 'out' | \
|
outdir="$(cargo_out_dir "target/$TARGET/debug")"
|
||||||
while read outdir; do
|
file "$outdir/rg.bash"
|
||||||
file "$outdir/rg.bash"
|
file "$outdir/rg.fish"
|
||||||
file "$outdir/rg.fish"
|
file "$outdir/_rg.ps1"
|
||||||
file "$outdir/_rg.ps1"
|
# N.B. man page isn't generated on ARM cross-compile, but we gave up
|
||||||
# man page requires asciidoc, and we only install it on Linux x86.
|
# long before this anyway.
|
||||||
if is_linux; then
|
file "$outdir/rg.1"
|
||||||
file "$outdir/rg.1"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Run tests for ripgrep and all sub-crates.
|
# Run tests for ripgrep and all sub-crates.
|
||||||
cargo test --target "${TARGET}" --verbose --all
|
cargo test --target "$TARGET" --verbose --all
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
21
ci/utils.sh
21
ci/utils.sh
@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
# Various utility functions used through CI.
|
# Various utility functions used through CI.
|
||||||
|
|
||||||
|
# Finds Cargo's `OUT_DIR` directory from the most recent build.
|
||||||
|
#
|
||||||
|
# This requires one parameter corresponding to the target directory
|
||||||
|
# to search for the build output.
|
||||||
|
cargo_out_dir() {
|
||||||
|
# This works by finding the most recent stamp file, which is produced by
|
||||||
|
# every ripgrep build.
|
||||||
|
target_dir="$1"
|
||||||
|
find "$target_dir" -name ripgrep-stamp -print0 \
|
||||||
|
| xargs -0 ls -t \
|
||||||
|
| head -n1 \
|
||||||
|
| xargs dirname
|
||||||
|
}
|
||||||
|
|
||||||
host() {
|
host() {
|
||||||
case "$TRAVIS_OS_NAME" in
|
case "$TRAVIS_OS_NAME" in
|
||||||
linux)
|
linux)
|
||||||
@ -68,3 +82,10 @@ is_linux() {
|
|||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_osx() {
|
||||||
|
case "$TRAVIS_OS_NAME" in
|
||||||
|
osx) return 0 ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user