|
6 | 6 | pull_request: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - test: |
10 | | - name: Test |
| 9 | + format: |
| 10 | + name: Code Formatting |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 |
|
13 | 13 | steps: |
14 | 14 | - uses: actions/checkout@v4 |
15 | 15 | - uses: coursier/cache-action@v6 |
16 | 16 | - uses: VirtusLab/scala-cli-setup@main |
17 | | - with: |
18 | | - power: true |
19 | 17 |
|
20 | | - - name: Run tests |
21 | | - run: scala-cli test . |
| 18 | + - name: Check formatting |
| 19 | + run: scala-cli format --check . |
22 | 20 |
|
23 | | - format: |
24 | | - name: Format |
| 21 | + test: |
| 22 | + name: Unit Tests |
25 | 23 | runs-on: ubuntu-latest |
26 | 24 |
|
27 | 25 | steps: |
28 | 26 | - uses: actions/checkout@v4 |
29 | 27 | - uses: coursier/cache-action@v6 |
30 | 28 | - uses: VirtusLab/scala-cli-setup@main |
31 | | - with: |
32 | | - power: true |
33 | 29 |
|
34 | | - - name: Check formatting |
35 | | - run: scala-cli format --check . |
| 30 | + - name: Run unit tests |
| 31 | + run: scala-cli test . |
36 | 32 |
|
37 | | - examples: |
38 | | - name: Examples |
| 33 | + example: |
| 34 | + name: Integration Tests |
39 | 35 | runs-on: ubuntu-latest |
40 | 36 |
|
41 | 37 | steps: |
42 | 38 | - uses: actions/checkout@v4 |
43 | 39 | - uses: coursier/cache-action@v6 |
44 | 40 | - uses: VirtusLab/scala-cli-setup@main |
45 | | - with: |
46 | | - power: true |
47 | 41 |
|
48 | | - - name: Run Hello World |
49 | | - run: | |
50 | | - output=$(scala-cli run . -- "$(cat examples/helloworld.b)") |
51 | | - test "$output" = "Hello World!" |
52 | | - - name: Run Addition |
53 | | - run: | |
54 | | - output=$(scala-cli run . -- "$(cat examples/addition.b)") |
55 | | - test "$output" = "7" |
56 | | - - name: Run Bubble Sort |
| 42 | + - name: Run integration tests |
57 | 43 | run: | |
58 | | - output=$(echo -n "9c786a5412b" | scala-cli run . -- "$(cat examples/bubblesort.b)") |
59 | | - test "$output" = "12345678abc" |
60 | | - - name: Run ROT13 |
61 | | - run: | |
62 | | - output=$(echo -n "Uryyb, Jbeyq!" | scala-cli run . -- "$(cat examples/rot13.b)") |
63 | | - test "$output" = "Hello, World!" |
| 44 | + declare -A examples=( |
| 45 | + ["helloworld"]='Hello World!' |
| 46 | + ["addition"]='7' |
| 47 | + ['bubblesort:978365412']='123456789' |
| 48 | + ['bubblesort:aZefcYbdX']='XYZabcdef' |
| 49 | + ['rot13:Uryyb, Jbeyq!']='Hello, World!' |
| 50 | + ['rot13:Hello, World!']='Uryyb, Jbeyq!' |
| 51 | + ) |
| 52 | +
|
| 53 | + for example in "${!examples[@]}"; do |
| 54 | + name="$example" |
| 55 | + input="" |
| 56 | + expected="${examples[$example]}" |
| 57 | +
|
| 58 | + if [[ $example == *:* ]]; then |
| 59 | + name="${example%%:*}" |
| 60 | + input="${example##*:}" |
| 61 | + fi |
| 62 | +
|
| 63 | + echo "Running examples/$name.b $input" |
| 64 | + .github/test.sh "$name" "$expected" "$input" |
| 65 | + done |
0 commit comments