Skip to content

Commit e192593

Browse files
authored
Unify test image creation logic (#9)
1 parent dd1b8e1 commit e192593

3 files changed

Lines changed: 18 additions & 20 deletions

File tree

.github/workflows/build.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@ jobs:
1313
name: Generate test ext4 image
1414
runs-on: ubuntu-latest
1515
steps:
16+
- name: Checkout the Git repository
17+
uses: actions/checkout@v4
1618
- name: Generate test.ext4
1719
shell: bash
1820
run: |
1921
set -e
20-
mkdir test
21-
echo "hello world" > test/test.txt
22-
for i in {1..100};do
23-
echo "hello world" >> test/test.txt
24-
done
25-
dd if=/dev/zero of=test.ext4.tmp count=1024 bs=1024
26-
mkfs.ext4 test.ext4.tmp -d test
27-
echo -n F > test.ext4
28-
cat test.ext4.tmp >> test.ext4
22+
./_test_image.sh
2923
- uses: actions/upload-artifact@v4
3024
with:
3125
name: test.ext4

_test_image.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
tmp_dir=$(mktemp -d)
5+
trap "rm -r \"$tmp_dir\"" EXIT
6+
echo "hello world" > "$tmp_dir"/test.txt
7+
for i in {1..100};do
8+
echo "hello world" >> "$tmp_dir"/test.txt
9+
done
10+
dd if=/dev/zero of=test.ext4.tmp count=1024 bs=1024
11+
mkfs.ext4 test.ext4.tmp -d "$tmp_dir"
12+
echo -n F > test.ext4
13+
cat test.ext4.tmp >> test.ext4

test.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,8 @@ python -m pip install wheel
1313
python -m pip install \
1414
--extra-index-url=https://wheels.eeems.codes/ \
1515
-r requirements.txt
16-
if ! [ -f test.ext4 ];then
17-
tmp_dir=$(mktemp -d)
18-
trap "rm -r \"$tmp_dir\"" EXIT
19-
echo "hello world" > "$tmp_dir"/test.txt
20-
for i in {1..100};do
21-
echo "hello world" >> "$tmp_dir"/test.txt
22-
done
16+
if ! [ -f test.ext4 ] || ! [ -f test.ext4.tmp ];then
17+
./_test_image.sh
2318
trap "rm -f test.ext4{,.tmp}" EXIT
24-
dd if=/dev/zero of=test.ext4.tmp count=1024 bs=1024
25-
mkfs.ext4 test.ext4.tmp -d "$tmp_dir"
26-
echo -n F > test.ext4
27-
cat test.ext4.tmp >> test.ext4
2819
fi
2920
python test.py

0 commit comments

Comments
 (0)