Skip to content

Commit fe57c47

Browse files
committed
adjusting the workflow and exports
1 parent 15e525a commit fe57c47

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎.github/workflows/deploy-documents.yml‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ jobs:
4343
# src/lib/design-checks.mjs and src/lib/design-refresh.mjs are copies of
4444
# phalcon/tools/ in phalcon/assets: the checks and the refresh of the
4545
# design files, the same on every Phalcon site. A download that fails,
46-
# or a file that is not valid JavaScript, keeps the committed copy. The
47-
# design files and the tests that come next use the new tools.
46+
# a file that is not valid JavaScript, or a file that lacks an export of
47+
# the committed copy keeps the committed copy. The design files and the
48+
# tests that come next use the new tools.
49+
env:
50+
# Exits with 0 when the first file has every export of the second one.
51+
EXPORTS: >-
52+
const [next, last] = await Promise.all(process.argv.slice(1).map((file) => import(process.cwd() + '/' + file)));
53+
process.exit(Object.keys(last).every((name) => name in next) ? 0 : 1);
4854
run: |
4955
for file in design-checks.mjs design-refresh.mjs; do
5056
new="src/lib/${file%.mjs}.new.mjs"
5157
52-
if curl -fsSL --max-time 30 -o "$new" "https://assets.phalcon.io/phalcon/tools/$file" && node --check "$new"; then
58+
if curl -fsSL --max-time 30 -o "$new" "https://assets.phalcon.io/phalcon/tools/$file" && node --check "$new" \
59+
&& node --input-type=module -e "$EXPORTS" "$new" "src/lib/$file"; then
5360
mv "$new" "src/lib/$file"
5461
else
5562
rm -f "$new"

‎scripts/sources.test.mjs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,13 @@ test("the deploy workflow gets the design tools first, and keeps the committed c
153153
assert.ok(step < workflow.indexOf("run: node scripts/update-tokens.mjs"), "the step must come before the design files");
154154
assert.match(workflow, /for file in design-checks\.mjs design-refresh\.mjs; do/);
155155
assert.match(workflow, /new="src\/lib\/\$\{file%\.mjs\}\.new\.mjs"/);
156-
assert.match(workflow, /curl -fsSL --max-time 30 -o "\$new" "https:\/\/assets\.phalcon\.io\/phalcon\/tools\/\$file" && node --check "\$new"; then/);
156+
assert.match(workflow, /curl -fsSL --max-time 30 -o "\$new" "https:\/\/assets\.phalcon\.io\/phalcon\/tools\/\$file" && node --check "\$new"/);
157+
});
158+
159+
test("the deploy workflow keeps the committed design tools when a new file lacks one of their exports", () => {
160+
// The site imports the functions by name: a new file with an export less would stop the refresh.
161+
const workflow = readFileSync(new URL(".github/workflows/deploy-documents.yml", root), "utf8");
162+
163+
assert.match(workflow, /node --check "\$new" \\\n\s+&& node --input-type=module -e "\$EXPORTS" "\$new" "src\/lib\/\$file"; then/);
164+
assert.match(workflow, /Object\.keys\(last\)\.every\(\(name\) => name in next\)/);
157165
});

0 commit comments

Comments
 (0)