interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / .github / workflows / ci.yml

116 lines · 5869 bytes Raw Blame History
1name: tasks
2# Births omc from the 408-byte seed at the aien-dev/omega-mv commit in omega.ref on a GitHub-hosted
3# ubuntu-24.04-arm runner, compiles and runs every task and exercise, and runs negative controls
4# that must fail: a mutated expected.txt, a mutated task source, every exercise stub, a wrong
5# exercise solution, and every task's expected.txt mutated at once (each task and each oracle
6# comparison must catch its own).
7on:
8 push:
9 branches: [main]
10 pull_request:
11 workflow_dispatch:
12 schedule:
13 - cron: '41 6 * * 1'
14permissions:
15 contents: read
16jobs:
17 tasks:
18 runs-on: ubuntu-24.04-arm
19 timeout-minutes: 30
20 steps:
21 - uses: actions/checkout@v4
22 - name: Oracles reproduce every expected.txt
23 run: |
24 set -eu
25 python3 --version
26 for d in tasks/*/; do
27 n=$(basename "$d")
28 python3 "$d/oracle.py" > "$RUNNER_TEMP/oracle.out"
29 cmp "$RUNNER_TEMP/oracle.out" "$d/expected.txt" || { echo "oracle for $n disagrees with expected.txt"; exit 1; }
30 done
31 echo "every oracle reproduces its expected.txt"
32 - name: Tasks (must PASS), omc born from the seed
33 run: |
34 set -u
35 uname -srm
36 start=$(date +%s%3N)
37 rc=0; sh run.sh > "$RUNNER_TEMP/tasks.log" || rc=$?
38 echo "wall_ms $(( $(date +%s%3N) - start ))"
39 cat "$RUNNER_TEMP/tasks.log"
40 { echo '```'; cat "$RUNNER_TEMP/tasks.log"; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
41 [ "$rc" = 0 ] || { echo "run.sh exited $rc"; exit 1; }
42 total=$(ls -d tasks/*/ | wc -l)
43 grep -qx "TASKS PASS $total/$total" "$RUNNER_TEMP/tasks.log"
44 - name: Negative control 1, a mutated expected.txt (must FAIL)
45 run: |
46 set -u
47 t="$RUNNER_TEMP/neg1"; cp -r tasks "$t"
48 sed 's/^Buzz$/Bzzz/' tasks/fizzbuzz/expected.txt > "$t/fizzbuzz/expected.txt"
49 if cmp -s tasks/fizzbuzz/expected.txt "$t/fizzbuzz/expected.txt"; then echo "edit did nothing"; exit 1; fi
50 rc=0; sh run.sh --omc build/omega-mv/seed/out/omc --tasks "$t" > "$RUNNER_TEMP/neg1.log" || rc=$?
51 cat "$RUNNER_TEMP/neg1.log"
52 [ "$rc" = 1 ] || { echo "mutated expected.txt was not caught: rc=$rc"; exit 1; }
53 grep -qx 'FAIL fizzbuzz stdout differs from expected.txt' "$RUNNER_TEMP/neg1.log"
54 [ "$(grep -c '^FAIL ' "$RUNNER_TEMP/neg1.log")" = 1 ]
55 echo "negative control 1 failed as required (rc=$rc)"
56 - name: Negative control 2, a mutated task source (must FAIL)
57 run: |
58 set -u
59 t="$RUNNER_TEMP/neg2"; cp -r tasks "$t"
60 # 0xedb88320 is the reflected CRC-32 polynomial; flipping one bit must change the checksum.
61 sed 's/0xedb88320/0xedb88321/' tasks/crc-32/crc-32.om > "$t/crc-32/crc-32.om"
62 if cmp -s tasks/crc-32/crc-32.om "$t/crc-32/crc-32.om"; then echo "edit did nothing"; exit 1; fi
63 rc=0; sh run.sh --omc build/omega-mv/seed/out/omc --tasks "$t" > "$RUNNER_TEMP/neg2.log" || rc=$?
64 cat "$RUNNER_TEMP/neg2.log"
65 [ "$rc" = 1 ] || { echo "mutated source was not caught: rc=$rc"; exit 1; }
66 grep -q '^FAIL crc-32 ' "$RUNNER_TEMP/neg2.log"
67 echo "negative control 2 failed as required (rc=$rc)"
68 - name: Exercises, every example solution (must PASS)
69 run: |
70 set -eu
71 for d in exercises/*/; do sh exercise.sh "$d" "$d.meta/example.om"; done
72 - name: Negative control 3, every unsolved stub (must FAIL)
73 run: |
74 set -u
75 for d in exercises/*/; do
76 rc=0; sh exercise.sh "$d" > "$RUNNER_TEMP/stub.log" || rc=$?
77 cat "$RUNNER_TEMP/stub.log"
78 [ "$rc" = 1 ] || { echo "stub $d was not caught: rc=$rc"; exit 1; }
79 grep -q '^EXERCISE FAIL .* trap 13 ' "$RUNNER_TEMP/stub.log"
80 done
81 echo "negative control 3: every stub failed as required"
82 - name: Negative control 4, a wrong leap solution (must FAIL on the century cases)
83 run: |
84 set -u
85 sed '/^fn leap/,$d' exercises/leap/.meta/example.om > "$RUNNER_TEMP/wrong.om"
86 printf 'fn leap y ulong to bool\nret eq rem y 4 0\nend\n' >> "$RUNNER_TEMP/wrong.om"
87 rc=0; sh exercise.sh exercises/leap "$RUNNER_TEMP/wrong.om" > "$RUNNER_TEMP/wrong.log" || rc=$?
88 cat "$RUNNER_TEMP/wrong.log"
89 [ "$rc" = 1 ] || { echo "wrong solution was not caught: rc=$rc"; exit 1; }
90 grep -qx 'EXERCISE FAIL leap failed=3' "$RUNNER_TEMP/wrong.log"
91 echo "negative control 4 failed as required (rc=$rc)"
92 - name: Negative control 5, every expected.txt mutated (every task and every oracle check must FAIL)
93 run: |
94 set -u
95 t="$RUNNER_TEMP/neg5"; cp -r tasks "$t"
96 total=0
97 for d in "$t"/*/; do
98 n=$(basename "$d")
99 printf 'omega-rosetta negative control\n' >> "$d/expected.txt"
100 if python3 "tasks/$n/oracle.py" | cmp -s - "$d/expected.txt"; then echo "oracle check missed mutated $n"; exit 1; fi
101 total=$((total + 1))
102 done
103 rc=0; sh run.sh --omc build/omega-mv/seed/out/omc --tasks "$t" > "$RUNNER_TEMP/neg5.log" || rc=$?
104 cat "$RUNNER_TEMP/neg5.log"
105 [ "$rc" = 1 ] || { echo "mutated expected.txt files were not caught: rc=$rc"; exit 1; }
106 [ "$(grep -c '^FAIL .* stdout differs from expected.txt$' "$RUNNER_TEMP/neg5.log")" = "$total" ]
107 grep -qx "TASKS PASS 0/$total" "$RUNNER_TEMP/neg5.log"
108 echo "negative control 5: all $total mutated tasks failed as required (rc=$rc)"
109 - name: Keep the logs
110 if: always()
111 uses: actions/upload-artifact@v4
112 with:
113 name: tasks-logs
114 path: |
115 ${{ runner.temp }}/*.log
116 build/seed.log