Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Neilpang committed Nov 13, 2023
1 parent 1729806 commit acff579
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 42 deletions.
16 changes: 11 additions & 5 deletions .github/tpl/README.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ You can add NAT port between the host and the VM.
```


The default memory of the VM is 1024MB, you can use `mem` option to set the memory size:
The default memory of the VM is 6144MB, you can use `mem` option to set the memory size:

```
...
Expand All @@ -152,7 +152,7 @@ The default memory of the VM is 1024MB, you can use `mem` option to set the memo
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
mem: 2048
mem: 4096
...
```

Expand All @@ -177,10 +177,16 @@ All the supported releases are here: [{{VM_NAME}} {{ALL_RELEASES}}](conf)

# Under the hood

GitHub only supports Ubuntu, Windows and MacOS out of the box.
We use Qemu and Libvirt to run the {{VM_NAME}} VM.




# Upcoming features:

1. Runs on MacOS to use cpu accelaration.
2. Support ARM and other architecture.

However, the MacOS support virtualization. It has VirtualBox installed.

So, we run the {{VM_NAME}} VM in VirtualBox on MacOS.


12 changes: 9 additions & 3 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ on:

jobs:
build:
runs-on: macos-12
runs-on: ubuntu-22.04
env:
DEBUG: 1
NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }}
VM_RELEASE: ${{ secrets.VM_RELEASE }}
SEC_VBOX : ${{ secrets.SEC_VBOX }}
steps:
- uses: actions/checkout@v3
- name: Run establish a ngrok tunnel
- uses: vmactions/cf-tunnel@v0
id: tunnel
with:
protocol: http
port: 8000
- name: Run vnc tunnel
id: test
uses: vmactions/[email protected]
with:
protocol: tcp
port: 3390
port: 5900
- name: Sleep
run: |
for i in $(seq 1 10) ; do echo $i; sleep 1; done
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ jobs:
strategy:
matrix:
release: [ "11.4", ""]
runs-on: macos-12
name: A job to run test sshfs Solaris
runs: [ "ubuntu-22.04"]
runs-on: ${{ matrix.runs }}
name: sshfs Solaris
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
SEC_VBOX : ${{ secrets.SEC_VBOX }}
steps:
- uses: actions/checkout@v3
- name: Test in Solaris
Expand All @@ -54,17 +56,19 @@ jobs:
sync: sshfs
run: |
tree .
tree /Users/runner/work/
tree $HOME/work/
test:
strategy:
matrix:
release: [ "11.4", ""]
runs-on: macos-12
name: A job to run test Solaris
runs: [ "ubuntu-22.04"]
runs-on: ${{ matrix.runs }}
name: Solaris
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
SEC_VBOX : ${{ secrets.SEC_VBOX }}
steps:
- uses: actions/checkout@v3
- name: Test in Solaris
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function setup(nat, mem) {
core.endGroup();

core.startGroup("Initialize files in VM");
let cmd1 = "mkdir -p /Users/runner/work && ln -s /Users/runner/work/ work";
let cmd1 = "mkdir -p " + process.env["HOME"] + "/work && ln -s " + process.env["HOME"] + "/work/ work";
await execSSH(cmd1, "Setting up VM");

let sync = core.getInput("sync");
Expand Down
53 changes: 25 additions & 28 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,51 +73,56 @@ osname="$VM_OS_NAME"
ostype="$VM_OS_TYPE"
sshport=$VM_SSH_PORT

ovafile="$osname-$VM_RELEASE.ova"

ovafile="$osname-$VM_RELEASE.qcow2.xz"

_idfile='~/.ssh/host.id_rsa'

importVM() {
_idfile='~/.ssh/mac.id_rsa'

bash $vmsh addSSHHost $osname $sshport "$_idfile"

bash $vmsh setup

if [ ! -e "$ovafile" ]; then
echo "Downloading $OVA_LINK"
wget -O "$ovafile" -q "$OVA_LINK"
axel -n 8 -o "$ovafile" -q "$OVA_LINK"
echo "Download finished, extract"
xz -d $ovafile
echo "Extract finished"
fi

if [ ! -e "id_rsa.pub" ]; then
echo "Downloading $VM_PUBID_LINK"
wget -O "id_rsa.pub" -q "$VM_PUBID_LINK"
fi

if [ ! -e "mac.id_rsa" ]; then
echo "Downloading $VM_PUBID_LINK"
wget -O "mac.id_rsa" -q "$HOST_ID_LINK"
if [ ! -e "host.id_rsa" ]; then
echo "Downloading $HOST_ID_LINK"
wget -O "host.id_rsa" -q "$HOST_ID_LINK"
fi

ls -lah

bash $vmsh addSSHAuthorizedKeys id_rsa.pub
cat mac.id_rsa >$HOME/.ssh/mac.id_rsa
chmod 600 $HOME/.ssh/mac.id_rsa
cat host.id_rsa >$HOME/.ssh/host.id_rsa
chmod 600 $HOME/.ssh/host.id_rsa

bash $vmsh importVM "$ovafile"
bash $vmsh importVM $osname $ostype "$osname-$VM_RELEASE.qcow2"

if [ "$DEBUG" ]; then
bash $vmsh startWeb $osname
bash $vmsh startCF
fi

}



waitForLoginTag() {
bash $vmsh waitForText "$osname" "$VM_LOGIN_TAG"
if [ -e "hooks/waitForLoginTag.sh" ]; then
echo "Run hooks/waitForLoginTag.sh"
. hooks/waitForLoginTag.sh
else
bash $vmsh waitForText "$osname" "$VM_LOGIN_TAG"
fi

}


Expand Down Expand Up @@ -153,15 +158,15 @@ startVM() {
rsyncToVM() {
_pwd="$PWD"
cd "$_oldPWD"
rsync -avrtopg -e 'ssh -o [email protected]' --exclude _actions --exclude _PipelineMapping --exclude _temp /Users/runner/work/ $osname:work
rsync -avrtopg -e 'ssh -o [email protected]' --exclude _actions --exclude _PipelineMapping --exclude _temp $HOME/work/ $osname:work
cd "$_pwd"
}


rsyncBackFromVM() {
_pwd="$PWD"
cd "$_oldPWD"
rsync -vrtopg -e 'ssh -o [email protected]' $osname:work/ /Users/runner/work
rsync -vrtopg -e 'ssh -o [email protected]' $osname:work/ $HOME/work
cd "$_pwd"
}

Expand All @@ -176,20 +181,11 @@ EOF
}

runSSHFSInVM() {
# remove these when using the vbox v0.0.2 and newer
echo "Reloading sshd services in the Host"
sudo sh <<EOF
echo "" >>/etc/ssh/sshd_config
echo "StrictModes no" >>/etc/ssh/sshd_config
EOF
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist


if [ -e "hooks/onRunSSHFS.sh" ] && ssh "$osname" sh <hooks/onRunSSHFS.sh; then
echo "OK";
elif [ "$VM_SSHFS_PKG" ]; then
echo "Insalling $VM_SSHFS_PKG"
echo "Installing $VM_SSHFS_PKG"
ssh "$osname" sh <<EOF
$VM_INSTALL_CMD $VM_SSHFS_PKG
Expand All @@ -198,7 +194,7 @@ EOF
echo "Run sshfs"
ssh "$osname" sh <<EOF
sshfs -o reconnect,ServerAliveCountMax=2,allow_other,default_permissions host:work /Users/runner/work
sshfs -o reconnect,ServerAliveCountMax=2,allow_other,default_permissions host:work $HOME/work
EOF

Expand All @@ -210,6 +206,7 @@ EOF

#run in the vm, just as soon as the vm is up
onStarted() {
bash $vmsh addSSHHost $osname "$_idfile"
if [ -e "hooks/onStarted.sh" ]; then
ssh "$osname" sh <hooks/onStarted.sh
fi
Expand Down Expand Up @@ -248,7 +245,7 @@ waitForBooting() {
showDebugInfo() {
echo "==================Debug Info===================="
pwd && ls -lah
bash -c 'pwd && ls -lah ~/.ssh/ && cat ~/.ssh/config'
bash -c 'pwd && ls -lah ~/.ssh/ && [ -e "~/.ssh/config" ] && cat ~/.ssh/config'
cat $_conf_filename

echo "===================Debug Info in VM============="
Expand Down

0 comments on commit acff579

Please sign in to comment.