Skip to content

Commit

Permalink
root: added Nim Programming Language support
Browse files Browse the repository at this point in the history
Since we wanted Nim for a very long time, we should support it from
the get-go. Hence, let's do this.

This patch adds Nim Programming Language support into root
repository.

Co-authored-by: Galyna, Cory <[email protected]>
Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]>
Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
  • Loading branch information
hollowaykeanho and corygalyna committed Oct 16, 2023
1 parent 99b2fde commit 52055aa
Show file tree
Hide file tree
Showing 64 changed files with 4,502 additions and 105 deletions.
34 changes: 28 additions & 6 deletions CONFIG.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ PROJECT_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI"


######################
# GO TECHNOLOGY #
# NIM TECHNOLOGY #
######################
# PROJECT_GO
# PROJECT_NIM
# This is a control variable used for enabling Go technology and also defining
# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the
# offered service (e.g. GitHub Actions), setting this variable with value shall
# notify the CI provider to setup Go development environment automatically.
#
# To enable it: simply supply the path (e.g. default is 'srcGO').
# To disable it: simply supply an empty path (e.g. default is '').
PROJECT_GO = ''
PROJECT_NIM = 'srcNIM'


# PROJECT_PATH_GO_ENGINE
# PROJECT_PATH_NIM_ENGINE
# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for
# setting up localized environment.
PROJECT_PATH_GO_ENGINE = "go-engine"
PROJECT_PATH_NIM_ENGINE = "nim-engine"



Expand All @@ -126,7 +126,29 @@ PROJECT_PATH_GO_ENGINE = "go-engine"
#
# To enable it: simply supply the path (e.g. default is 'srcC').
# To disable it: simply supply an empty path (e.g. default is '').
PROJECT_C = 'srcC'
PROJECT_C = ''




######################
# GO TECHNOLOGY #
######################
# PROJECT_GO
# This is a control variable used for enabling Go technology and also defining
# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the
# offered service (e.g. GitHub Actions), setting this variable with value shall
# notify the CI provider to setup Go development environment automatically.
#
# To enable it: simply supply the path (e.g. default is 'srcGO').
# To disable it: simply supply an empty path (e.g. default is '').
PROJECT_GO = ''


# PROJECT_PATH_GO_ENGINE
# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for
# setting up localized environment.
PROJECT_PATH_GO_ENGINE = "go-engine"



Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some good business reasons why using AutomataCI:

### Supported Technologies

* Nim Programming Language (*Coming Soon*)
* [Nim Programming Language](https://nim-lang.org/)
* [Go Programming Language](https://go.dev/)
* C Programming Language
1. [i386 & amd64 GCC Compilers](https://gcc.gnu.org/)
Expand Down
18 changes: 18 additions & 0 deletions automataCI/_package-sourcing_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,21 @@ if [ ! -z "$PROJECT_C" ]; then
fi
fi
fi




# source from Nim and overrides existing
if [ ! -z "$PROJECT_NIM" ]; then
__recipe="${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}"
__recipe="${__recipe}/package_unix-any.sh"
FS::is_file "$__recipe"
if [ $? -eq 0 ]; then
OS::print_status info "sourcing Nim content assembling functions: ${__recipe}\n"
. "$__recipe"
if [ $? -ne 0 ]; then
OS::print_status error "Sourcing failed\n"
return 1
fi
fi
fi
18 changes: 18 additions & 0 deletions automataCI/_package-sourcing_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,21 @@ if (-not [string]::IsNullOrEmpty(${env:PROJECT_C})) {
}
}
}




# source from Nim and overrides existing
if (-not [string]::IsNullOrEmpty(${env:PROJECT_NIM})) {
$__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}"
$__recipe = "${__recipe}\package_windows-any.ps1"
$__process = FS-Is-File "${__recipe}"
if ($__process -eq 0) {
OS-Print-Status info "sourcing Nim content assembling functions: ${__recipe}"
$__process = . "${__recipe}"
if ($__process -ne 0) {
OS-Print-Status error "Source failed."
return
}
}
}
8 changes: 8 additions & 0 deletions automataCI/ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ if (Test-Path -Path "${env:PROJECT_PATH_ROOT}\SECRETS.toml" -PathType leaf) {



# update critical environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `
+ ";" `
+ [System.Environment]::GetEnvironmentVariable("Path","User")




# execute command
switch ($args[0]) {
{ $_ -in 'env', 'Env', 'ENV' } {
Expand Down
18 changes: 18 additions & 0 deletions automataCI/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ fi



# update environment variables
case "$PROJECT_OS" in
linux)
__location="/home/linuxbrew/.linuxbrew/bin/brew"
;;
darwin)
__location="/usr/local/bin/brew"
;;
*)
;;
esac
if [ -f "$__location" ]; then
eval "$("${__location}" shellenv)"
fi




# execute command
case "$1" in
env|Env|ENV)
Expand Down
18 changes: 18 additions & 0 deletions automataCI/common_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ fi



# execute NIM if set
if [ ! -z "$PROJECT_NIM" ]; then
__recipe="$(STRINGS::to_lowercase "$PROJECT_CI_JOB")_unix-any.sh"
__recipe="${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/${__recipe}"
FS::is_file "$__recipe"
if [ $? -eq 0 ]; then
OS::print_status info "NIM tech detected. Parsing job recipe: ${__recipe}\n"
. "$__recipe"
if [ $? -ne 0 ]; then
OS::print_status error "Parse failed.\n"
return 1
fi
fi
fi




# execute baseline as last
__recipe="$(STRINGS::to_lowercase "$PROJECT_CI_JOB")_unix-any.sh"
__recipe="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/${__recipe}"
Expand Down
18 changes: 18 additions & 0 deletions automataCI/common_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ if (-not [string]::IsNullOrEmpty(${env:PROJECT_C})) {



# execute NIM if set
if (-not [string]::IsNullOrEmpty(${env:PROJECT_NIM})) {
$__recipe = STRINGS-To-Lowercase "${env:PROJECT_CI_JOB}_windows-any.ps1"
$__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\${__recipe}"
$__process = FS-Is-File "${__recipe}"
if ($__process -eq 0) {
OS-Print-Status info "NIM tech detected. Parsing job recipe: ${__recipe}"
$__process = . $__recipe
if ($__process -ne 0) {
OS-Print-Status error "Parse failed."
return 1
}
}
}




# execute baseline as last
$__recipe = STRINGS-To-Lowercase "${env:PROJECT_CI_JOB}_windows-any.ps1"
$__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\${__recipe}"
Expand Down
Binary file modified automataCI/docs/AutomataCI-Engineering-Specification.odt
Binary file not shown.
Binary file modified automataCI/docs/AutomataCI-Engineering-Specification.pdf
Binary file not shown.
12 changes: 11 additions & 1 deletion automataCI/env_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if [ ! -z "$PROJECT_GO" ]; then
fi


if [ ! -z "$PROJECT_C" ]; then
if [ ! -z "$PROJECT_C" ] || [ ! -z "$PROJECT_NIM" ]; then
OS::print_status info "Installing c...\n"
INSTALLER::setup_c "$PROJECT_OS" "$PROJECT_ARCH"
if [ $? -ne 0 ]; then
Expand All @@ -89,6 +89,16 @@ if [ ! -z "$PROJECT_C" ]; then
fi


if [ ! -z "$PROJECT_NIM" ]; then
OS::print_status info "Installing nim...\n"
INSTALLER::setup_nim "$PROJECT_OS" "$PROJECT_ARCH"
if [ $? -ne 0 ]; then
OS::print_status error "install failed.\n"
return 1
fi
fi




# report status
Expand Down
16 changes: 15 additions & 1 deletion automataCI/env_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (-not ([string]::IsNullOrEmpty(${env:PROJECT_PYTHON}))) {
OS-Print-Status info "Installing python..."
$__process = INSTALLER-Setup-Python
if ($__process -ne 0) {
OS-Print-Status error "install failed."
return 1
}
}
Expand All @@ -71,15 +72,28 @@ if (-not ([string]::IsNullOrEmpty(${env:PROJECT_GO}))) {
OS-Print-Status info "Installing go..."
$__process = INSTALLER-Setup-Go
if ($__process -ne 0) {
OS-Print-Status error "install failed."
return 1
}
}


if (-not ([string]::IsNullOrEmpty(${env:PROJECT_C}))) {
if (-not ([string]::IsNullOrEmpty(${env:PROJECT_C})) -or
-not ([string]::IsNullOrEmpty(${env:PROJECT_NIM}))) {
OS-Print-Status info "Installing c..."
$__process = INSTALLER-Setup-C
if ($__process -ne 0) {
OS-Print-Status error "install failed."
return 1
}
}


if (-not ([string]::IsNullOrEmpty(${env:PROJECT_NIM}))) {
OS-Print-Status info "Installing nim..."
$__process = INSTALLER-Setup-Nim
if ($__process -ne 0) {
OS-Print-Status error "install failed."
return 1
}
}
Expand Down
Loading

0 comments on commit 52055aa

Please sign in to comment.