Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Neilpang committed Dec 4, 2023
1 parent ad9f471 commit 59f584f
Show file tree
Hide file tree
Showing 11 changed files with 445 additions and 14 deletions.
192 changes: 192 additions & 0 deletions .github/tpl/README.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Run GitHub CI in {{VM_NAME}} ![Test](https://github.com/{{GITHUB_REPOSITORY}}/workflows/Test/badge.svg)

Use this action to run your CI in {{VM_NAME}}.

The github workflow only supports Ubuntu, Windows and MacOS. But what if you need to use {{VM_NAME}}?

This action is to support {{VM_NAME}}.


Sample workflow `test.yml`:

```yml

name: Test

on: [push]

jobs:
test:
runs-on: {{VM_RUNS_ON}}
name: A job to run test in {{VM_NAME}}
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
steps:
- uses: actions/checkout@v4
- name: Test in {{VM_NAME}}
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
prepare: |
{{VM_PREPARE}}
run: |
{{VM_RUN}}




```


The latest major version is: `{{LATEST_MAJOR}}`, which is the most recommended to use. (You can also use the latest full version: `{{LATEST_TAG}}`)


If you are migrating from the previous `v0`, please change the `runs-on: ` to `runs-on: {{VM_RUNS_ON}}`


The `envs: 'MYTOKEN MYTOKEN2'` is the env names that you want to pass into the vm.

The `run: xxxxx` is the command you want to run in the vm.

The env variables are all copied into the VM, and the source code and directory are all synchronized into the VM.

The working dir for `run` in the VM is the same as in the Host machine.

All the source code tree in the Host machine are mounted into the VM.

All the `GITHUB_*` as well as `CI=true` env variables are passed into the VM.

So, you will have the same directory and same default env variables when you `run` the CI script.

{{VM_SHELL_COMMENTS}}

The code is shared from the host to the VM via `rsync`, you can choose to use to `sshfs` share code instead.


```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
sync: sshfs
prepare: |
{{VM_PREPARE}}
...
```


When using `rsync`, you can define `copyback: false` to not copy files back from the VM in to the host.


```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
sync: rsync
copyback: false
prepare: |
{{VM_PREPARE}}
...
```



You can add NAT port between the host and the VM.

```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
nat: |
"8080": "80"
"8443": "443"
udp:"8081": "80"
...
```


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

```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
mem: 4096
...
```



It uses [the {{VM_NAME}} {{DEFAULT_RELEASE}}](conf/default.release.conf) by default, you can use `release` option to use another version of {{VM_NAME}}:

```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: {{GITHUB_REPOSITORY}}@{{LATEST_MAJOR}}
with:
release: {{VM_SET_RELEASE}}
...
```

All the supported releases are here: [{{VM_NAME}} {{ALL_RELEASES}}](conf)


# Under the hood

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.




14 changes: 14 additions & 0 deletions .github/workflows/major.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Update Major Release Tag

on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
update-majorver:
name: Update Major Release Tag
runs-on: ubuntu-latest
steps:
- uses: nowactions/update-majorver@v1
45 changes: 45 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Manual"
on:
workflow_dispatch:


jobs:
build:
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@v4
- 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: 5900
- name: Sleep
run: |
for i in $(seq 1 10) ; do echo $i; sleep 1; done
touch /tmp/keepalive
echo "====================================="
echo "please loin the SSH bellow, and run: "
echo "bash run.sh importVM"
echo "bash run.sh onBeforeStartVM "
echo "bash run.sh startVM "
echo "====================================="
- uses: neilpang/debugger-action@master







51 changes: 51 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Update Readme"
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- '.github/tpl/*'
- '.github/data/*'
- '.github/workflows/readme.yml'

release:
types: [ published ]


jobs:
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get latest release
id: get-latest-release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
view_top: 1

- name: Using main branch
run: |
git switch main || (git fetch --all && git checkout -b main origin/main)
. conf/default.release.conf
echo "DEFAULT_RELEASE=$DEFAULT_RELEASE" >> $GITHUB_ENV
echo "LATEST_MAJOR=$(echo ${{ steps.get-latest-release.outputs.tag_name }} | cut -d . -f 1)" >> $GITHUB_ENV
echo "LATEST_TAG=${{ steps.get-latest-release.outputs.tag_name }}" >> $GITHUB_ENV
echo "ALL_RELEASES=$(ls conf/ | grep -v default | sed 's/.conf//g' | tr '\n' ',' | sed "s/,\$//" | sed 's/,/, /g')" >> $GITHUB_ENV
- name: Update the readme.md
uses: vmactions/[email protected]
with:
datafile: .github/data/datafile.ini
files: |
.github/tpl/README.tpl.md : README.md
- uses: EndBug/add-and-commit@v9
with:
message: "Update version to ${{ steps.get-latest-release.outputs.tag_name }}"
pull: '--rebase --autostash '
add: |
README.md
Loading

0 comments on commit 59f584f

Please sign in to comment.