Files
wekan/tests/ucsNextcloudWorkflows.test.cjs
T
Lauri Ojansivu 164dd5cdb0 Docker image: distroless base-nossl, without libssl and libgomp.
distroless cc-debian13 adds libssl3t64 and libgomp1 to glibc. Nothing in
the image loads either - node links OpenSSL 3.5 statically, and sharp,
canvas, bcrypt and argon2 need neither - and they were 20 of the base's
55 scanner findings, both HIGH ones among them. The image is now
gcr.io/distroless/base-nossl-debian13 plus gcc-14-base, libgcc-s1,
libstdc++6 and libatomic1 from Debian 13, each with its dpkg record; the
386 root is the same packages. That root, assembled for arm64 from the
registry and deb.debian.org, runs node and loads every arm64 native
module of the bundle, and Trivy finds 42 findings in it: 0 HIGH, 0
fixable.

Thanks to xet7 !
2026-11-25 00:51:28 +02:00

76 lines
4.7 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const root = path.resolve(__dirname, '..');
const read = name => fs.readFileSync(path.join(root, '.github/workflows', name), 'utf8');
for (const name of ['ucs', 'nextcloud']) {
for (const caller of ['release-all.yml', 'release-all-missing.yml']) {
const source = read(caller);
assert.ok(!source.includes(`\n ${name}:\n`), `${caller} must not contain ${name}`);
assert.ok(!source.includes(`uses: ./.github/workflows/${name}.yml`));
}
const source = read(`${name}.yml`);
assert.ok(source.includes('workflow_dispatch:'));
assert.ok(!source.includes('workflow_call:'), 'publisher is manual-only');
assert.ok(source.includes('cancel-in-progress: false'));
assert.match(source, /timeout-minutes: \d+/);
assert.ok(!source.includes('git push'), 'backfilling does not downgrade companion branches');
assert.ok(!source.includes('continue-on-error: true'), 'real failures remain visible');
}
const ucs = read('ucs.yml');
assert.ok(ucs.includes('bash releases/fetch.sh'));
assert.ok(ucs.includes('ucs-release.py upload'));
assert.ok(ucs.includes('UCS_SOURCE_APP') && ucs.includes('UCS_TARGET_UCS'));
assert.ok(ucs.includes('steps.portal.outputs.skip'));
assert.ok(ucs.includes('gh release view --repo wekan/wekan'));
assert.ok(ucs.includes('gh release view --repo wekan/FerretDB'));
assert.ok(ucs.includes('ucs-release.py resolve'));
assert.ok(!ucs.includes('vars.UCS_FERRETDB_IMAGE'));
assert.ok(ucs.includes('required: false'));
assert.ok(ucs.includes('group: wekan-ucs-publish'));
// Migration is a command in the standard image, never a fourth package.
assert.ok(!ucs.includes('docker buildx build'));
assert.ok(!ucs.includes('GHCR_AUTH'));
assert.ok(!ucs.includes('packages: write'));
assert.ok(read('release-all.yml').includes('ucs-release.py check-image --version "$VERSION"'));
assert.ok(read('release-all-missing.yml').includes('releases/retry-failed-release.py'));
const dockerfile = fs.readFileSync(path.join(root, 'Dockerfile'), 'utf8');
// Distroless: no shell in the image, so UCS and Nextcloud start it with node.
assert.match(dockerfile, /^FROM gcr\.io\/distroless\/base-nossl-debian13:nonroot AS distroless$/m);
assert.match(dockerfile, /COPY releases\/ucs-migration \/opt\/ucs-migration/);
assert.match(dockerfile, /COPY --chmod=755 releases\/ucs-migration\/tools \/opt\/ucs-migration\/tools/);
assert.match(dockerfile, /USER wekan/);
assert.match(dockerfile, /CMD \["\/usr\/local\/bin\/node", "\/build\/wekan-entrypoint\.mjs"\]/);
assert.ok(!dockerfile.includes('VOLUME /var/run/docker.sock'));
const nc = read('nextcloud.yml');
// Packed by releases/nextcloud-pack.sh, which works with GNU tar and with
// bsdtar (macOS, the BSDs): GNU tar's --transform is not used.
assert.ok(nc.includes('releases/nextcloud-pack.sh exapp "$APP_ID" "$task_dir/$archive"'));
const pack = fs.readFileSync(path.join(__dirname, '..', 'releases', 'nextcloud-pack.sh'), 'utf8');
assert.ok(pack.includes('--exclude=.git --exclude=.tools --exclude=.env --exclude=node_modules'));
assert.ok(pack.includes('COPYFILE_DISABLE=1'), 'no ._* AppleDouble files from macOS tar');
assert.ok(!/--transform/.test(pack.replace(/^#.*$/gm, '')), 'no GNU-only tar option');
assert.ok(nc.includes('openssl dgst -sha512 -verify'));
assert.ok(nc.includes("trap ") && nc.includes('EXIT'), 'private signing material is removed on failure too');
assert.ok(nc.includes('curl --fail-with-body'), 'App Store HTTP rejection fails the publication');
assert.ok(nc.includes('if [ "$new_archive" = true ]'), 'published tarballs are reused rather than overwritten');
assert.ok(nc.includes('persist-credentials: false'));
assert.ok(nc.includes('nextcloud-exapp-capability.json'));
// The capability check runs node, which every image has, old and distroless alike.
assert.ok(nc.includes('docker run --rm --entrypoint /usr/local/bin/node "ghcr.io/wekan/wekan:v$VERSION" -e'));
assert.ok(!/--entrypoint \/bin\/sh|--entrypoint bash/.test(nc), 'no shell in the WeKan image');
assert.ok(nc.includes('node --test exapp/tests/*.test.mjs'));
assert.ok(nc.includes('--platform linux/amd64,linux/arm64'));
assert.ok(!nc.includes('--clobber'));
assert.ok(!nc.includes('wekan-exapp:latest'));
assert.ok(!nc.includes('|| echo "::warning::Nextcloud App Store upload failed'));
// Register the Python behavioral suites with the ordinary node-suite runner.
for (const file of ['ucsRelease.test.py', 'nextcloudRelease.test.py']) {
const result = spawnSync('python3', ['-B', path.join(__dirname, file)], { encoding: 'utf8', env: process.env });
assert.equal(result.status, 0, result.stdout + result.stderr);
process.stdout.write(result.stderr);
}
console.log('UCS and Nextcloud manual workflow checks passed');