From 07ec641d3dffff573d6535e9eba3c3f0978bf26e Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Thu, 12 Dec 2024 09:49:58 -0500 Subject: [PATCH 1/6] Add support for NFS sync --- index.js | 5 ++++- run.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a3405ef..e167284 100644 --- a/index.js +++ b/index.js @@ -95,6 +95,9 @@ async function setup(nat, mem, cpu) { } else if (sync == "sshfs") { core.info("Setup sshfs"); await shell("bash run.sh runSSHFSInVM"); + } else if (sync == "nfs") { + core.info("Setup nfs"); + await shell("bash run.sh runNFSInVM"); } else { await shell("bash run.sh installRsyncInVM"); await shell("bash run.sh rsyncToVM"); @@ -193,7 +196,7 @@ async function main() { let sync = core.getInput("sync"); if(sync == "no") { core.info("don't get back by rsync"); - } else if (sync != "sshfs") { + } else if (sync != "sshfs" && sync != "nfs") { core.info("get back by rsync"); await exec.exec("bash " + workingDir + "/run.sh rsyncBackFromVM"); } diff --git a/run.sh b/run.sh index b81af10..6d82faa 100644 --- a/run.sh +++ b/run.sh @@ -60,6 +60,7 @@ export VM_OS_NAME export VM_RELEASE export VM_INSTALL_CMD export VM_SSHFS_PKG +export VM_NFS_CMD export VM_LOGIN_TAG export VM_OCR export VM_DISK @@ -275,6 +276,21 @@ EOF } +runNFSInVM() { + if [ "$VM_NFS_CMD" ]; then + echo "Installing NFS on host" + sudo apt-get install -y nfs-kernel-server + echo "$HOME/work *(rw,async,no_subtree_check,anonuid=$(id -u),anongid=$(id -g))" | sudo tee -a /etc/exports + sudo exportfs -a + + echo "Configuring NFS in VM" + ssh "$osname" sh < Date: Sun, 22 Dec 2024 18:26:11 -0500 Subject: [PATCH 2/6] use onRunNFS.sh --- run.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/run.sh b/run.sh index 6d82faa..e4486a1 100644 --- a/run.sh +++ b/run.sh @@ -277,12 +277,14 @@ EOF } runNFSInVM() { - if [ "$VM_NFS_CMD" ]; then - echo "Installing NFS on host" - sudo apt-get install -y nfs-kernel-server - echo "$HOME/work *(rw,async,no_subtree_check,anonuid=$(id -u),anongid=$(id -g))" | sudo tee -a /etc/exports - sudo exportfs -a + echo "Installing NFS on host" + sudo apt-get install -y nfs-kernel-server + echo "$HOME/work *(rw,async,no_subtree_check,anonuid=$(id -u),anongid=$(id -g))" | sudo tee -a /etc/exports + sudo exportfs -a + if [ -e "hooks/onRunNFS.sh" ] && ssh "$osname" sh Date: Sun, 22 Dec 2024 18:32:47 -0500 Subject: [PATCH 3/6] update readme, test templates --- .github/tpl/README.tpl.md | 4 +-- .github/tpl/test.tpl.yml | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/.github/tpl/README.tpl.md b/.github/tpl/README.tpl.md index 9559761..6dfa10e 100644 --- a/.github/tpl/README.tpl.md +++ b/.github/tpl/README.tpl.md @@ -68,7 +68,7 @@ So, you will have the same directory and same default env variables when you `ru ## 2. Share code -The code is shared from the host to the VM via `rsync` by default, you can choose to use to `sshfs` share code instead. +The code is shared from the host to the VM via `rsync` by default, you can choose to use to `sshfs` or `nfs` share code instead. ``` @@ -83,7 +83,7 @@ The code is shared from the host to the VM via `rsync` by default, you can choos with: envs: 'MYTOKEN MYTOKEN2' usesh: true - sync: sshfs + sync: sshfs # or: nfs prepare: | {{VM_PREPARE}} diff --git a/.github/tpl/test.tpl.yml b/.github/tpl/test.tpl.yml index a9680d5..46da654 100644 --- a/.github/tpl/test.tpl.yml +++ b/.github/tpl/test.tpl.yml @@ -83,6 +83,65 @@ jobs: pwd {{VM_RUN}} + testnfs: + if: ${{ !contains(github.repository, 'netbsd') && !contains(github.repository, 'openbsd') && !contains(github.repository, 'dragonflybsd') && !contains(github.repository, 'omnios')}} + strategy: + matrix: + release: [ {{TEST_RELEASES}}, ""] + runs: [ "ubuntu-22.04", "ubuntu-24.04", "ubuntu-latest"] + runs-on: ${{ matrix.runs }} + name: nfs {{VM_NAME}} + env: + MYTOKEN : ${{ secrets.MYTOKEN }} + MYTOKEN2: "value2" + SEC_VBOX : ${{ secrets.SEC_VBOX }} + DEBUG: 1 + steps: + - uses: actions/checkout@v4 + - name: Creating Web console + uses: vmactions/cf-tunnel@v0 + id: tunnel + with: + protocol: http + port: 8000 + - name: Test in {{VM_NAME}} + id: test + uses: {{GITHUB_REPOSITORY}}@{{GITHUB_SHA}} + with: + envs: 'DEBUG MYTOKEN MYTOKEN2' + prepare: | + {{VM_PREPARE}} + release: ${{ matrix.release }} + nat: | + "10022": "22" + "8080": "80" + "8443": "443" + udp:"8081": "80" + usesh: true + sync: nfs + run: | + ls -lah /root/work + tree $HOME/work/ + if [ -z "$(ls -A $HOME/work)" ]; then + echo "nfs error." + exit 1 + fi + echo "TEST_ENV=abc" >>${GITHUB_ENV} +{{VM_RUN}} + + - name: Test NAT + run: + echo "TEST_ENV=$TEST_ENV" + [ "$TEST_ENV" = "abc" ] + ssh -vvv -p 10022 -i $HOME/.ssh/host.id_rsa root@localhost "uname -a;whoami;pwd" + - name: Test custom shell + shell: {{VM_OS_NAME}} {0} + run: | + pwd + cd $GITHUB_WORKSPACE; + pwd +{{VM_RUN}} + test: strategy: From 42d06ed561c63f8126c6173bcd5785d0c0bcc3a8 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Tue, 24 Dec 2024 08:42:26 -0500 Subject: [PATCH 4/6] set RUNNER_HOME for onRunNFS to expand host's HOME --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index e4486a1..d7fe22f 100644 --- a/run.sh +++ b/run.sh @@ -282,7 +282,7 @@ runNFSInVM() { echo "$HOME/work *(rw,async,no_subtree_check,anonuid=$(id -u),anongid=$(id -g))" | sudo tee -a /etc/exports sudo exportfs -a - if [ -e "hooks/onRunNFS.sh" ] && ssh "$osname" sh Date: Tue, 24 Dec 2024 10:35:38 -0500 Subject: [PATCH 5/6] all available VM images support NFS --- .github/tpl/test.tpl.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/tpl/test.tpl.yml b/.github/tpl/test.tpl.yml index 46da654..cdeda1b 100644 --- a/.github/tpl/test.tpl.yml +++ b/.github/tpl/test.tpl.yml @@ -84,7 +84,6 @@ jobs: {{VM_RUN}} testnfs: - if: ${{ !contains(github.repository, 'netbsd') && !contains(github.repository, 'openbsd') && !contains(github.repository, 'dragonflybsd') && !contains(github.repository, 'omnios')}} strategy: matrix: release: [ {{TEST_RELEASES}}, ""] From 16fd3caff93ad2f89d2303dcdd785caae8243885 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Tue, 24 Dec 2024 14:24:24 -0500 Subject: [PATCH 6/6] add default mount cmd --- run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/run.sh b/run.sh index d7fe22f..a60b944 100644 --- a/run.sh +++ b/run.sh @@ -288,6 +288,12 @@ runNFSInVM() { echo "Configuring NFS in VM" ssh "$osname" sh <