-
Notifications
You must be signed in to change notification settings - Fork 1
178 lines (141 loc) · 6.15 KB
/
Copy pathtest-action.yml
File metadata and controls
178 lines (141 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: "Jython tests"
run-name: "Run Jython tests"
on:
push:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: "Test action"
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
jython_version:
- "2.7.3"
- "2.7.2"
- "2.7.1"
- "2.7.0"
- "2.5.3"
- "2.5.2"
- "2.5.1"
- "2.5.0"
- "2.2.1"
- "2.2"
- "2.1"
- "2.0"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Jython ${{ matrix.jython_version }}
uses: ./
with:
jython-version: "${{ matrix.jython_version }}"
- name: Environment check
shell: bash
run: |
VERTICAL_SEPARATOR="\x1b[0;35m|\x1b[0m";
HORIZONTAL_SEPARATOR="\x1b[0;36m----------------------------------------------------------------------------------------------------\x1b[0m";
printf "\033[0;33mEnvironment variables:\033[0m\n";
env | sed "s/^/ $VERTICAL_SEPARATOR /"
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mGithub PATH (GITHUB_PATH='%s'):\033[0m\n" "$GITHUB_PATH";
cat "$GITHUB_PATH" | sed "s/^/ $VERTICAL_SEPARATOR /"
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mInstallation folder content:\033[0m\n";
ls -la ~/jython/ | sed "s/^/ $VERTICAL_SEPARATOR /"
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mBinary files:\033[0m\n";
ls -la ~/.local/bin/ | sed "s/^/ $VERTICAL_SEPARATOR /"
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mBash script ('jython'):\033[0m\n";
if [ -f ~/.local/bin/jython ]; then
cat ~/.local/bin/jython | sed "s/^/ $VERTICAL_SEPARATOR /"
fi
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mBatch script ('jython.bat'):\033[0m\n";
if [ -f ~/.local/bin/jython.bat ]; then
cat ~/.local/bin/jython.bat | sed "s/^/ $VERTICAL_SEPARATOR /"
fi
printf -- "$HORIZONTAL_SEPARATOR\n\n"
printf "\033[0;33mPowershell script ('jython.ps1'):\033[0m\n";
if [ -f ~/.local/bin/jython.ps1 ]; then
cat ~/.local/bin/jython.ps1 | sed "s/^/ $VERTICAL_SEPARATOR /"
fi
- name: Run Jython (Bash)
shell: bash
run: |
set +e;
output="$(jython -c 'import sys, os; print(os.name, sys.version); print "\n\nJython Works!\n\n"')";
echo "$output";
echo "$output" | grep -q "Jython Works!";
- name: Run Jython (Bourne Shell)
shell: sh
run: |
set +e;
output="$(jython -c 'import sys, os; print(os.name, sys.version); print "\n\nJython Works!\n\n"')";
echo "$output";
echo "$output" | grep -q "Jython Works!";
- name: Run Jython (Batch)
if: runner.os == 'Windows'
shell: cmd
run: |
@rem ----------------------------------------------------------------------------------------------------
@rem WARNING: The commands may fail if not quoted with double quotes (") instead of single quotes (')
@rem
@rem The single quotes are not recognized by the Windows Command Prompt (cmd) and are treated
@rem as part of the command itself.
@rem
@rem This means that if there are spaces in the command, each word will be treated as a separate
@rem parameter and will fail.
@rem ----------------------------------------------------------------------------------------------------
SET "search_string=Jython Works!"
ECHO ----------------------------------------------------------------------------------------------------
ECHO The following command is expected to pass because of the double quotes:
CALL jython -c "import sys, os; print(os.name, sys.version); print '\n\nJython Works!\n\n'" > double_quotes.temp.out 2>&1
TYPE double_quotes.temp.out
findstr /C:"%search_string%" double_quotes.temp.out > NUL
if %errorlevel% NEQ 0 (
ECHO The command failed.
EXIT /B 9
)
ECHO ----------------------------------------------------------------------------------------------------
ECHO The following command is expected to fail because of the single quotes:
CALL jython -c 'import sys, os; print(os.name, sys.version); print "\n\nJython Works!\n\n"' > single_quotes.temp.out 2>&1
TYPE single_quotes.temp.out
@rem Exit with error code 10 if the command does NOT fail as expected
findstr /C:"%search_string%" single_quotes.temp.out > NUL
if %errorlevel% EQU 0 (
ECHO The command should have failed but it did not.
EXIT /B 10
)
ECHO ----------------------------------------------------------------------------------------------------
ECHO Tests passed successfully!
EXIT /B 0
- name: Run Jython (Powershell)
shell: pwsh
run: |
echo ----------------------------------------------------------------------------------------------------
echo "Command: 'jython'"
jython -c "import sys, os; print(os.name, sys.version); print '\n\nJython Works!\n\n'"
echo ----------------------------------------------------------------------------------------------------
echo "Command: 'jython.ps1'"
jython.ps1 -c "import sys, os; print(os.name, sys.version); print '\n\nJython Works!\n\n'"
echo ----------------------------------------------------------------------------------------------------
Describe JythonTest {
It 'verifies Jython works' {
$output = jython.ps1 -c "import sys, os; print(os.name, sys.version); print '\n\nJython Works!\n\n'"
$output | Select-String -Quiet -Pattern "Jython Works!" | Should -Be true
}
}