-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3bbcbad
Showing
11 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
extends: ["config:base"], | ||
|
||
labels: ["dependencies"], | ||
assignees: ["@mondeja"], | ||
schedule: "every 6 months on the first day of the month", | ||
separateMajorMinor: true, | ||
|
||
// Only automerge patchs | ||
packageRules: [ | ||
{ | ||
matchUpdateTypes: ["patch", "pin", "digest"], | ||
automerge: true, | ||
}, | ||
], | ||
|
||
// Security vulnerabilities should be fixed ASAP | ||
vulnerabilityAlerts: { | ||
addLabels: ["security"], | ||
schedule: "at any time", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Solaris (SunOS) tests | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: curl -sL https://mondeja.github.io/shread/unix/_/download/shunit2/en.sh | sudo bash - | ||
name: Download shunit2 | ||
- uses: mondeja/solaris-vm-action@v1 | ||
with: | ||
run: sh tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Update copyright years | ||
|
||
on: | ||
schedule: | ||
- cron: 0 3 2 1 * | ||
workflow_dispatch: | ||
|
||
jobs: | ||
action-update-license-year: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: FantasticFiasco/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.ova | ||
*.zip | ||
!/ova/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Zip | ||
|
||
```bash | ||
zip sol-11_4.zip sol-11_4.ova | ||
split --bytes=48MB sol-11_4.zip sol-11_4-part -d --additional-suffix=.zip | ||
``` | ||
|
||
### Unzip | ||
|
||
```bash | ||
cat sol-11_4-part* > sol-11_4.zip | ||
unzip sol-11_4.zip | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2021, Álvaro Mondéjar Rubio | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# solaris-vm-action | ||
|
||
[![Tests][tests-image]][tests-link] | ||
|
||
Run your workflow in a SunOS 11.4 virtual machine using VirtualBox. | ||
|
||
## Usage | ||
|
||
```yaml | ||
name: Run Solaris tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sun_tools-tests: | ||
name: Solaris (SunOS) tests | ||
runs-on: macos-latest | ||
steps: | ||
- uses: mondeja/solaris-vm-action@v1 | ||
with: | ||
memory: 2048 | ||
run: | | ||
sh build.sh | ||
sh test.sh | ||
``` | ||
|
||
## Arguments | ||
|
||
- ``run`` (*required*): Commands to run, in multiple lines. | ||
- ``cpus`` (1): Number of CPUs for the virtual machine. | ||
- ``memory`` (4096): RAM memory size for the virtual machine. | ||
|
||
|
||
[tests-image]: https://img.shields.io/github/workflow/status/mondeja/solaris-vm-action/CI?logo=github&label=tests | ||
[tests-link]: https://github.com/mondeja/solaris-vm-action/actions?query=workflow%3ACI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Solaris VM | ||
description: Run your workflow job on a Solaris VM | ||
author: mondeja | ||
inputs: | ||
run: | ||
description: Commands to run in the Solaris VM. | ||
required: true | ||
cpus: | ||
description: Number of CPUs for the machine (1 as default). | ||
required: false | ||
memory: | ||
description: RAM memory for the machine. | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- run: INPUT_COMMANDS="${{ inputs.run }}" INPUT_CPUS="${{ inputs.cpus }}" INPUT_MEMORY="${{ inputs.memory }}" sh {{ github.action_path }}/run.sh | ||
shell: sh | ||
|
||
branding: | ||
icon: 'box' | ||
color: 'red' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/sh | ||
|
||
MACHINE_IP="" | ||
|
||
if [ -z "$INPUT_CPUS" ]; then | ||
INPUT_CPUS=1 | ||
fi | ||
if [ -z "$INPUT_MEMORY" ]; then | ||
INPUT_MEMORY=4096 | ||
fi | ||
|
||
CURRENT_DIR_BASENAME="$(pwd | awk -F/ '{print $NF}')" | ||
|
||
set -ex | ||
|
||
clean_ova_parts() { | ||
rm -f sol-11_4-part*.zip | ||
} | ||
|
||
extract_ova_parts() { | ||
cat sol-11_4-part* > sol-11_4.zip | ||
unzip sol-11_4.zip | ||
rm -f sol-11_4.zip | ||
clean_ova_parts | ||
} | ||
|
||
download_ova_parts() { | ||
clean_ova_parts | ||
curl -Z \ | ||
--parallel-max 16 \ | ||
https://raw.githubusercontent.com/mondeja/solaris-vm-action-ova/master/ova/sol-11_4-part[00-78].zip \ | ||
-o 'sol-11_4-part#1.zip' | ||
} | ||
|
||
prepare_ova() { | ||
if [ ! -f "sol-11_4.ova" ]; then | ||
download_ova_parts | ||
extract_ova_parts | ||
fi | ||
} | ||
|
||
import_vm() { | ||
vboxmanage import sol-11_4.ova | ||
} | ||
|
||
modify_vm() { | ||
if [ "$INPUT_CPUS" -ne 1 ]; then | ||
vboxmanage modifyvm sol-11_4 --cpus "$INPUT_CPUS" | ||
fi | ||
if [ "$INPUT_MEMORY" -ne 4096 ]; then | ||
vboxmanage modifyvm sol-11_4 --mem "$INPUT_MEMORY" | ||
fi | ||
} | ||
|
||
run_vm() { | ||
vboxmanage startvm sol-11_4 --type headless | ||
} | ||
|
||
get_machine_ip() { | ||
vboxmanage guestproperty get sol-11_4 "/VirtualBox/GuestInfo/Net/0/V4/IP" \ | ||
| cut -d' ' -f2 | ||
} | ||
|
||
wait_for_dhcp_ip() { | ||
MACHINE_IP="$(get_machine_ip)" | ||
if [ "$(echo $MACHINE_IP | cut -d'.' -f1)" = "10" ]; then | ||
sleep 3 | ||
if [ "$1" -gt "200" ]; then | ||
printf "Error starting the Solaris VM after 10 minutes." >&2 | ||
printf " Timeout reached.\n" >&2 | ||
exit 1 | ||
else | ||
wait_for_dhcp_ip "$(( $1 + 1 ))" | ||
fi | ||
fi | ||
} | ||
|
||
sync_files() { | ||
sshpass -p "solaris" \ | ||
rsync \ | ||
--exclude _actions/mondeja/solaris-vm \ | ||
--exclude sol-11_4.ova \ | ||
-ae "ssh -p 22 -o StrictHostKeyChecking=no" \ | ||
$PWD \ | ||
solaris@$MACHINE_IP:/export/home/solaris | ||
} | ||
|
||
run_commands() { | ||
sshpass -p solaris ssh \ | ||
-o StrictHostKeyChecking=no solaris@$MACHINE_IP << EOF | ||
set -e | ||
cd /export/home/solaris/$CURRENT_DIR_BASENAME | ||
$INPUT_COMMANDS | ||
EOF | ||
} | ||
|
||
main() { | ||
prepare_ova | ||
import_vm | ||
modify_vm | ||
run_vm | ||
wait_for_dhcp_ip 1 | ||
sync_files | ||
run_commands | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
checkDependencies() { | ||
if [ "$(command -v "shunit2")" = "" ]; then | ||
printf "You need to install shunit2 or add it to PATH to run tests.\n" >&2 | ||
exit 1 | ||
fi; | ||
} | ||
|
||
testUname() { | ||
assertEquals "SunOS" "$(uname -a)" | ||
assertEquals "Solaris" "$(uname -o)" | ||
} | ||
|
||
main() { | ||
checkDependencies | ||
. shunit2 | ||
} | ||
|
||
main |