Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/celest_cli.headless.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Verifies the functionality of the headless wrapper scripts.
name: celest_cli (Headless)
on:
pull_request:
paths:
- ".github/workflows/celest_cli.headless.yaml"
- "apps/cli/tool/linux/**"

# Prevent duplicate runs due to Graphite
# https://graphite.dev/docs/troubleshooting#why-are-my-actions-running-twice
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || ''}}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
# Test multiple shells since small nuances exist between them
shell:
- sh
- bash
runs-on: ${{ matrix.os }}
timeout-minutes: 5
defaults:
run:
shell: ${{ matrix.shell }}
working-directory: apps/cli/tool/linux
steps:
- name: Git Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- name: Setup Dart
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # 1.7.1
- name: Install Celest
run: ./install
- name: Verify Celest
run: ./check
2 changes: 1 addition & 1 deletion apps/cli/lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ final class Cli {
}

if (argResults.wasParsed('version') && argResults['version'] as bool) {
stdout.write(ctx.verbose ? sdkInfo : version);
stdout.writeln(ctx.verbose ? sdkInfo : version);
return;
}

Expand Down
29 changes: 16 additions & 13 deletions apps/cli/tool/linux/celest
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
set -e

OS=`uname -s`
if test $OS = "Linux"; then
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
. "${os_release}"
if test $OS != "Linux"; then
>&2 echo "This script is intended for Linux systems only."
exit 1
fi

if [ "${ID:-linux}" != "debian" ] && [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
>&2 echo "Unsupported distribution: ${ID:-linux}"
exit 1
fi
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
. "${os_release}"

# If running in headless mode, re-run script in dbus session.
if ! dbus-send --session --dest=org.freedesktop.DBus / org.freedesktop.DBus.Peer.Ping > /dev/null 2>&1; then
exec dbus-run-session -- "$0" "$@"
fi
if [ "${ID:-linux}" != "debian" ] && [ "${ID:-linux}" != "ubuntu" ] && [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
>&2 echo "Unsupported distribution: ${ID:-linux}"
exit 1
fi

echo 'password' | gnome-keyring-daemon --start --replace --components=secrets --unlock --daemonize > /dev/null 2>&1
# If running in headless mode, re-run script in dbus session.
if ! dbus-send --session --dest=org.freedesktop.DBus / org.freedesktop.DBus.Peer.Ping > /dev/null 2>&1; then
exec dbus-run-session -- "$0" "$@"
fi

celest $@
echo 'password' | gnome-keyring-daemon --start --replace --components=secrets --unlock --daemonize > /dev/null 2>&1

/opt/celest/celest $@
23 changes: 23 additions & 0 deletions apps/cli/tool/linux/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
#
# This script verifies the functionality of the `install` and `celest` wrapper scripts.

# Check that `celest` is installed
if ! command -v celest; then
echo "Celest is not installed."
exit 1
fi

# Check that `celest` without the wrapper fails
if celest --version; then
echo "Celest should not be executable without the wrapper."
exit 1
fi

# Check that `celest` with the wrapper works
if ! $SHELL ./celest --version; then
echo "Celest should be executable with the wrapper."
exit 1
fi

echo "All checks passed."
55 changes: 28 additions & 27 deletions apps/cli/tool/linux/install
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

set -e

OS=`uname -s`
if test $OS != "Linux"; then
>&2 echo "This script is intended for Linux systems only."
exit 1
fi

install_package() {
if [ "$(id -u)" -ne 0 ]; then
if ! command -v sudo &> /dev/null; then
if ! command -v sudo > /dev/null 2>&1; then
>&2 echo "Script requires sudo to install '${@}'. Please install it manually."
exit 1
fi
Expand All @@ -19,7 +25,6 @@ install_package() {
fi
}

OS=`uname -s`
case `uname -m` in
x86_64|amd64|AMD64)
ARCH="x64"
Expand All @@ -33,36 +38,32 @@ case `uname -m` in
;;
esac

if test $OS = "Linux"; then
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
. "${os_release}"
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
. "${os_release}"

if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
echo "Detected Debian-based system: ${ID:-linux}"
else
>&2 echo "Unsupported distribution: ${ID:-linux}"
exit 1
fi
if [ "${ID:-linux}" != "debian" ] && [ "${ID:-linux}" != "ubuntu" ] && [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
>&2 echo "Unsupported distribution: ${ID:-linux}"
exit 1
fi

# Check if Celest is installed
if ! command -v celest &> /dev/null; then
if ! command -v curl &> /dev/null; then
echo "Installing curl..."
install_package -y curl
fi
# Check if Celest is installed
if ! command -v celest > /dev/null 2>&1; then
if ! command -v curl > /dev/null 2>&1; then
echo "Installing curl..."
install_package -y curl
fi

echo "Installing Celest..."
CURRENT_DIR=$(pwd)
cd $(mktemp -d)
trap 'cd "$CURRENT_DIR"; rm -rf "$TMP_DIR"' EXIT
echo "Installing Celest..."
CURRENT_DIR=$(pwd)
cd $(mktemp -d)
trap 'cd "$CURRENT_DIR"; rm -rf "$TMP_DIR"' EXIT

ARTIFACT_NAME="celest_cli-linux-${ARCH}.deb"
DOWNLOAD_URL="https://github.com/celest-dev/celest/releases/latest/download/$ARTIFACT_NAME"
ARTIFACT_NAME="celest_cli-linux-${ARCH}.deb"
DOWNLOAD_URL="https://github.com/celest-dev/celest/releases/latest/download/$ARTIFACT_NAME"

echo "Downloading Celest from $DOWNLOAD_URL"
curl -sSLo "$ARTIFACT_NAME" "$DOWNLOAD_URL"
install_package -y --fix-broken "./$ARTIFACT_NAME"
fi
echo "Downloading Celest from $DOWNLOAD_URL"
curl -sSLo "$ARTIFACT_NAME" "$DOWNLOAD_URL"
install_package -y --fix-broken "./$ARTIFACT_NAME"
fi

echo "Celest is installed and ready to use."