-
Notifications
You must be signed in to change notification settings - Fork 24
feat: update setup script and installation instructions for easier setup #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaagut
wants to merge
4
commits into
main
Choose a base branch
from
feature/setup_workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dd0899c
feat: update setup script and installation instructions for easier setup
jaagut f553d96
Potential fix for pull request finding
jaagut 57d411c
Potential fix for pull request finding
jaagut 4658d40
fix: update setup script and clone commands for consistency and relia…
jaagut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Setup script | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run approximately twice a month. | ||
| - cron: "17 4 1,15 * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| setup: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 90 | ||
| env: | ||
| PSModulePath: "" # Otherwise colcon might think that PowerShell is being used | ||
|
|
||
| steps: | ||
| - name: Download and run setup script | ||
| run: | | ||
| cd "$RUNNER_TEMP" | ||
| curl -fsSL https://raw.githubusercontent.com/bit-bots/bitbots_main/main/scripts/bitbots_setup.sh \ | ||
| --output bitbots_setup.sh | ||
| bash ./bitbots_setup.sh --https |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| #!/usr/bin/env bash | ||
| set -Eeuo pipefail | ||
|
|
||
| readonly DEFAULT_BRANCH="main" | ||
| readonly REPO_URL_SSH="git@github.com:bit-bots/bitbots_main.git" | ||
| readonly REPO_URL_HTTPS="https://github.com/bit-bots/bitbots_main.git" | ||
|
|
||
| branch="$DEFAULT_BRANCH" | ||
| branch_explicit=false | ||
| clone_method="ssh" | ||
| clone_method_explicit=false | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 [--ssh | --https] [branch]" >&2 | ||
| } | ||
|
|
||
| parse_args() { | ||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --ssh | --https) | ||
| local method="${arg#--}" | ||
| if $clone_method_explicit && [[ "$clone_method" != "$method" ]]; then | ||
| echo "Only one clone method can be selected." >&2 | ||
| usage | ||
| exit 2 | ||
| fi | ||
| clone_method="$method" | ||
| clone_method_explicit=true | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $arg" >&2 | ||
| usage | ||
| exit 2 | ||
| ;; | ||
| *) | ||
| if $branch_explicit; then | ||
| echo "Only one branch can be selected." >&2 | ||
| usage | ||
| exit 2 | ||
| fi | ||
| branch="$arg" | ||
| branch_explicit=true | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| ask_question() { | ||
| local response | ||
|
|
||
| while true; do | ||
| read -r -p "$1 [Y/n]: " response | ||
| case "$response" in | ||
| [Yy] | [Yy][Ee][Ss] | "") return 0 ;; | ||
| [Nn] | [Nn][Oo]) return 1 ;; | ||
| *) echo "Please answer yes or no." ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| setup_pixi() { | ||
| command -v pixi >/dev/null && return | ||
|
|
||
| command -v curl >/dev/null || { | ||
| echo "Required command not found: curl" >&2 | ||
| exit 1 | ||
| } | ||
| echo "Installing Pixi..." | ||
| curl -fsSL https://pixi.sh/install.sh | bash | ||
| export PATH="$HOME/.pixi/bin:$PATH" | ||
| command -v pixi >/dev/null || { | ||
| echo "Pixi installation completed, but pixi is not available on PATH." >&2 | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| clone_repo() { | ||
| local target="$PWD/bitbots_main" | ||
|
|
||
| if [[ -e "$target" ]]; then | ||
| git -C "$target" rev-parse --is-inside-work-tree >/dev/null 2>&1 || { | ||
| echo "Cannot clone: $target already exists and is not a Git repository." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| if git -C "$target" remote get-url origin >/dev/null 2>&1; then | ||
| git -C "$target" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" | ||
| git -C "$target" fetch --prune origin | ||
| fi | ||
|
|
||
| if git -C "$target" show-ref --verify --quiet "refs/heads/$branch"; then | ||
| git -C "$target" switch "$branch" | ||
| else | ||
| git -C "$target" switch --track -c "$branch" "origin/$branch" | ||
| fi | ||
| return | ||
| fi | ||
|
|
||
| echo "Cloning bitbots_main branch '$branch'..." | ||
| if [[ "$clone_method" == "https" ]]; then | ||
| git clone --branch "$branch" "$REPO_URL_HTTPS" "$target" | ||
| elif git clone --branch "$branch" "$REPO_URL_SSH" "$target"; then | ||
| : | ||
| else | ||
| echo "SSH clone failed. This may mean your SSH keys are not set up for GitHub." | ||
| echo "See: https://docs.github.com/en/authentication/connecting-to-github-with-ssh" | ||
| if [[ ! -t 0 ]]; then | ||
| echo "Cannot ask to retry with HTTPS because standard input is not interactive." >&2 | ||
| echo "Re-run the script with --https." >&2 | ||
| exit 1 | ||
| fi | ||
| if ask_question "Continue with an HTTPS clone instead?"; then | ||
| git clone --branch "$branch" "$REPO_URL_HTTPS" "$target" | ||
| else | ||
| echo "Set up your SSH keys and re-run this script." >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| main() { | ||
| parse_args "$@" | ||
|
|
||
| command -v git >/dev/null || { | ||
| echo "Required command not found: git" >&2 | ||
| exit 1 | ||
| } | ||
| setup_pixi | ||
|
|
||
| clone_repo | ||
|
|
||
| cd "$PWD/bitbots_main" | ||
| echo "Installing dependencies..." | ||
| pixi install | ||
| echo "Running full build..." | ||
| echo "If the build exhausts memory on this system, retry inside bitbots_main with:" | ||
| echo "pixi run -e default build --parallel-workers 2" | ||
| pixi run -e default build | ||
| } | ||
|
|
||
| main "$@" | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.