Skip to content

Commit b8e9229

Browse files
author
Andrew Kent
committed
fix windows CI, README improvements
1 parent 19cade1 commit b8e9229

File tree

4 files changed

+60
-26
lines changed

4 files changed

+60
-26
lines changed

.github/ci.sh

+2-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ retry() {
3838
}
3939

4040
setup_dist_bins() {
41-
if $IS_WIN; then
42-
is_exe "dist/bin" "saw" && return
43-
else
44-
is_exe "dist/bin" "saw" && is_exe "dist/bin" "saw-remote-api" && return
45-
extract_exe "saw-remote-api" "dist/bin"
46-
fi
41+
is_exe "dist/bin" "saw" && is_exe "dist/bin" "saw-remote-api" && return
42+
extract_exe "saw-remote-api" "dist/bin"
4743
extract_exe "saw" "dist/bin"
4844
export PATH=$PWD/dist/bin:$PATH
4945
echo "$PWD/dist/bin" >> "$GITHUB_PATH"

.github/workflows/build.yml

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ jobs:
113113
run: |
114114
saw-remote-api/scripts/run_rpc_tests.sh
115115
saw-remote-api/scripts/check_docs.sh
116-
if: runner.os != 'Windows'
117116
118117
- uses: actions/setup-java@v1
119118
with:

saw-remote-api/python/README.md

+49-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In-development Python client for SAW.
44

55
This SAW client depends on the [saw-remote-api](https://github.com/GaloisInc/saw-script/tree/master/saw-remote-api) server.
66

7-
## TL;DR Steps to running SAW Python scripts
7+
# TL;DR Steps to running SAW Python scripts
88

99
1. Clone the repo
1010
```
@@ -47,16 +47,21 @@ $ poetry run python tests/saw/test_salsa20.py
4747
subprocesses when run via `unittest` even though they pass and successfully
4848
verify the goals. It's on our to-do list.)
4949

50-
## Installation
50+
# Python Client Installation (via Poetry)
5151

52-
# Python environment
52+
First, clone the repository and submodules.
5353

54-
## Poetry
54+
```
55+
$ git clone https://github.com/GaloisInc/saw-script.git
56+
$ cd saw-script
57+
$ git submodule update --init
58+
```
5559

56-
First, [install `poetry`](https://python-poetry.org/docs/#installation) and then
57-
run in the `saw-remote-api/python` directory:
60+
Then, use [`poetry`](https://python-poetry.org/docs/#installation) to install
61+
the python client from the `saw-remote-api/python` directory:
5862

5963
```
64+
$ cd saw-remote-api/python
6065
$ poetry install
6166
```
6267

@@ -89,9 +94,11 @@ and reset it, ensuring states from previous scrips have been cleared. E.g.,
8994
`saw.connect(reset_server=True)`.
9095

9196

92-
## Selecting a SAW Server
97+
## Acquiring a SAW Server
9398

94-
## Server executables
99+
There are several ways a server executable can be obtained.
100+
101+
### Server executables
95102

96103
An executable of the server is included in the SAW release/nightly tarballs.
97104

@@ -138,17 +145,17 @@ container.)
138145
### Building from Source
139146

140147
If this repository is checked out and the build directions are successfully run,
141-
`cabal v2-which saw-remote-api` will indicate where the server executable has
142-
been stored.
148+
`cabal v2-exec which saw-remote-api` should indicate where the server executable has
149+
been stored by `cabal`.
143150

144151
Alternatively `cabal v2-install saw-remote-api` should install the server
145152
executable into the user's `~/.cabal/bin` directory (or similar), which (if
146-
configured properly) should then appear as `saw-remote-api` in a user's `PATH`,
153+
configured properly) should then appear as `saw-remote-api` in a user's `PATH`.
147154

148155

149156
# Running Python SAW verification scripts
150157

151-
Once the server is setup and any path variables are setup as necessary, the
158+
Once the server is setup and any path variables are setup as desired, the
152159
Python (>= v3.8) client can be installed using
153160
[`poetry`](https://python-poetry.org/docs/#installation) as follows:
154161

@@ -162,3 +169,33 @@ Then the tests or individual scripts can be run as follows:
162169
$ poetry run python -m unittest discover tests/saw
163170
$ poetry run python tests/saw/test_salsa20.py
164171
```
172+
173+
If leveraging environment variables is undesirable, the scripts themselves can
174+
specify a command to launch the server, e.g.:
175+
176+
```
177+
saw.connect(COMMAND)
178+
```
179+
180+
where `COMMAND` is a command to launch a new SAW server in socket mode.
181+
182+
Or a server URL can be specified directly in the script, e.g.:
183+
184+
```
185+
saw.connect(url=URL)
186+
```
187+
188+
where `URL` is a URL for a running SAW server in HTTP mode.
189+
190+
## Running Verification Scripts from a clean state
191+
192+
To ensure any previous server state is cleared when running a SAW Python script
193+
against a persistent server (e.g., one running in HTTP mode in a different process),
194+
the `reset_server` keyword can be passed to `saw.connect()`. E.g.,
195+
196+
```
197+
saw.connect(url="http://localhost:8080/", reset_server=True)
198+
```
199+
200+
will connect to a SAW server running at `http://localhost:8080/` and will
201+
guarantee any previous state on the server is cleared.

saw-remote-api/scripts/run_rpc_tests.sh

+9-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ function run_test {
1313
echo "Setting up python environment for remote server clients..."
1414
poetry install
1515

16+
# Ask cabal where the server is, and if that does work... check
17+
# the places CI will place the executable as a backup
1618
export SAW_SERVER=$(cabal v2-exec which saw-remote-api)
1719
if [[ -x "$SAW_SERVER" ]]; then
1820
echo "using saw-remote-api at $SAW_SERVER"
19-
else
20-
# try the dist/bin folder CI puts executables in
21+
elif [[ -x "$DIR/../../dist/bin/saw-remote-api" ]]; then
2122
export SAW_SERVER="$DIR/../../dist/bin/saw-remote-api"
22-
if [[ -x "$SAW_SERVER" ]]; then
2323
echo "using saw-remote-api at $SAW_SERVER"
24-
else
25-
echo "cabal could not locate saw-remote-api via the which command"
26-
exit 1
27-
fi
24+
elif [[ -x "$DIR/../../dist/bin/saw-remote-api.exe" ]]; then
25+
export SAW_SERVER="$DIR/../../dist/bin/saw-remote-api.exe"
26+
echo "using saw-remote-api at $SAW_SERVER"
27+
else
28+
echo "could not locate saw-remote-api executable"
29+
exit 1
2830
fi
2931

3032
echo "Running saw-remote-api tests..."

0 commit comments

Comments
 (0)