Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
neil committed Dec 4, 2023
1 parent 1135e99 commit b024d4b
Show file tree
Hide file tree
Showing 153 changed files with 9,775 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: vmactions
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 changes: 14 additions & 0 deletions .github/data/datafile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


VM_NAME=OmniOS

VM_RUNS_ON=ubuntu-latest

VM_PREPARE="pkg install socat"

VM_RUN[email protected]/data/run.txt

VM_SET_RELEASE=r151046

VM_SHELL_COMMENTS=""

15 changes: 15 additions & 0 deletions .github/data/run.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ -n "test" ]; then
echo "false"
fi
if [ "test" ]; then
echo "test"
fi
pwd
ls -lah
whoami
env
psrinfo -vp
cat /etc/release
psrinfo -v
echo "::memstat" | mdb -k
echo "OK"
54 changes: 54 additions & 0 deletions .github/workflows/syncbase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Step 1, Sync generate.yml from BaseVM"
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
push:
branches:
- 'main'
paths:
- '.github/data/*'
- 'conf/*'
- '.github/workflows/syncbase.yml'


jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.VM_TOKEN }}
- 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 "ALL_RELEASES=\"$(ls conf/ | grep -v default | sed 's/.conf//g' | tr '\n' ',' | sed "s/,\$//" | sed 's/,/", "/g')\"" >> $GITHUB_ENV
git clone https://github.com/vmactions/base-vm.git
- name: Sync generate.yml
uses: vmactions/[email protected]
env:
LATEST_TAG: ${{ steps.get-latest-release.outputs.tag_name }}
with:
datafile: .github/data/datafile.ini
files: |
base-vm/.github/tpl/generate.tpl.yml : .github/workflows/generate.yml
- uses: EndBug/add-and-commit@v9
with:
message: "Sync from https://github.com/vmactions/base-vm"
pull: '--rebase --autostash '
add: |
.github/workflows/generate.yml
207 changes: 206 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,206 @@
# omnios-vm
# Run GitHub CI in Solaris ![Test](https://github.com/vmactions/solaris-vm/workflows/Test/badge.svg)

Use this action to run your CI in Solaris.

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

This action is to support Solaris.


Sample workflow `test.yml`:

```yml

name: Test

on: [push]

jobs:
test:
runs-on: ubuntu-latest
name: A job to run test in Solaris
env:
MYTOKEN : ${{ secrets.MYTOKEN }}
MYTOKEN2: "value2"
steps:
- uses: actions/checkout@v4
- name: Test in Solaris
id: test
uses: vmactions/solaris-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
prepare: |
pkgutil -y -i socat
run: |
if [ -n "test" ]; then
echo "false"
fi
if [ "test" ]; then
echo "test"
fi
pwd
ls -lah
whoami
env
psrinfo -vp
cat /etc/release
psrinfo -v
echo "::memstat" | mdb -k
echo "OK"
```
The latest major version is: `v1`, which is the most recommended to use. (You can also use the latest full version: `v1.0.0`)


If you are migrating from the previous `v0`, please change the `runs-on: ` to `runs-on: ubuntu-latest`


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.



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: vmactions/solaris-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
sync: sshfs
prepare: |
pkgutil -y -i socat



...


```
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: vmactions/solaris-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
sync: rsync
copyback: false
prepare: |
pkgutil -y -i socat



...


```
You can add NAT port between the host and the VM.
```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: vmactions/solaris-vm@v1
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: vmactions/solaris-vm@v1
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
mem: 4096
...
```
It uses [the Solaris 11.4](conf/default.release.conf) by default, you can use `release` option to use another version of Solaris:
```
...
steps:
- uses: actions/checkout@v4
- name: Test
id: test
uses: vmactions/solaris-vm@v1
with:
release: 11.4
...
```
All the supported releases are here: [Solaris 11.4](conf)
# Under the hood
We use Qemu and Libvirt to run the Solaris VM.
# Upcoming features:
1. Runs on MacOS to use cpu accelaration.
2. Support ARM and other architecture.
37 changes: 37 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Solaris-vm'
description: 'Run CI in Solaris for GitHub Actions'
inputs:
prepare:
description: 'Install some tools before CI runs'
required: false
run:
description: 'The CI command to run'
required: true
release:
description: 'The release version of Solaris vm'
required: false
envs:
description: 'The envs to pass into Solaris vm'
required: false
mem:
description: 'Set the memory size of the vm'
required: false
nat:
description: 'The NAT ports to Solaris vm'
required: false
usesh:
description: 'Use sh instead of the default shell: csh'
required: false
sync:
description: 'How to synchronize the source code to/from the VM, Values can be: rsync(default), and sshfs'
required: false
copyback:
description: 'whether or not to copy the build result repo back from the VM to the host Mac OS, defalt is True'
required: false
branding:
icon: 'activity'
color: 'green'

runs:
using: 'node16'
main: 'index.js'
1 change: 1 addition & 0 deletions conf/default.release.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_RELEASE=r151048
11 changes: 11 additions & 0 deletions conf/r151046.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

BUILDER_VERSION=0.0.1

CONF_LINK="https://raw.githubusercontent.com/vmactions/omnios-builder/v${BUILDER_VERSION}/conf/omnios-${VM_RELEASE}.conf"

OVA_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}.qcow2.xz"

VM_PUBID_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}-id_rsa.pub"

HOST_ID_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}-host.id_rsa"

11 changes: 11 additions & 0 deletions conf/r151048.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

BUILDER_VERSION=0.0.1

CONF_LINK="https://raw.githubusercontent.com/vmactions/omnios-builder/v${BUILDER_VERSION}/conf/omnios-${VM_RELEASE}.conf"

OVA_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}.qcow2.xz"

VM_PUBID_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}-id_rsa.pub"

HOST_ID_LINK="https://github.com/vmactions/omnios-builder/releases/download/v${BUILDER_VERSION}/omnios-${VM_RELEASE}-host.id_rsa"

Loading

0 comments on commit b024d4b

Please sign in to comment.