Skip to content

Commit

Permalink
improve CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreMarchand20 committed Dec 4, 2023
1 parent 8e1a625 commit 8321a47
Showing 16 changed files with 121 additions and 85 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -19,31 +19,28 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Set up Python package
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
python3 -m pip install --upgrade pip
python3 -m pip install .[test]
- name: Run regression tests
run: |
set enable-bracketed-paste off
pytest
- name: Check module imports with isort
run: |
python -m pip install isort
python -m isort . --check-only --diff
python3 -m pip install isort
python3 -m isort . --check-only --diff
# uses: isort/isort-action@master

- name: Check formatting with black
uses: psf/black@stable

- name: Check building a binary wheel and a source tarball
run: |
python -m pip install twine build --user
python -m build --sdist --wheel --outdir dist/ .
python -m twine check dist/*
python3 -m pip install twine build --user
python3 -m build --sdist --wheel --outdir dist/ .
python3 -m twine check dist/*
2 changes: 1 addition & 1 deletion examples/backward_search.sh
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ rm my_first_file.txt
#$ delay 500

#$ send touch
#$ expect second
#$ expect second_file.txt

#$ wait 1000

5 changes: 4 additions & 1 deletion examples/history.sh
Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@ rm my_first_file.txt

#$ delay 800

#$ sendarrow up 2
#$ sendarrow up 1
#$ expect rm my_first_file.txt

#$ sendarrow up 1
#$ expect touch my_second_file.txt

#$ sendarrow up
2 changes: 2 additions & 0 deletions examples/special_character.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

#$ expect \$
#$ sendcharacter #
This is a test with URL (https://github.com)
5 changes: 5 additions & 0 deletions tests/custom_rc_file_dumb_term
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export PS1="$ "
export HOME=~
export TERM=dumb
export PATH=/usr/bin:/usr/local/bin/
set enable-bracketed-paste off
5 changes: 5 additions & 0 deletions tests/custom_rc_file_xterm_term
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export PS1="$ "
export HOME=~
export TERM=xterm
export PATH=/usr/bin:/usr/local/bin/
set enable-bracketed-paste off
17 changes: 8 additions & 9 deletions tests/reference_output/asciinema_hello_world.cast
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[?2004h$ asciinema rec temp_test.cast \
[?2004l[?2004h> --overwrite \
[?2004l[?2004h> -c 'env -i PS1=$ bash --noprofile --norc' \
[?2004l[?2004h> -q
[?2004l$echo "Hello World"
$ asciinema rec temp_test.cast \
> --overwrite \
> -c 'env -i PS1=$ bash --noprofile --norc' \
> -q
$echo "Hello World"
Hello World
$exit
[?2004h$ asciinema play temp_test.cast
[?2004l$echo "Hello World"
$ asciinema play temp_test.cast
$echo "Hello World"
Hello World
$exit
[?2004h$ [?2004l
exit
$ exit
11 changes: 5 additions & 6 deletions tests/reference_output/autocompletion.cast
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[?2004h$ mkdir my_folder_with_a_very_long_name
[?2004l[?2004h$ cd my_folder_with_a_very_long_name/
[?2004l[?2004h$ basename $PWD
[?2004lmy_folder_with_a_very_long_name
[?2004h$ [?2004l
exit
$ mkdir my_folder_with_a_very_long_name
$ cd my_folder_with_a_very_long_name/
$ basename $PWD
my_folder_with_a_very_long_name
$ exit
19 changes: 11 additions & 8 deletions tests/reference_output/backward_search.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[?2004h$ touch my_first_file.txt
[?2004l[?2004h$ touch my_second_file.txt
[?2004l[?2004h$ rm my_first_file.txt
[?2004l[?2004h$ (reverse-i-search)`': t': rm my_first_file.txt(reverse-i-search)`to': touch my_second_file.txt[1@u': tou[1@c': touc[1@h': touchtouch my_first$ touch$
[?2004l[?2004h$ ls my_first_file.txt
[?2004lmy_first_file.txt
[?2004h$ [?2004l
exit
$ touch my_first_file.txt
$ touch my_second_file.txt
$ rm my_first_file.txt
$
(reverse-i-search)`': t': rm my_first_file.txt
(reverse-i-search)`to': touch my_second_file.txt[1@u': tou[1@c': touc[1@h': touchtouch my_first
$ touch
$
$ ls my_first_file.txt
my_first_file.txt
$ exit
27 changes: 13 additions & 14 deletions tests/reference_output/change_structure.cast
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[?2004h$ mkdir my_directory
[?2004l[?2004h$ cd my_directory
[?2004l[?2004h$ basename $PWD
[?2004lmy_directory
[?2004h$ touch my_textfile.txt
[?2004l[?2004h$ ls
[?2004lmy_textfile.txt
[?2004h$ rm my_textfile.txt
[?2004l[?2004h$ ls
[?2004l[?2004h$ cd ..
[?2004l[?2004h$ rm -r my_directory
[?2004l[?2004h$ ls
[?2004l[?2004h$ [?2004l
exit
$ mkdir my_directory
$ cd my_directory
$ basename $PWD
my_directory
$ touch my_textfile.txt
$ ls
my_textfile.txt
$ rm my_textfile.txt
$ ls
$ cd ..
$ rm -r my_directory
$ ls
$ exit
11 changes: 5 additions & 6 deletions tests/reference_output/escaped_command.cast
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[?2004h$ echo "Very" \
[?2004l[?2004h> "long" \
[?2004l[?2004h> "command"
[?2004lVery long command
[?2004h$ [?2004l
exit
$ echo "Very" \
> "long" \
> "command"
Very long command
$ exit
15 changes: 7 additions & 8 deletions tests/reference_output/hello_world.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[?2004h$ echo "Hello world"
[?2004lHello world
[?2004h$ echo "I have waited 1000ms"
[?2004lI have waited 1000ms
[?2004h$ echo "I am writing with a 10ms delay"
[?2004lI am writing with a 10ms delay
[?2004h$ [?2004l
exit
$ echo "Hello world"
Hello world
$ echo "I have waited 1000ms"
I have waited 1000ms
$ echo "I am writing with a 10ms delay"
I am writing with a 10ms delay
$ exit
17 changes: 9 additions & 8 deletions tests/reference_output/history.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[?2004h$ touch my_first_file.txt
[?2004l[?2004h$ touch my_second_file.txt
[?2004l[?2004h$ rm my_first_file.txt
[?2004l[?2004h$ rm my_first_file.txt$ [4@touch my_second_file.txt$ touch my_first_file.txt
[?2004l[?2004h$ ls
[?2004lmy_first_file.txt my_second_file.txt
[?2004h$ [?2004l
exit
$ touch my_first_file.txt
$ touch my_second_file.txt
$ rm my_first_file.txt
$ rm my_first_file.txt
$ [4@touch my_second_file.txt
$ touch my_first_file.txt
$ ls
my_first_file.txt my_second_file.txt
$ exit
34 changes: 25 additions & 9 deletions tests/reference_output/man_page.cast
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[?2004h$ man echo
[?2004l[?1049h[?1h=ECHO(1) User Commands ECHO(1)
$ man echo
[?1049h[?1h=
ECHO(1) User Commands ECHO(1)

NAME
echo - display a line of text
@@ -22,10 +23,25 @@
--version
output version information and exit

 Manual page echo(1) line 1 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 1 (press h for help or q to quit) If -e is in effect, the following sequences are recognized:
 Manual page echo(1) line 2 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 2 (press h for help or q to quit)
 Manual page echo(1) line 3 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 3 (press h for help or q to quit) \\ backslash
 Manual page echo(1) line 4 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 4 (press h for help or q to quit)
 Manual page echo(1) line 5 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 5 (press h for help or q to quit) \a alert (BEL)
 Manual page echo(1) line 6 (press h for help or q to quit)[?1l>[?1049l[?2004h$ [?2004l
exit
 Manual page echo(1) line 1 (press h for help or q to quit)
 ESCESC[[BB
 Manual page echo(1) line 1 (press h for help or q to quit)
 If -e is in effect, the following sequences are recognized:
 Manual page echo(1) line 2 (press h for help or q to quit)
 ESCESC[[BB
 Manual page echo(1) line 2 (press h for help or q to quit)

 Manual page echo(1) line 3 (press h for help or q to quit)
 ESCESC[[BB
 Manual page echo(1) line 3 (press h for help or q to quit)
 \\ backslash
 Manual page echo(1) line 4 (press h for help or q to quit)
 ESCESC[[BB
 Manual page echo(1) line 4 (press h for help or q to quit)

 Manual page echo(1) line 5 (press h for help or q to quit)
 ESCESC[[BB
 Manual page echo(1) line 5 (press h for help or q to quit)
 \a alert (BEL)
 Manual page echo(1) line 6 (press h for help or q to quit)
[?1l>[?1049l$ exit
5 changes: 2 additions & 3 deletions tests/reference_output/special_character.cast
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[?2004h$ #This is a test with URL (https://github.com)
[?2004l[?2004h$ [?2004l
exit
$ #This is a test with URL (https://github.com)
$ exit
12 changes: 11 additions & 1 deletion tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -28,14 +28,24 @@ def test_regression(tmp_path, request, inputfile: pathlib.Path):
reference_folder = (
request.config.invocation_params.dir / "tests" / "reference_output"
)
custom_rc_file = (
request.config.invocation_params.dir / "tests" / "custom_rc_file_dumb_term"
)
output_folder = tmp_path
output_file_name = inputfile.stem + ".cast"
print(pathlib.Path().cwd())
term: str = "dumb"
if inputfile.name in ["backward_search.sh", "history.sh", "man_page.sh"]:
custom_rc_file = (
request.config.invocation_params.dir / "tests" / "custom_rc_file_xterm_term"
)
cli(
[
"--debug",
"--asciinema-arguments",
"""--raw --overwrite -c 'env -i TERM=xterm-256color HOME=~ PS1="$ " PATH=/usr/bin:/usr/local/bin/ bash --noprofile --norc'""",
"""--raw --overwrite -c 'env -i bash --noprofile --rcfile """
+ str(custom_rc_file)
+ """'""",
str(example_folder / inputfile.name),
str(output_folder / output_file_name),
]

0 comments on commit 8321a47

Please sign in to comment.