-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (118 loc) · 4.82 KB
/
Copy pathci.yml
File metadata and controls
132 lines (118 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Obsidian CI
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Checks and documentation
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install build dependencies
run: |
sudo add-apt-repository --yes ppa:jackmacwindows/ppa
sudo apt-get update
sudo apt-get install --yes craftos-pc lua5.4
# ui/events.lua uses goto, so this needs a 5.2+ compiler. luac5.1 would
# reject it. This only parses, it never runs engine code.
- name: Syntax-check all sources
run: |
status=0
for file in $(find src tools -name '*.lua' | sort); do
if ! luac5.4 -p "$file"; then
echo "::error file=$file::syntax error"
status=1
fi
done
exit $status
# Mirrors what the installer produces: src/ lands in the computer as
# "obsidian", user code sits next to it and calls require("obsidian").
# luac only proves a file parses; this proves the engine comes up.
- name: Smoke-test the source install
run: |
# --directory is CraftOS-PC's *data* directory; the computer's own
# root lives in computer/0 below it. Files copied anywhere else are
# invisible to the shell.
root="$RUNNER_TEMP/craftos-smoke/computer/0"
mkdir -p "$root"
cp tools/smoketest.lua "$root/smoketest.lua"
craftos \
--headless \
--directory "$RUNNER_TEMP/craftos-smoke" \
--mount-ro "obsidian=$GITHUB_WORKSPACE/src" \
--exec "local ok = shell.run('smoketest.lua'); os.shutdown(ok and 0 or 1)"
# Only validated here. The pages are generated and published by
# docs.yml into the gh-pages branch, so master carries no docs/.
- name: Validate documentation annotations
run: lua5.4 tools/docgen.lua --check
# install.lua fetches manifest.txt to know which source files to pull.
# Generated rather than hand-maintained: a file added to src/ but missing
# here would produce a source install that is silently incomplete.
- name: Generate source manifest
run: find src -name '*.lua' | sort > manifest.txt
- name: Build release bundles
run: |
mkdir -p "$RUNNER_TEMP/obsidian-bundle"
lua5.4 tools/bundle-host.lua \
--no-minify "$RUNNER_TEMP/obsidian-bundle/obsidian.lua"
lua5.4 tools/bundle-host.lua \
"$RUNNER_TEMP/obsidian-bundle/obsidian.min.lua"
lua5.4 tools/bundle-host.lua \
--compress "$RUNNER_TEMP/obsidian-bundle/obsidian.compressed.lua"
# The minifier rewrites every identifier, so a bundle that no longer
# parses is the failure mode that matters most here.
- name: Syntax-check release bundles
run: |
status=0
for file in "$RUNNER_TEMP"/obsidian-bundle/*.lua; do
if ! luac5.4 -p "$file"; then
echo "::error::generated bundle does not parse: $file"
status=1
fi
done
exit $status
# Each bundle is dropped in as obsidian.lua, i.e. exactly where the
# installed directory would sit, and has to satisfy the same test. That
# also proves a bundle is a drop-in replacement for the source install.
- name: Smoke-test release bundles
run: |
for variant in obsidian obsidian.min obsidian.compressed; do
datadir="$RUNNER_TEMP/craftos-bundle-$variant"
root="$datadir/computer/0"
mkdir -p "$root"
cp tools/smoketest.lua "$root/smoketest.lua"
cp "$RUNNER_TEMP/obsidian-bundle/$variant.lua" "$root/obsidian.lua"
echo "--- $variant.lua ---"
craftos \
--headless \
--directory "$datadir" \
--exec "local ok = shell.run('smoketest.lua'); os.shutdown(ok and 0 or 1)"
done
- name: Update committed bundles and manifest
if: github.event_name == 'push'
run: |
mkdir -p bundle
cp "$RUNNER_TEMP"/obsidian-bundle/*.lua bundle/
git add bundle manifest.txt
if git diff --cached --quiet; then
echo "bundles and manifest already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Build release bundles"
git push
- name: Upload release bundles
uses: actions/upload-artifact@v7
with:
name: obsidian-bundles
path: ${{ runner.temp }}/obsidian-bundle/*.lua
if-no-files-found: error