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.
@@ -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_Store3
.DS_Store4
__pycache__/4
__pycache__/5
*.pyc5
*.pyc6
7
# Generated by src/build.sh — sources live in server/.8
build/api.php9
build/auth.php10
build/callback.php11
build/logout.php12
build/router.php13
build/.htaccess14
build/lib/15
build/data/@@ -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) wordt6
# niet geüpload; alleen data/.htaccess wordt naderhand gezet.7
# favicon.ico wordt nooit geüpload.6
stages: [test, build, deploy]8
stages: [test, build, deploy]7
9
8
workflow:10
workflow:@@ -17,7 +19,9 @@ unit_tests:17
stage: test19
stage: test18
image: node:20-bookworm20
image: node:20-bookworm19
script:21
script:22
- apt-get update -qq && apt-get install -y -qq php-cli php-sqlite3 php-curl php-mbstring >/dev/null20
- node --test test/*.test.js23
- node --test test/*.test.js24
- php server/tests/run.php21
25
22
build_game:26
build_game:23
stage: build27
stage: build@@ -34,6 +38,16 @@ build_game:34
- test -d build/images38
- test -d build/images35
- test -f build/images/block-ember.png39
- test -f build/images/block-ember.png36
- test -f build/images/flame.png40
- test -f build/images/flame.png41
- test -f build/api.php42
- test -f build/auth.php43
- test -f build/callback.php44
- test -f build/logout.php45
- test -f build/.htaccess46
- test -f build/lib/bootstrap.php47
- test -f build/lib/Store.php48
- test -f build/data/.htaccess49
- test ! -f build/data/config.php50
- test ! -e build/data/*.sqlite37
# 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.png69
- build/images/pixel.png56
- build/images/favicon-16.png70
- build/images/favicon-16.png57
- build/images/favicon-32.png71
- build/images/favicon-32.png72
- build/api.php73
- build/auth.php74
- build/callback.php75
- build/logout.php76
- build/.htaccess77
- build/lib/bootstrap.php78
- build/lib/Store.php79
- build/data/.htaccess58
expire_in: 7d80
expire_in: 7d59
81
60
ftp_upload:82
ftp_upload:@@ -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).22
OURS = {22
OURS = {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 the154
# 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
@@ -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], {