Commit Graph
11 Commits
Author SHA1 Message Date
Lauri Ojansivu aeff4900df Every file the scripts write stays in .tools/: temporary files, downloads, Meteor, Node.js, npm.
build.sh and the releases/ scripts wrote all over the machine: temporary
files to /tmp and macOS's /var/folders, downloads and release zips to
~/Downloads or ~/Lataukset, Meteor to ~/.meteor, Node.js to /usr/local
(sudo n) or ~/.nvm, the npm cache to ~/.npm, Volta to ~/.volta, the
Sandstorm toolchain to ~/projects, and PATH lines into ~/.zshrc and
~/.bashrc. A sandboxed editor (Flatpak on Linux, sandbox-exec on macOS)
can reach only the checkout, and a container's own /tmp is a few hundred
megabytes. Everything is in .tools/ now, which git and Meteor ignore:

- releases/tools-env.sh, sourced by build.sh and every script that writes
  files, sets TMPDIR/TMP/TEMP to .tools/tmp (also downloads and release
  zips), NVM_DIR, npm_config_cache, VOLTA_HOME and the meteor-spk
  directory to .tools/, METEOR_WAREHOUSE_DIR to .tools/.meteor once Meteor
  is installed there, and puts those tools first on PATH, so no shell rc
  file is edited. HOME is not moved: git needs ~/.gitconfig and ~/.ssh.
  A TMPDIR already inside a .tools/ is kept, so a test's own directory
  there stays its own; without a writable one it stops rather than fall
  back to /tmp. It never fails a caller running set -euo pipefail.
- macOS's mktemp ignores TMPDIR when given no template, so every mktemp
  names one: mktemp "$TMPDIR/name.XXXXXX". Fixed /tmp files are in
  $TMPDIR.
- build.sh installs Node.js on Linux into .tools/n (N_PREFIX, no sudo),
  nvm on macOS into .tools/nvm (PROFILE=/dev/null: no rc file edited), and
  Meteor with HOME=.tools for the installer only, into .tools/.meteor.
  build.sh is replaced, not edited in place, while it may be running.
- Containers get this checkout's .tools/tmp as their /tmp: every
  db-conformance database (MariaDB's temporary tables were verified to land
  there, and MongoDB's socket) and the repack container, which empty it
  themselves before they are removed. install-node-for-arch.sh requires
  the mounted TMPDIR.
- tests/run-node-suites.cjs gives every suite TMPDIR in .tools/tmp, and the
  tests that copied a script into a fixture copy tools-env.sh too; tests
  that pinned ~/.meteor, the rc file edits, sudo n or /tmp/manifest.json
  pin the .tools/ places now and say why.

tests/toolsDirOnly.test.cjs runs tools-env.sh against a TMPDIR already
set elsewhere and under set -euo pipefail, and fails on any script that
makes a temporary file without naming .tools/tmp, writes to the home
directory, or edits a shell rc file, or on a container whose /tmp is its
own.

Thanks to xet7 !
2026-10-27 23:49:55 +02:00
Lauri Ojansivu 7f7cc63cde GitHub Actions: no expressions in scripts, actions pinned, least privilege.
Qlty (zizmor) security findings in the workflows that build and publish
every release:

- template-injection (128): ${{ ... }} pasted into a run: script is expanded
  before the shell sees it, so a crafted workflow_dispatch input, tag or step
  output becomes shell code. 251 expressions in 13 workflows now reach their
  scripts through the step's env: and are used as quoted shell variables
  ($env:NAME in the PowerShell steps); ${{ env.X }} is plain $X. Where a
  value sat in single quotes it is double-quoted now, and six unquoted ones
  are quoted.
- unpinned-uses (20 in Qlty, 160 with current zizmor): every action is
  pinned to a commit, with its version as a comment for Dependabot.
  actions/dependency-review-action@v5 was a branch; it is v5.0.0.
- excessive-permissions (8): AppImage, Flatpak, mac, windows,
  release-all and release-all-missing grant contents: read at the workflow
  level, and each job that writes (a release asset, a git push, the docker
  push, gh run rerun) is granted that on the job. Nothing used actions:
  write except recover, which keeps it.
- artipacked (47 -> 13): actions/checkout gets persist-credentials: false,
  except in the jobs that push with the checkout's credentials, directly or
  through releases/version.sh, release-website.sh, release-charts.sh and
  backfill-charts.sh.

actionlint with shellcheck reports 50 notes, the 56 before minus the six
quoted. Every PowerShell step parses (pwsh 7.6.7). Not run on GitHub.

tests/workflowHardening.test.cjs fails on an expression in a run script,
an unpinned action, a workflow-level write grant in a multi-job workflow,
or a checkout keeping credentials outside the pushing jobs, and runs
zizmor when it is installed. Eleven guards that pinned the old text, or ran
the extracted scripts with the expressions substituted, now pin the env
form and pass the values as the step's environment.

Thanks to Qlty and xet7 !
2026-10-15 23:19:50 +03:00
copilot-swe-agent[bot]andxet7 47e007b1b1 Fix snap-variants upload path
Co-authored-by: xet7 <15545+xet7@users.noreply.github.com>
2026-09-20 23:10:53 +00:00
copilot-swe-agent[bot]andxet7 ef5ccf3fb0 Retry Snap Store HTTP 500 upload failures
Co-authored-by: xet7 <15545+xet7@users.noreply.github.com>
2026-09-20 20:35:40 +00:00
Lauri Ojansivu 0bce2330ae Fix Windows and variant release builds 2026-09-05 23:51:02 +03:00
Lauri Ojansivu c44b5af361 Exclude Dependabot from variant repository sync 2026-09-05 13:15:13 +03:00
Lauri Ojansivu abdd9750c6 Update Ondra and Gantt repositories during releases 2026-09-05 12:39:57 +03:00
Lauri Ojansivu f3f3d21a36 One release publishes all three snaps: wekan, wekan-ondra, wekan-gantt-gpl.
People are still on the older snap names, so a release that publishes only
`wekan` leaves them on a stale package. Two things stood in the way, and both
were in snap-variants.

The job gated EVERYTHING on WEKAN_REPO_TOKEN being able to push to
wekan/<variant>. Building and publishing a snap needs SNAP_AUTH and nothing
else; keeping the variant GitHub repositories in step with wekan/wekan is a
separate, optional thing. Because the two were tied together, a token without
push rights meant no variant snaps at all - that is why v10.48 and v10.49
published none. Now the guard answers two questions instead of one: `snap` (is
SNAP_AUTH set) decides the build and the publish, `sync` (may the token push)
decides only whether the repository is updated, and every "cannot push" warning
ends with "The snap is still built and published".

The variant tree is also no longer taken from a clone of the variant
repository: it is rsynced from the release tag this job checked out, with the
snap name and title sed into both snapcraft files. So the snap is built from
what was just released, whatever state the variant repository is in - and the
optional push sends that same tree on.

Both variants now build on amd64 AND arm64, the two native runners the default
snap uses, instead of amd64 only, and publish to stable + candidate + beta +
edge like the default snap: base core24, grade stable, so all four channels
accept it.

A last guard before the upload: the built file's name must start with the
variant's snap name. A build that produced wekan_*.snap here would overwrite
the DEFAULT snap in the store with a variant.

SNAP_AUTH must carry the ACL for all three names:

  snapcraft export-login --snaps wekan,wekan-ondra,wekan-gantt-gpl \
    --acls package_access,package_push,package_release,package_update \
    snap-auth.txt

tests/releaseWin64AndVariants.test.cjs pins that the build and publish depend
on `snap` and never on `sync`, that the push is the part that needs the token
and runs once per variant, that both variants cover both architectures, and
that a wrongly named snap is refused.

Thanks to xet7 !
2026-07-29 04:04:47 +03:00
Lauri Ojansivu 652a6b8501 The variant sync renames the snap in both snapcraft files, not just one.
snapcraft.yaml is what the snap-variants job builds; snapcraft-core26.yaml is
the same snap on the next base. The sync step seds only the first, so the
core26 file in wekan-ondra and wekan-gantt-gpl kept saying `name: wekan` - and
a core26 build from either repository would have published itself as the
DEFAULT WeKan snap. Both files are renamed now, and the guard pins it.

Also ignores /wekan-ondra/ and /wekan-gantt-gpl/, which is where those two
repositories are cloned when they are synced by hand from this working copy.
They are whole git repositories, so they were never at risk of being committed
into this one, but they do not need to be untracked noise either.

Thanks to xet7 !
2026-07-29 04:04:47 +03:00
Lauri Ojansivu 9b57dfd8b2 The win64 zip was never broken: SIGPIPE + pipefail turned a MATCH into a failure.
v10.49 printed the listing the previous fix added, and it settles two releases
of guessing:

  7z t: archive is intact.
  7z l -ba listed 51850 entries; the first five:
  2026-07-28 21:58:39 D....        0        0  bundle
  2026-07-28 21:52:07 .....        9        9  bundle\.node_version.txt
  2026-07-28 21:58:36 ....A  8828928  3365469  bundle\bsondump.exe
  2026-07-28 21:58:39 ....A 55313920 26791675  bundle\ferretdb.exe
  2026-07-28 21:52:07 .....      243      168  bundle\main.js
  ##[error]Process completed with exit code 141

bundle\main.js is right there, and the step still failed - with 141, which is
128+13, SIGPIPE. `printf '%s\n' "$listing" | head -5`: head has its five lines
and exits, printf is killed writing to a closed pipe, `set -o pipefail` (which
GitHub's bash sets) makes that the pipeline's status, and `set -e` ends the
step. The evidence printed, then killed the job.

The same mechanism is the ORIGINAL v10.48 failure, and this is the part worth
keeping: `printf '%s' "$listing" | grep -qF -e "bundle\main.js"` - grep -q exits
the instant it MATCHES, printf dies of SIGPIPE, pipefail reports 141, and `if !`
reads that as "not found". So "wekan-10.48-win64.zip has no bundle/main.js" was
printed BECAUSE the file was found. Reproduced both, exactly, in bash.

Every listing now goes through a file and every reader reads the file: the win64
verify, the four `unzip -l "$zip" | grep -q " $want$"` checks on the other
platforms (same trap, only luckier about the pipe buffer so far), and the five
`gh release view ... | grep -qxF` asset checks. No pipe, no SIGPIPE, no
pipefail verdict on a command that did its job.

tests/releaseWin64AndVariants.test.cjs pins that nothing in the workflow pipes a
listing into grep or head, and that the win64 verify reads its listing from a
file.

Thanks to xet7 !
2026-07-29 02:24:51 +03:00
Lauri Ojansivu 89e6189cc3 release-all.yml: fix the four things the v10.48 logs showed, and stop
misattributing the failures.

Every one of these made a release job report the wrong cause, which is worse
than the failure itself: two of them sent the last round of work after the
wrong problem.

1. snap-launchpad never checked whether a .snap existed. In three steps it did

     snaps=( wekan_${VERSION}_<arch>.snap )

   and then counted the array. That string has no wildcard, so it is a literal
   filename, `shopt -s nullglob` cannot empty a literal, and the count was
   ALWAYS 1 whether or not the file was there. So s390x logged an empty
   `Artifacts:` list, then "Remote build s390x succeeded", then

     'wekan_10.48_s390x.snap' is not a valid file
     ##[error]SNAP_AUTH did not work: the Snap Store refused the upload

   The Snap Store never saw an upload. It is a real glob now, the first match
   must also be non-empty, and the upload step says "the Launchpad build
   produced no artifact - this is NOT a SNAP_AUTH problem" for a missing file
   and keeps the credential advice for a refusal by the store.

2. The Launchpad build log was downloaded and thrown away. It is the only thing
   that says why a build ends as "Stopped", and the job printed it only when
   snapcraft's exit code was non-zero - which, after (1), it was not. It is now
   printed whenever there is no snap, along with `ls -la`, and the "exit 0 but
   nothing built" case says so in words.

3. build-win64 verified the zip by listing it into a variable and grepping that,
   so a failure printed the verdict and none of the evidence: "has no
   bundle/main.js" with no way to tell a bad zip from a bad grep. What can be
   checked robustly now is: bundle/main.js, bundle/node.exe and
   bundle/start-wekan.bat exist and are non-empty BEFORE zipping, and the
   archive passes `7z t`. The listing is printed - five lines and a match count
   per file - and a zero count is a warning naming both facts that contradict
   it, not a failed release.

4. The snap-variants pre-flight asked GitHub for `.permissions.push` on the
   variant repository. That field is the authenticated USER's role, not what the
   token may do: it answered true, and the push one step later got

     remote: Permission to wekan/wekan-gantt-gpl.git denied to xet7

   It now asks the receive-pack advertisement - the first thing a real push
   requests, and what GitHub answers 403 to for a token without Contents:write -
   with the token in curl's -u rather than in a URL, and no git command, since
   this step runs before actions/checkout.

What still needs a person is unchanged and written up in ../log/workflow/TODO.txt:
why Launchpad stops the ppc64el and s390x builds after ~20 minutes, and giving
WEKAN_REPO_TOKEN write access to the two variant repositories.

tests/releaseWin64AndVariants.test.cjs is new and pins (3) and (4);
tests/releaseSnapArches.test.cjs gains "every snaps=() must be a real glob" and
"the build log is printed whenever there is no snap", and its
"SNAP_AUTH did not work" assertion is replaced by the two messages that took its
place, with a note saying why. Both read the workflow with comments stripped -
the comments quote the broken lines on purpose.

Thanks to xet7 !
2026-07-29 00:40:21 +03:00