interplane.Get Omega
Read in your language

vscode-omega

aien-dev/vscode-omega

Brought by drakestapleton

branch main Branches Tags History

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

148 lines · 7921 bytes Raw Blame History
1name: extension
2# Tests omc.js, the snippets and the extension inside VS Code against omc born from the 408-byte seed of aien-dev/omega-mv at
3# omega.ref, measures token agreement between the TextMate grammar and aien-dev/tree-sitter-omega at
4# tree-sitter-omega.ref over every omega-mv *.om file, packages the .vsix with vsce, and on a v* tag
5# publishes it with its sha256 as a GitHub Release. Four negative controls must fail.
6on:
7 push:
8 branches: [main]
9 tags: ['v*']
10 pull_request:
11 workflow_dispatch:
12permissions:
13 contents: read
14jobs:
15 extension:
16 runs-on: ubuntu-24.04-arm
17 timeout-minutes: 25
18 steps:
19 - uses: actions/checkout@v4
20 - uses: actions/setup-node@v4
21 with:
22 node-version: '24'
23 - run: npm ci
24 - name: Clone omega-mv at omega.ref and birth omc from the seed
25 run: |
26 set -eu
27 ref=$(awk '$1=="commit"{print $2}' omega.ref)
28 git clone --no-checkout https://github.com/aien-dev/omega-mv "$RUNNER_TEMP/omega-mv"
29 cd "$RUNNER_TEMP/omega-mv"
30 git checkout --detach "$ref"
31 git worktree add --detach "$RUNNER_TEMP/omega-build" "$ref"
32 cd "$RUNNER_TEMP/omega-build"
33 sh seed/omega-from-seed.sh > "$RUNNER_TEMP/seed.log" 2>&1 || { tail -40 "$RUNNER_TEMP/seed.log"; exit 1; }
34 sha256sum seed/out/omc
35 echo "OMC=$RUNNER_TEMP/omega-build/seed/out/omc" >> "$GITHUB_ENV"
36 - name: Unit tests with the real omc (diagnostics, fmt, snippets compile)
37 run: OMEGA_REQUIRE_OMC=1 npm test
38 - name: Negative control 1, an omc that accepts everything must fail the tests
39 run: |
40 set -u
41 rc=0; OMC=/usr/bin/true OMEGA_REQUIRE_OMC=1 node --test test/omc.test.js > neg1.txt 2>&1 || rc=$?
42 grep -E '(pass|fail) [0-9]+' neg1.txt || true
43 [ "$rc" != 0 ] || { echo "tests passed with a fake omc"; exit 1; }
44 echo "negative control 1 failed as required (rc=$rc)"
45 - name: Inside VS Code 1.90.0 (xvfb) the extension gives the omc diagnostic and formats
46 run: |
47 set -eu -o pipefail
48 sudo apt-get update -qq
49 sudo apt-get install -y -qq xvfb libnss3 libgbm1 libasound2t64 libgtk-3-0t64 libxkbfile1 libsecret-1-0 > /dev/null
50 Xvfb :99 -screen 0 1280x800x24 > /dev/null 2>&1 &
51 echo "DISPLAY=:99" >> "$GITHUB_ENV"
52 DISPLAY=:99 npm run test:vscode 2>&1 | tee vscode-test.txt
53 grep -q '^PASS diagnostic 3 omc error 16' vscode-test.txt
54 grep -q '^PASS format' vscode-test.txt
55 - name: Negative control 2, inside VS Code a fake omc must fail the diagnostic check
56 run: |
57 set -u
58 rc=0; OMC=/usr/bin/true npm run test:vscode > neg-vscode.txt 2>&1 || rc=$?
59 grep -E 'PASS|AssertionError|failed' neg-vscode.txt || true
60 [ "$rc" != 0 ] || { echo "VS Code test passed with a fake omc"; exit 1; }
61 echo "negative control 2 failed as required (rc=$rc)"
62 - name: tree-sitter-omega at tree-sitter-omega.ref
63 run: |
64 set -eu
65 ref=$(awk '$1=="commit"{print $2}' tree-sitter-omega.ref)
66 git clone --no-checkout https://github.com/aien-dev/tree-sitter-omega "$RUNNER_TEMP/ts"
67 cd "$RUNNER_TEMP/ts"
68 git checkout --detach "$ref"
69 npm ci --ignore-scripts
70 (cd node_modules/tree-sitter-cli && node install.js)
71 sha256sum -c tree-sitter-cli.sha256
72 sh scripts/coverage.sh --omc "$OMC" "$RUNNER_TEMP/omega-mv" > "$RUNNER_TEMP/coverage.tsv"
73 grep '^COVERAGE' "$RUNNER_TEMP/coverage.tsv"
74 awk -F'\t' '$2=="omc=accept"{print $1}' "$RUNNER_TEMP/coverage.tsv" > "$RUNNER_TEMP/accepted.txt"
75 wc -l < "$RUNNER_TEMP/accepted.txt"
76 - name: TextMate vs tree-sitter agreement (omc-accepted files and test/fixtures must agree 100%; all files reported)
77 run: |
78 set -eu
79 node test/agree.js --ts "$RUNNER_TEMP/ts" --src "$RUNNER_TEMP/omega-mv" --min 0 > agree-all.txt
80 tail -2 agree-all.txt
81 node test/agree.js --ts "$RUNNER_TEMP/ts" --src "$RUNNER_TEMP/omega-mv" --files "$RUNNER_TEMP/accepted.txt" --min 100 > agree-accepted.txt \
82 || { cat agree-accepted.txt; exit 1; }
83 tail -2 agree-accepted.txt
84 # test/fixtures: omc-accepted edge cases (names that start with note, note(...), note in text).
85 for f in test/fixtures/*.om; do "$OMC" < "$f" > /dev/null || { echo "omc refuses $f"; exit 1; }; done
86 node test/agree.js --ts "$RUNNER_TEMP/ts" --src test/fixtures --min 100 > agree-fixtures.txt \
87 || { cat agree-fixtures.txt; exit 1; }
88 tail -2 agree-fixtures.txt
89 { echo '```'; echo "all files:"; tail -2 agree-all.txt; echo "omc-accepted files:"; tail -2 agree-accepted.txt; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
90 - name: Negative control 3, a TextMate grammar without the type words must fail agreement
91 run: |
92 set -u
93 node -e '
94 const g = require("./syntaxes/omega.tmLanguage.json");
95 const w = g.repository.words.patterns, n = w.length;
96 g.repository.words.patterns = w.filter((p) => p.name !== "support.type.builtin.omega");
97 if (g.repository.words.patterns.length !== n - 1) process.exit(3);
98 require("fs").writeFileSync(process.env.RUNNER_TEMP + "/mutant.json", JSON.stringify(g));'
99 rc=0; node test/agree.js --ts "$RUNNER_TEMP/ts" --src "$RUNNER_TEMP/omega-mv" --files "$RUNNER_TEMP/accepted.txt" \
100 --grammar "$RUNNER_TEMP/mutant.json" --min 100 > neg2.txt || rc=$?
101 tail -2 neg2.txt
102 [ "$rc" = 1 ] || { echo "mutated grammar was not caught: rc=$rc"; exit 1; }
103 echo "negative control 3 failed as required (rc=$rc)"
104 - name: Package the .vsix with vsce
105 run: |
106 set -eu
107 v=$(node -p 'require("./package.json").version')
108 npx --no-install vsce package --no-dependencies -o "omega-$v.vsix"
109 sha256sum "omega-$v.vsix" | tee "omega-$v.vsix.sha256"
110 sh test/check-vsix.sh "omega-$v.vsix"
111 - name: Negative control 4, a package built without .vscodeignore must fail the package check
112 run: |
113 set -u
114 d="$RUNNER_TEMP/neg4"; mkdir -p "$d"
115 git ls-files | grep -vx .vscodeignore | while read -r f; do mkdir -p "$d/$(dirname "$f")"; cp "$f" "$d/$f"; done
116 (cd "$d" && "$GITHUB_WORKSPACE/node_modules/.bin/vsce" package --no-dependencies -o bad.vsix > /dev/null)
117 rc=0; sh test/check-vsix.sh "$d/bad.vsix" || rc=$?
118 [ "$rc" = 1 ] || { echo "package check passed a vsix that ships tests: rc=$rc"; exit 1; }
119 echo "negative control 4 failed as required (rc=$rc)"
120 - uses: actions/upload-artifact@v4
121 with:
122 name: vsix
123 path: |
124 omega-*.vsix
125 omega-*.vsix.sha256
126 agree-all.txt
127 release:
128 if: startsWith(github.ref, 'refs/tags/v')
129 needs: extension
130 runs-on: ubuntu-24.04-arm
131 permissions:
132 contents: write
133 steps:
134 - uses: actions/checkout@v4
135 - uses: actions/download-artifact@v4
136 with:
137 name: vsix
138 - name: Check the tag matches package.json, then publish the Release
139 env:
140 GH_TOKEN: ${{ github.token }}
141 run: |
142 set -eu
143 v=$(node -p 'require("./package.json").version')
144 [ "v$v" = "$GITHUB_REF_NAME" ] || { echo "tag $GITHUB_REF_NAME != package.json $v"; exit 1; }
145 sha256sum -c "omega-$v.vsix.sha256"
146 gh release create "$GITHUB_REF_NAME" "omega-$v.vsix" "omega-$v.vsix.sha256" \
147 --title "Omega for VS Code $v" \
148 --notes "Install: download both files, then \`sha256sum -c omega-$v.vsix.sha256 && code --install-extension omega-$v.vsix\`. sha256: $(cut -d' ' -f1 "omega-$v.vsix.sha256")"