BlueGit

projects-timfalken-com meteors

feat: build and deploy the PHP API, leaving data/ and favicon alone

build.sh copies the PHP endpoints into build/ (never config.php or
sqlite). The FTP mirror excludes data/ and favicon.ico, then only
puts data/.htaccess. CI runs the PHP Store tests and publishes the
PHP files as individual artifacts.

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
58ca9cdf43061e27a74a643e6c88258c19f2dba6
Parent
02ce7144
4 files changed +48 −2
.gitignore +10 −0
@@ -3,3 +3,13 @@ node_modules/
3 3 .DS_Store
4 4 __pycache__/
5 5 *.pyc
6
7 # Generated by src/build.sh — sources live in server/.
8 build/api.php
9 build/auth.php
10 build/callback.php
11 build/logout.php
12 build/router.php
13 build/.htaccess
14 build/lib/
15 build/data/
@@ -3,3 +3,13 @@ node_modules/
3.DS_Store
3.DS_Store
4__pycache__/
4__pycache__/
5*.pyc
5*.pyc
6
7# Generated by src/build.sh — sources live in server/.
8build/api.php
9build/auth.php
10build/callback.php
11build/logout.php
12build/router.php
13build/.htaccess
14build/lib/
15build/data/
blue-ci-cd.yml +23 −1
@@ -2,7 +2,9 @@
2 2 # Group secrets: timftphost, timftpuser, timftppassword, timftproot (protected).
3 3 # Repo secret: projectftp (protected; Tim set this to $timftproot/meteors).
4 4 # GEEN mirror --delete: live files mogen niet verdwijnen.
5 # Deployt map build/ (NIET de repo-root).
5 # Deployt map build/ (NIET de repo-root). data/ (config, sqlite) wordt
6 # niet geüpload; alleen data/.htaccess wordt naderhand gezet.
7 # favicon.ico wordt nooit geüpload.
6 8 stages: [test, build, deploy]
7 9
8 10 workflow:
@@ -17,7 +19,9 @@ unit_tests:
17 19 stage: test
18 20 image: node:20-bookworm
19 21 script:
22 - apt-get update -qq && apt-get install -y -qq php-cli php-sqlite3 php-curl php-mbstring >/dev/null
20 23 - node --test test/*.test.js
24 - php server/tests/run.php
21 25
22 26 build_game:
23 27 stage: build
@@ -34,6 +38,16 @@ build_game:
34 38 - test -d build/images
35 39 - test -f build/images/block-ember.png
36 40 - test -f build/images/flame.png
41 - test -f build/api.php
42 - test -f build/auth.php
43 - test -f build/callback.php
44 - test -f build/logout.php
45 - test -f build/.htaccess
46 - test -f build/lib/bootstrap.php
47 - test -f build/lib/Store.php
48 - test -f build/data/.htaccess
49 - test ! -f build/data/config.php
50 - test ! -e build/data/*.sqlite
37 51 # BlueGit weigert directory-artifacts (IsDir → "ontbreekt"). Alleen bestanden.
38 52 # Afbeeldingen staan in git en zitten zo ook in de deploy-checkout.
39 53 artifacts:
@@ -55,6 +69,14 @@ build_game:
55 69 - build/images/pixel.png
56 70 - build/images/favicon-16.png
57 71 - build/images/favicon-32.png
72 - build/api.php
73 - build/auth.php
74 - build/callback.php
75 - build/logout.php
76 - build/.htaccess
77 - build/lib/bootstrap.php
78 - build/lib/Store.php
79 - build/data/.htaccess
58 80 expire_in: 7d
59 81
60 82 ftp_upload:
@@ -2,7 +2,9 @@
2# Group secrets: timftphost, timftpuser, timftppassword, timftproot (protected).
2# Group secrets: timftphost, timftpuser, timftppassword, timftproot (protected).
3# Repo secret: projectftp (protected; Tim set this to $timftproot/meteors).
3# Repo secret: projectftp (protected; Tim set this to $timftproot/meteors).
4# GEEN mirror --delete: live files mogen niet verdwijnen.
4# GEEN mirror --delete: live files mogen niet verdwijnen.
5# Deployt map build/ (NIET de repo-root).
5# Deployt map build/ (NIET de repo-root). data/ (config, sqlite) wordt
6# niet geüpload; alleen data/.htaccess wordt naderhand gezet.
7# favicon.ico wordt nooit geüpload.
6stages: [test, build, deploy]
8stages: [test, build, deploy]
7
9
8workflow:
10workflow:
@@ -17,7 +19,9 @@ unit_tests:
17 stage: test
19 stage: test
18 image: node:20-bookworm
20 image: node:20-bookworm
19 script:
21 script:
22 - apt-get update -qq && apt-get install -y -qq php-cli php-sqlite3 php-curl php-mbstring >/dev/null
20 - node --test test/*.test.js
23 - node --test test/*.test.js
24 - php server/tests/run.php
21
25
22build_game:
26build_game:
23 stage: build
27 stage: build
@@ -34,6 +38,16 @@ build_game:
34 - test -d build/images
38 - test -d build/images
35 - test -f build/images/block-ember.png
39 - test -f build/images/block-ember.png
36 - test -f build/images/flame.png
40 - test -f build/images/flame.png
41 - test -f build/api.php
42 - test -f build/auth.php
43 - test -f build/callback.php
44 - test -f build/logout.php
45 - test -f build/.htaccess
46 - test -f build/lib/bootstrap.php
47 - test -f build/lib/Store.php
48 - test -f build/data/.htaccess
49 - test ! -f build/data/config.php
50 - test ! -e build/data/*.sqlite
37 # BlueGit weigert directory-artifacts (IsDir → "ontbreekt"). Alleen bestanden.
51 # BlueGit weigert directory-artifacts (IsDir → "ontbreekt"). Alleen bestanden.
38 # Afbeeldingen staan in git en zitten zo ook in de deploy-checkout.
52 # Afbeeldingen staan in git en zitten zo ook in de deploy-checkout.
39 artifacts:
53 artifacts:
@@ -55,6 +69,14 @@ build_game:
55 - build/images/pixel.png
69 - build/images/pixel.png
56 - build/images/favicon-16.png
70 - build/images/favicon-16.png
57 - build/images/favicon-32.png
71 - build/images/favicon-32.png
72 - build/api.php
73 - build/auth.php
74 - build/callback.php
75 - build/logout.php
76 - build/.htaccess
77 - build/lib/bootstrap.php
78 - build/lib/Store.php
79 - build/data/.htaccess
58 expire_in: 7d
80 expire_in: 7d
59
81
60ftp_upload:
82ftp_upload:
ci/deploy.py +10 −0
@@ -21,6 +21,8 @@ ROOT = Path(__file__).resolve().parents[1]
21 21 # log; foreign names no longer abort the deploy (we never --delete).
22 22 OURS = {
23 23 'index.html', 'game.js', 'framework.js', 'style.css', 'images',
24 'api.php', 'auth.php', 'callback.php', 'logout.php', '.htaccess',
25 'lib', 'data', 'router.php',
24 26 '.', '..',
25 27 }
26 28
@@ -148,11 +150,19 @@ def deploy_commands(environ, target, webroot):
148 150 f'mkdir -p {quoted(target)} || echo "Using existing project directory"',
149 151 f'cd {quoted(target)}',
150 152 # GEEN --delete. Never upload favicon.ico (leave Tim's / the host's).
153 # Never mirror data/: that folder holds Tim's config.php and the
154 # sqlite database. We only ensure data/.htaccess afterwards.
151 155 'mirror --reverse --no-perms --no-symlinks --max-errors=1 '
152 156 '--exclude-glob ".git/" --exclude-glob ".git/**" '
153 157 '--exclude-glob "blue-ci-cd.yml" --exclude-glob "README.md" '
154 158 '--exclude-glob "favicon.ico" --exclude-glob "**/favicon.ico" '
159 '--exclude-glob "router.php" '
160 '--exclude-glob "data/" --exclude-glob "data/**" '
161 '--exclude-glob "**/config.php" --exclude-glob "**/*.sqlite" '
155 162 f'{quoted(str(webroot))} .',
163 # Ensure the deny-all htaccess exists; do not touch any other data file.
164 'mkdir -p data || echo "data exists"',
165 f'put {quoted(str(webroot / "data" / ".htaccess"))} -o data/.htaccess',
156 166 'bye',
157 167 ]
158 168
@@ -21,6 +21,8 @@ ROOT = Path(__file__).resolve().parents[1]
21# log; foreign names no longer abort the deploy (we never --delete).
21# log; foreign names no longer abort the deploy (we never --delete).
22OURS = {
22OURS = {
23 'index.html', 'game.js', 'framework.js', 'style.css', 'images',
23 'index.html', 'game.js', 'framework.js', 'style.css', 'images',
24 'api.php', 'auth.php', 'callback.php', 'logout.php', '.htaccess',
25 'lib', 'data', 'router.php',
24 '.', '..',
26 '.', '..',
25}
27}
26
28
@@ -148,11 +150,19 @@ def deploy_commands(environ, target, webroot):
148 f'mkdir -p {quoted(target)} || echo "Using existing project directory"',
150 f'mkdir -p {quoted(target)} || echo "Using existing project directory"',
149 f'cd {quoted(target)}',
151 f'cd {quoted(target)}',
150 # GEEN --delete. Never upload favicon.ico (leave Tim's / the host's).
152 # GEEN --delete. Never upload favicon.ico (leave Tim's / the host's).
153 # Never mirror data/: that folder holds Tim's config.php and the
154 # sqlite database. We only ensure data/.htaccess afterwards.
151 'mirror --reverse --no-perms --no-symlinks --max-errors=1 '
155 'mirror --reverse --no-perms --no-symlinks --max-errors=1 '
152 '--exclude-glob ".git/" --exclude-glob ".git/**" '
156 '--exclude-glob ".git/" --exclude-glob ".git/**" '
153 '--exclude-glob "blue-ci-cd.yml" --exclude-glob "README.md" '
157 '--exclude-glob "blue-ci-cd.yml" --exclude-glob "README.md" '
154 '--exclude-glob "favicon.ico" --exclude-glob "**/favicon.ico" '
158 '--exclude-glob "favicon.ico" --exclude-glob "**/favicon.ico" '
159 '--exclude-glob "router.php" '
160 '--exclude-glob "data/" --exclude-glob "data/**" '
161 '--exclude-glob "**/config.php" --exclude-glob "**/*.sqlite" '
155 f'{quoted(str(webroot))} .',
162 f'{quoted(str(webroot))} .',
163 # Ensure the deny-all htaccess exists; do not touch any other data file.
164 'mkdir -p data || echo "data exists"',
165 f'put {quoted(str(webroot / "data" / ".htaccess"))} -o data/.htaccess',
156 'bye',
166 'bye',
157 ]
167 ]
158
168
test/deploy_guard.test.js +5 −1
@@ -96,7 +96,7 @@ describe('assert_safe_target', () =>
96 96 assert.doesNotMatch(r.stdout + r.stderr, /GEBLOKKEERD/);
97 97 });
98 98
99 it('the FTP mirror never deletes and never uploads favicon.ico', () =>
99 it('the FTP mirror never deletes, never uploads favicon.ico, and leaves data/ alone', () =>
100 100 {
101 101 const py = [
102 102 'import sys',
@@ -107,6 +107,10 @@ describe('assert_safe_target', () =>
107 107 'cmds = "\\n".join(deploy_commands(env, "/var/www/meteors", Path("build")))',
108 108 'assert "--delete" not in cmds, cmds',
109 109 'assert "--exclude-glob \\"favicon.ico\\"" in cmds, cmds',
110 'assert "--exclude-glob \\"data/**\\"" in cmds, cmds',
111 'assert "--exclude-glob \\"**/config.php\\"" in cmds, cmds',
112 'assert "data/.htaccess" in cmds, cmds',
113 'assert "put " in cmds, cmds',
110 114 'print("mirror ok")'
111 115 ].join('\n');
112 116 const r = spawnSync('python3', ['-c', py], {
@@ -96,7 +96,7 @@ describe('assert_safe_target', () =>
96 assert.doesNotMatch(r.stdout + r.stderr, /GEBLOKKEERD/);
96 assert.doesNotMatch(r.stdout + r.stderr, /GEBLOKKEERD/);
97 });
97 });
98
98
99 it('the FTP mirror never deletes and never uploads favicon.ico', () =>
99 it('the FTP mirror never deletes, never uploads favicon.ico, and leaves data/ alone', () =>
100 {
100 {
101 const py = [
101 const py = [
102 'import sys',
102 'import sys',
@@ -107,6 +107,10 @@ describe('assert_safe_target', () =>
107 'cmds = "\\n".join(deploy_commands(env, "/var/www/meteors", Path("build")))',
107 'cmds = "\\n".join(deploy_commands(env, "/var/www/meteors", Path("build")))',
108 'assert "--delete" not in cmds, cmds',
108 'assert "--delete" not in cmds, cmds',
109 'assert "--exclude-glob \\"favicon.ico\\"" in cmds, cmds',
109 'assert "--exclude-glob \\"favicon.ico\\"" in cmds, cmds',
110 'assert "--exclude-glob \\"data/**\\"" in cmds, cmds',
111 'assert "--exclude-glob \\"**/config.php\\"" in cmds, cmds',
112 'assert "data/.htaccess" in cmds, cmds',
113 'assert "put " in cmds, cmds',
110 'print("mirror ok")'
114 'print("mirror ok")'
111 ].join('\n');
115 ].join('\n');
112 const r = spawnSync('python3', ['-c', py], {
116 const r = spawnSync('python3', ['-c', py], {