Skip to content

Commit

Permalink
ci: support prs, close #194
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 22, 2024
1 parent c5298fd commit fc5a017
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# don't use [shell: bash] unless needed, as for macos-fresh that caused an infinite queue for the test step, and for linux bash may not exist yet
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
name: dorothy-workflow
'on':
- push
Expand All @@ -15,7 +16,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/install?branch=${{ github.ref_name }}&commit=${{ github.sha }}')"
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/install?slug=${{ github.repository }}&commit=${{ github.sha }}')"
- name: 'Dorothy Configure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
Expand Down Expand Up @@ -103,7 +104,7 @@ jobs:
git config --global user.email '[email protected]'
git remote set-url origin 'https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}'
git commit -a -m 'ci: adjustments'
git push origin HEAD:${{ github.ref_name }}
git push origin HEAD:${{ github.ref }}
fi
- name: 'Trunk Check'
shell: bash -leo pipefail {0}
Expand All @@ -116,7 +117,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?branch=${{ github.ref_name }}&commit=${{ github.sha }}')" -- dorothy test
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.repository }}&commit=${{ github.sha }}')" -- dorothy test
fresh-macos-test:
runs-on: macos-latest
steps:
Expand All @@ -129,7 +130,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?branch=${{ github.ref_name }}&commit=${{ github.sha }}')" -- dorothy test
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.repository }}&commit=${{ github.sha }}')" -- dorothy test
distro-test:
continue-on-error: true
runs-on: ubuntu-latest
Expand Down Expand Up @@ -203,4 +204,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # prevent rate limiting
run: |
# ensure dorothy is cloned, and run command
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?branch=${{ github.ref_name }}&commit=${{ github.sha }}')" -- dorothy test
bash -c "$(curl -fsSL 'https://dorothy.bevry.me/run?slug=${{ github.repository }}&commit=${{ github.sha }}')" -- dorothy test
27 changes: 15 additions & 12 deletions commands/dorothy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function dorothy_() (
# sanity check that we are running in bash
# sanity check, as [function .. () (], [elif], [&>], [local] are all bashisms, so other shells should have failed by now
if test -z "${BASH_VERSION-}"; then
printf '%s\n' 'Dorothy requires bash to run. Refer to the installation instructions: https://github.com/bevry/dorothy#install' >/dev/stderr
printf '%s\n' "Dorothy requires bash to run. Refer to the installation instructions: $dorothy_install" >/dev/stderr
exit 6 # ENXIO 6 Device not configured
fi

Expand Down Expand Up @@ -80,7 +80,8 @@ function dorothy_() (
# Variables

# vars that are local to this script and shared between functions
local dorothy_homepage="https://github.com/bevry/dorothy"
local dorothy_homepage='https://github.com/bevry/dorothy'
local dorothy_install="$dorothy_homepage#install"

# =====================================
# Arguments
Expand Down Expand Up @@ -191,7 +192,7 @@ function dorothy_() (

# process action arguments
# @todo prevent double-action overwrite
local item action='' option_xdg='' option_branch='' option_commit='' option_reference='HEAD' option_args=()
local item action='' option_xdg='' option_branch='' option_commit='' option_reference='HEAD' option_slug='bevry/dorothy' option_args=()
while test "$#" -ne 0; do
item="$1"
shift
Expand All @@ -207,7 +208,8 @@ function dorothy_() (
option_commit="${item#*=}"
option_reference="$option_commit"
;;
'--reference='*) option_reference="${item#*=}" ;;
'--ref='* | '--reference='*) option_reference="${item#*=}" ;;
'--slug='*) option_slug="${item#*=}" ;;
'repl')
action='repl'
option_args+=("$@")
Expand Down Expand Up @@ -279,7 +281,7 @@ function dorothy_() (
if test -n "$DOROTHY" -a -f "$DOROTHY/sources/bash.bash"; then
source "$DOROTHY/sources/bash.bash"
else
eval "$(curl -fsSL "https://raw.githubusercontent.com/bevry/dorothy/$option_reference/sources/bash.bash")"
eval "$(curl -fsSL "https://raw.githubusercontent.com/$option_slug/$option_commit/sources/bash.bash")"
fi

# =====================================
Expand Down Expand Up @@ -391,7 +393,7 @@ function dorothy_() (
fish -c 'builtin realpath "$argv[1]"' -- "$path"
return
else
__print_line 'Dorothy requires readlink or realpath to be installed. https://github.com/bevry/dorothy#install' >/dev/stderr
__print_line "Dorothy requires readlink or realpath to be installed. $dorothy_install" >/dev/stderr
return 6 # ENXIO 6 Device not configured
fi
done
Expand Down Expand Up @@ -480,7 +482,7 @@ function dorothy_() (
ps: $(type -P ps || :)
awk: $(awk --version || :)
Refer to the manual: https://github.com/bevry/dorothy
Refer to the manual: $dorothy_homepage
EOF
return 19 # ENODEV 19 Operation not supported by device
fi
Expand Down Expand Up @@ -837,16 +839,17 @@ function dorothy_() (

# helpers
function install_dorothy {
local clone_args=()
print_line "Installing Dorothy into $DOROTHY"
if test -n "$option_branch"; then
git clone --branch "$option_branch" --single-branch "https://github.com/bevry/dorothy.git" "$DOROTHY"
git clone --branch "$option_branch" --single-branch "https://github.com/$option_slug.git" "$DOROTHY"
else
git clone "https://github.com/bevry/dorothy.git" "$DOROTHY"
git clone --depth 1 --no-tags "https://github.com/$option_slug.git" "$DOROTHY"
fi
if test -n "$option_commit"; then
if test -n "$option_reference"; then
(
cd "$DOROTHY"
git checkout "$option_commit"
git checkout "$option_reference"
)
fi
}
Expand Down Expand Up @@ -1067,7 +1070,7 @@ function dorothy_() (
To enable SSH, do the following on this machine:
macOS via: System Preferences > Sharing > Remote Login.
Linux via: $(echo-style --code="bash -ic \"\$(curl -fsSL https://dorothy.bevry.workers.dev/commands/setup-util-sshd)\"")
Linux via: $(echo-style --code="bash -ic \"\$(curl -fsSL https://dorothy.bevry.me/run)\" -- setup-util-sshd")
EOF
)"
Expand Down

0 comments on commit fc5a017

Please sign in to comment.