plain-forge 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +247 -0
- package/bin/cli.mjs +143 -0
- package/forge/docs/.gitkeep +0 -0
- package/forge/rules/definitions.md +57 -0
- package/forge/rules/exported-concepts.md +39 -0
- package/forge/rules/func-specs.md +72 -0
- package/forge/rules/impl-reqs.md +50 -0
- package/forge/rules/import-modules.md +51 -0
- package/forge/rules/required-concepts.md +45 -0
- package/forge/rules/requires-modules.md +59 -0
- package/forge/rules/test-reqs.md +47 -0
- package/forge/skills/add-acceptance-test/SKILL.md +98 -0
- package/forge/skills/add-concept/SKILL.md +67 -0
- package/forge/skills/add-feature/SKILL.md +136 -0
- package/forge/skills/add-functional-spec/SKILL.md +81 -0
- package/forge/skills/add-functional-specs/SKILL.md +115 -0
- package/forge/skills/add-implementation-requirement/SKILL.md +73 -0
- package/forge/skills/add-resource/SKILL.md +108 -0
- package/forge/skills/add-template/SKILL.md +65 -0
- package/forge/skills/add-test-requirement/SKILL.md +68 -0
- package/forge/skills/analyze-2-func-specs/SKILL.md +102 -0
- package/forge/skills/analyze-func-specs/SKILL.md +124 -0
- package/forge/skills/analyze-if-func-spec-too-complex/SKILL.md +152 -0
- package/forge/skills/break-down-func-spec/SKILL.md +156 -0
- package/forge/skills/check-plain-env/SKILL.md +288 -0
- package/forge/skills/consolidate-concepts/SKILL.md +193 -0
- package/forge/skills/create-import-module/SKILL.md +98 -0
- package/forge/skills/create-requires-module/SKILL.md +104 -0
- package/forge/skills/debug-specs/SKILL.md +189 -0
- package/forge/skills/forge-integration/SKILL.md +443 -0
- package/forge/skills/forge-plain/SKILL.md +333 -0
- package/forge/skills/implement-conformance-testing-script/SKILL.md +247 -0
- package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_cypress.ps1 +324 -0
- package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_golang.ps1 +100 -0
- package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +102 -0
- package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.ps1 +92 -0
- package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +100 -0
- package/forge/skills/implement-prepare-environment-script/SKILL.md +242 -0
- package/forge/skills/implement-prepare-environment-script/assets/prepare_environment_java.sh +42 -0
- package/forge/skills/implement-prepare-environment-script/assets/prepare_environment_python.sh +81 -0
- package/forge/skills/implement-unit-testing-script/SKILL.md +133 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_flutter.ps1 +82 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_golang.ps1 +68 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_java.sh +45 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_python.ps1 +76 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_python.sh +90 -0
- package/forge/skills/implement-unit-testing-script/assets/run_unittests_react.ps1 +83 -0
- package/forge/skills/init-config-file/SKILL.md +261 -0
- package/forge/skills/init-plain-project/SKILL.md +124 -0
- package/forge/skills/load-plain-reference/SKILL.md +646 -0
- package/forge/skills/plain-healthcheck/SKILL.md +132 -0
- package/forge/skills/refactor-module/SKILL.md +197 -0
- package/forge/skills/resolve-spec-conflict/SKILL.md +88 -0
- package/forge/skills/run-codeplain/SKILL.md +540 -0
- package/package.json +42 -0
package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_golang.ps1
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
|
|
3
|
+
$ErrorActionPreference = 'Stop'
|
|
4
|
+
|
|
5
|
+
$UNRECOVERABLE_ERROR_EXIT_CODE = 69
|
|
6
|
+
|
|
7
|
+
# Check if build folder name is provided
|
|
8
|
+
if (-not $args[0]) {
|
|
9
|
+
Write-Host "Error: No build folder name provided."
|
|
10
|
+
Write-Host "Usage: $($MyInvocation.MyCommand.Name) <build_folder_name> <conformance_tests_folder>"
|
|
11
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Check if conformance tests folder name is provided
|
|
15
|
+
if (-not $args[1]) {
|
|
16
|
+
Write-Host "Error: No conformance tests folder name provided."
|
|
17
|
+
Write-Host "Usage: $($MyInvocation.MyCommand.Name) <build_folder_name> <conformance_tests_folder>"
|
|
18
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$BuildFolder = $args[0]
|
|
22
|
+
$ConformanceTestsFolder = $args[1]
|
|
23
|
+
|
|
24
|
+
$current_dir = Get-Location
|
|
25
|
+
|
|
26
|
+
$GO_BUILD_SUBFOLDER = "go_$BuildFolder"
|
|
27
|
+
|
|
28
|
+
if ($env:VERBOSE -eq "1") {
|
|
29
|
+
Write-Host "Preparing Go build subfolder: $GO_BUILD_SUBFOLDER"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Check if the go build subfolder exists
|
|
33
|
+
if (Test-Path $GO_BUILD_SUBFOLDER) {
|
|
34
|
+
# Delete all files and folders inside
|
|
35
|
+
Get-ChildItem -Path $GO_BUILD_SUBFOLDER -Force | Remove-Item -Recurse -Force
|
|
36
|
+
|
|
37
|
+
if ($env:VERBOSE -eq "1") {
|
|
38
|
+
Write-Host "Cleanup completed."
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
if ($env:VERBOSE -eq "1") {
|
|
42
|
+
Write-Host "Subfolder does not exist. Creating it..."
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
New-Item -ItemType Directory -Path $GO_BUILD_SUBFOLDER -Force | Out-Null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Copy-Item -Path "$BuildFolder/*" -Destination $GO_BUILD_SUBFOLDER -Recurse -Force
|
|
49
|
+
|
|
50
|
+
# Move to the subfolder
|
|
51
|
+
if (-not (Test-Path $GO_BUILD_SUBFOLDER)) {
|
|
52
|
+
Write-Host "Error: Go build folder '$GO_BUILD_SUBFOLDER' does not exist."
|
|
53
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Push-Location $GO_BUILD_SUBFOLDER
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
Write-Host "Runinng go get in the build folder..."
|
|
60
|
+
go get
|
|
61
|
+
|
|
62
|
+
# Move to conformance tests folder
|
|
63
|
+
Set-Location "$current_dir/$ConformanceTestsFolder"
|
|
64
|
+
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
|
|
65
|
+
Write-Host "Error: Conformance tests folder '$current_dir/$ConformanceTestsFolder' does not exist."
|
|
66
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Write-Host "Checking for go.mod in conformance test directory..."
|
|
70
|
+
if (Test-Path "go.mod") {
|
|
71
|
+
Write-Host "Running go get in conformance test directory..."
|
|
72
|
+
go get
|
|
73
|
+
} else {
|
|
74
|
+
Write-Host "No go.mod found in conformance test directory, skipping go get"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# Move back to build directory
|
|
78
|
+
Set-Location "$current_dir/$GO_BUILD_SUBFOLDER"
|
|
79
|
+
|
|
80
|
+
# Execute Go lang conformance tests
|
|
81
|
+
Write-Host "Running Golang conformance tests...`n"
|
|
82
|
+
|
|
83
|
+
# Temporarily allow stderr output without throwing (Go may write to stderr)
|
|
84
|
+
# ForEach-Object converts ErrorRecord objects (from stderr) to plain strings to avoid verbose error formatting
|
|
85
|
+
$ErrorActionPreference = 'Continue'
|
|
86
|
+
$output = go run "$current_dir/$ConformanceTestsFolder/conformance_tests.go" 2>&1 | ForEach-Object { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.Exception.Message } else { $_ } } | Out-String
|
|
87
|
+
$exit_code = $LASTEXITCODE
|
|
88
|
+
$ErrorActionPreference = 'Stop'
|
|
89
|
+
|
|
90
|
+
# If there was an error, print the output and exit with the error code
|
|
91
|
+
if ($exit_code -ne 0) {
|
|
92
|
+
Write-Host $output
|
|
93
|
+
exit $exit_code
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Exit with the exit code of the test command
|
|
97
|
+
exit $exit_code
|
|
98
|
+
} finally {
|
|
99
|
+
Pop-Location
|
|
100
|
+
}
|
package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
|
|
3
|
+
java --version
|
|
4
|
+
|
|
5
|
+
# Check if build folder name is provided
|
|
6
|
+
if [ -z "$1" ]; then
|
|
7
|
+
printf "Error: No build folder name provided.\n"
|
|
8
|
+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
# Check if conformance tests folder name is provided
|
|
13
|
+
if [ -z "$2" ]; then
|
|
14
|
+
printf "Error: No conformance tests folder name provided.\n"
|
|
15
|
+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
current_dir=$(pwd)
|
|
20
|
+
printf "Current directory: $current_dir\n"
|
|
21
|
+
|
|
22
|
+
tree $2
|
|
23
|
+
|
|
24
|
+
JAVA_BUILD_SUBFOLDER=,tmp/$1
|
|
25
|
+
|
|
26
|
+
if [ "${VERBOSE:-}" -eq 1 ] 2>/dev/null; then
|
|
27
|
+
printf "Preparing Java build subfolder: $JAVA_BUILD_SUBFOLDER\n"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
rm -rf $JAVA_BUILD_SUBFOLDER
|
|
31
|
+
mkdir -p $JAVA_BUILD_SUBFOLDER
|
|
32
|
+
|
|
33
|
+
cp -R $1/* $JAVA_BUILD_SUBFOLDER
|
|
34
|
+
printf "Copied from $1 to $JAVA_BUILD_SUBFOLDER...\n"
|
|
35
|
+
|
|
36
|
+
# Move to the subfolder
|
|
37
|
+
cd "$JAVA_BUILD_SUBFOLDER" 2>/dev/null
|
|
38
|
+
printf "Moved to $JAVA_BUILD_SUBFOLDER...\n"
|
|
39
|
+
|
|
40
|
+
if [ $? -ne 0 ]; then
|
|
41
|
+
printf "Error: Java build folder '$JAVA_BUILD_SUBFOLDER' does not exist.\n"
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "Runinng maven install in $(pwd)..."
|
|
46
|
+
output=$(mvn clean install -DskipTests 2>&1)
|
|
47
|
+
exit_code=$?
|
|
48
|
+
|
|
49
|
+
# If there was an error, print the output and exit with the error code
|
|
50
|
+
if [ $exit_code -ne 0 ]; then
|
|
51
|
+
echo "Command failed: mvn clean install -DskipTests"
|
|
52
|
+
echo "Error: Running maven build failed with exit code $exit_code"
|
|
53
|
+
echo "Output: $output"
|
|
54
|
+
exit $exit_code
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
CONFORMANCE_TESTS_FOLDER=.tmp/java_conformance
|
|
58
|
+
|
|
59
|
+
cd "$current_dir" 2>/dev/null
|
|
60
|
+
printf "Moved to $current_dir...\n"
|
|
61
|
+
printf "Preparing Java conformance tests subfolder: $CONFORMANCE_TESTS_FOLDER\n"
|
|
62
|
+
|
|
63
|
+
rm -rf $CONFORMANCE_TESTS_FOLDER
|
|
64
|
+
mkdir -p $CONFORMANCE_TESTS_FOLDER
|
|
65
|
+
|
|
66
|
+
cp -R $2/* $CONFORMANCE_TESTS_FOLDER
|
|
67
|
+
printf "Copied from $2 to $CONFORMANCE_TESTS_FOLDER...\n"
|
|
68
|
+
|
|
69
|
+
# Move to the subfolder
|
|
70
|
+
cd "$CONFORMANCE_TESTS_FOLDER" 2>/dev/null
|
|
71
|
+
printf "Moved to $CONFORMANCE_TESTS_FOLDER...\n"
|
|
72
|
+
|
|
73
|
+
if [ $? -ne 0 ]; then
|
|
74
|
+
printf "Error: Java conformance tests folder '$CONFORMANCE_TESTS_FOLDER' does not exist.\n"
|
|
75
|
+
exit 2
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "Runinng maven install in $(pwd)..."
|
|
79
|
+
output=$(mvn clean install -DskipTests 2>&1)
|
|
80
|
+
exit_code=$?
|
|
81
|
+
|
|
82
|
+
# If there was an error, print the output and exit with the error code
|
|
83
|
+
if [ $exit_code -ne 0 ]; then
|
|
84
|
+
echo "Command failed: mvn clean install -DskipTests"
|
|
85
|
+
echo "Error: Running maven build failed with exit code $exit_code"
|
|
86
|
+
echo "Output: $output"
|
|
87
|
+
exit $exit_code
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# Execute all Java unittests in the subfolder
|
|
91
|
+
echo "Running Java unittests in $(pwd)..."
|
|
92
|
+
output=$(mvn test 2>&1)
|
|
93
|
+
exit_code=$?
|
|
94
|
+
|
|
95
|
+
# If there was an error, print the output and exit with the error code
|
|
96
|
+
if [ $exit_code -ne 0 ]; then
|
|
97
|
+
echo "$output"
|
|
98
|
+
exit $exit_code
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# Echo the original exit code of the unittest command
|
|
102
|
+
exit $exit_code
|
package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.ps1
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
|
|
3
|
+
$ErrorActionPreference = 'Stop'
|
|
4
|
+
|
|
5
|
+
$UNRECOVERABLE_ERROR_EXIT_CODE = 69
|
|
6
|
+
|
|
7
|
+
# Check if build folder name is provided
|
|
8
|
+
if (-not $args[0]) {
|
|
9
|
+
Write-Host "Error: No build folder name provided."
|
|
10
|
+
Write-Host "Usage: $($MyInvocation.MyCommand.Name) <build_folder_name> <conformance_tests_folder>"
|
|
11
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Check if conformance tests folder name is provided
|
|
15
|
+
if (-not $args[1]) {
|
|
16
|
+
Write-Host "Error: No conformance tests folder name provided."
|
|
17
|
+
Write-Host "Usage: $($MyInvocation.MyCommand.Name) <build_folder_name> <conformance_tests_folder>"
|
|
18
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$BuildFolder = $args[0]
|
|
22
|
+
$ConformanceTestsFolder = $args[1]
|
|
23
|
+
|
|
24
|
+
# Try to find Python interpreter (python3 first, then python)
|
|
25
|
+
if (Get-Command python3 -ErrorAction SilentlyContinue) {
|
|
26
|
+
$PYTHON_CMD = "python3"
|
|
27
|
+
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
|
|
28
|
+
$PYTHON_CMD = "python"
|
|
29
|
+
} else {
|
|
30
|
+
Write-Host "Error: Python interpreter not found. Please install Python."
|
|
31
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$current_dir = Get-Location
|
|
35
|
+
|
|
36
|
+
$PYTHON_BUILD_SUBFOLDER = "python_$BuildFolder"
|
|
37
|
+
|
|
38
|
+
if ($env:VERBOSE -eq "1") {
|
|
39
|
+
Write-Host "Preparing Python build subfolder: $PYTHON_BUILD_SUBFOLDER"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Check if the Python build subfolder exists
|
|
43
|
+
if (Test-Path $PYTHON_BUILD_SUBFOLDER) {
|
|
44
|
+
# Delete all files and folders inside
|
|
45
|
+
Get-ChildItem -Path $PYTHON_BUILD_SUBFOLDER -Force | Remove-Item -Recurse -Force
|
|
46
|
+
|
|
47
|
+
if ($env:VERBOSE -eq "1") {
|
|
48
|
+
Write-Host "Cleanup completed."
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
if ($env:VERBOSE -eq "1") {
|
|
52
|
+
Write-Host "Subfolder does not exist. Creating it..."
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
New-Item -ItemType Directory -Path $PYTHON_BUILD_SUBFOLDER -Force | Out-Null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Copy-Item -Path "$BuildFolder/*" -Destination $PYTHON_BUILD_SUBFOLDER -Recurse -Force
|
|
59
|
+
|
|
60
|
+
# Move to the subfolder
|
|
61
|
+
if (-not (Test-Path $PYTHON_BUILD_SUBFOLDER)) {
|
|
62
|
+
Write-Host "Error: Python build folder '$PYTHON_BUILD_SUBFOLDER' does not exist."
|
|
63
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Push-Location $PYTHON_BUILD_SUBFOLDER
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
# Execute all Python conformance tests in the build folder
|
|
70
|
+
Write-Host "Running Python conformance tests...`n"
|
|
71
|
+
|
|
72
|
+
# Temporarily allow stderr output without throwing (Python unittest writes progress to stderr)
|
|
73
|
+
# ForEach-Object converts ErrorRecord objects (from stderr) to plain strings to avoid verbose error formatting
|
|
74
|
+
$ErrorActionPreference = 'Continue'
|
|
75
|
+
$output = & $PYTHON_CMD -m unittest discover -b -s "$current_dir/$ConformanceTestsFolder" 2>&1 | ForEach-Object { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.Exception.Message } else { $_ } } | Out-String
|
|
76
|
+
$exit_code = $LASTEXITCODE
|
|
77
|
+
$ErrorActionPreference = 'Stop'
|
|
78
|
+
|
|
79
|
+
# Echo the original output
|
|
80
|
+
Write-Host $output
|
|
81
|
+
|
|
82
|
+
# Check if no tests were discovered
|
|
83
|
+
if ($output -match "Ran 0 tests in") {
|
|
84
|
+
Write-Host "`nError: No unittests discovered."
|
|
85
|
+
exit 1
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Exit with the exit code of the unittest command
|
|
89
|
+
exit $exit_code
|
|
90
|
+
} finally {
|
|
91
|
+
Pop-Location
|
|
92
|
+
}
|
package/forge/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
UNRECOVERABLE_ERROR_EXIT_CODE=69
|
|
4
|
+
|
|
5
|
+
# Check if build folder name is provided
|
|
6
|
+
if [ -z "$1" ]; then
|
|
7
|
+
printf "Error: No build folder name provided.\n"
|
|
8
|
+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
|
|
9
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
# Check if conformance tests folder name is provided
|
|
13
|
+
if [ -z "$2" ]; then
|
|
14
|
+
printf "Error: No conformance tests folder name provided.\n"
|
|
15
|
+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
|
|
16
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Try to find Python interpreter (python3 first, then python)
|
|
20
|
+
if command -v python3 &> /dev/null; then
|
|
21
|
+
PYTHON_CMD="python3"
|
|
22
|
+
elif command -v python &> /dev/null; then
|
|
23
|
+
PYTHON_CMD="python"
|
|
24
|
+
else
|
|
25
|
+
printf "Error: Python interpreter not found. Please install Python.\n"
|
|
26
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
current_dir=$(pwd)
|
|
30
|
+
|
|
31
|
+
PYTHON_BUILD_SUBFOLDER=".tmp/$1"
|
|
32
|
+
|
|
33
|
+
if [ "${VERBOSE:-}" -eq 1 ] 2>/dev/null; then
|
|
34
|
+
printf "Preparing Python build subfolder: $PYTHON_BUILD_SUBFOLDER\n"
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
rm -rf $PYTHON_BUILD_SUBFOLDER
|
|
38
|
+
mkdir -p $PYTHON_BUILD_SUBFOLDER
|
|
39
|
+
|
|
40
|
+
cp -R $1/* $PYTHON_BUILD_SUBFOLDER
|
|
41
|
+
|
|
42
|
+
# Move to the subfolder
|
|
43
|
+
cd "$PYTHON_BUILD_SUBFOLDER" 2>/dev/null
|
|
44
|
+
|
|
45
|
+
if [ $? -ne 0 ]; then
|
|
46
|
+
printf "Error: Python build folder '$PYTHON_BUILD_SUBFOLDER' does not exist.\n"
|
|
47
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
printf "Creating and activating virtual environment...\n"
|
|
51
|
+
|
|
52
|
+
# Time the virtual environment creation and activation
|
|
53
|
+
start_time=$(date +%s.%N)
|
|
54
|
+
|
|
55
|
+
VENV_DIR=".venv"
|
|
56
|
+
|
|
57
|
+
if ! $PYTHON_CMD -m venv "$VENV_DIR"; then
|
|
58
|
+
printf "Error: Failed to create virtual environment in '$VENV_DIR'.\n"
|
|
59
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# shellcheck disable=SC1091
|
|
63
|
+
source "$VENV_DIR/bin/activate"
|
|
64
|
+
|
|
65
|
+
if [ $? -ne 0 ]; then
|
|
66
|
+
printf "Error: Failed to activate virtual environment at '$VENV_DIR/bin/activate'.\n"
|
|
67
|
+
exit $UNRECOVERABLE_ERROR_EXIT_CODE
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Install requirements if requirements.txt exists
|
|
71
|
+
if [ -f "requirements.txt" ]; then
|
|
72
|
+
pip install --upgrade pip
|
|
73
|
+
pip install -r requirements.txt
|
|
74
|
+
else
|
|
75
|
+
echo "Warning: requirements.txt not found. Cannot proceed with setting up requirements. The requirements may also already be installed"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
end_time=$(date +%s.%N)
|
|
79
|
+
|
|
80
|
+
# Calculate and display the time taken
|
|
81
|
+
duration=$(echo "$end_time - $start_time" | bc)
|
|
82
|
+
printf "Requirements setup completed in %.2f seconds\n\n" "$duration"
|
|
83
|
+
|
|
84
|
+
# Execute all Python conformance tests in the build folder
|
|
85
|
+
printf "Running Python conformance tests...\n\n"
|
|
86
|
+
|
|
87
|
+
output=$($PYTHON_CMD -m unittest discover -b -s "$current_dir/$2" 2>&1)
|
|
88
|
+
exit_code=$?
|
|
89
|
+
|
|
90
|
+
# Echo the original output
|
|
91
|
+
echo "$output"
|
|
92
|
+
|
|
93
|
+
# Check if no tests were discovered
|
|
94
|
+
if echo "$output" | grep -q "Ran 0 tests in"; then
|
|
95
|
+
printf "\nError: No unittests discovered.\n"
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Echo the original exit code of the unittest command
|
|
100
|
+
exit $exit_code
|