mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
ci(block): release job refuses an asset whose binaries are not executable
The release job lists the tarball (tar -tvzf) before SHA256SUMS and any upload, and stops unless blockmaster, blockvolume and sw-block are all present with exec bits for owner, group and other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1c7679a29
commit
90f6d7cfea
2 files changed
+36
-1
No files matched your search
@@ -138,6 +138,22 @@ jobs:
|
||||
cp seaweed-block/deploy/systemd/sw-block.tmpfiles.conf "$out/bin/sw-block.tmpfiles.conf"
|
||||
asset="sw-block-${version}-linux-amd64.tar.gz"
|
||||
tar -C "$out/bin" -czf "$out/$asset" blockmaster blockvolume sw-block sw-block.tmpfiles.conf
|
||||
# Before any upload: every binary in the asset is executable as shipped (tar tvf).
|
||||
executables=0
|
||||
while read -r perms _ _ _ _ name; do
|
||||
case "$name" in
|
||||
blockmaster|blockvolume|sw-block)
|
||||
if [[ ! "$perms" =~ ^-..x..x..x$ ]]; then
|
||||
echo "refusing to publish: $name in $asset is $perms, not executable" >&2
|
||||
exit 1
|
||||
fi
|
||||
executables=$((executables + 1)) ;;
|
||||
esac
|
||||
done < <(tar -tvzf "$out/$asset")
|
||||
if [ "$executables" != 3 ]; then
|
||||
echo "refusing to publish: $asset lists $executables of 3 binaries" >&2
|
||||
exit 1
|
||||
fi
|
||||
(cd "$out" && sha256sum "$asset" >SHA256SUMS)
|
||||
prerelease=false
|
||||
if [[ "$version" == *-* ]]; then prerelease=true; fi
|
||||
|
||||
+20
-1
@@ -1,6 +1,6 @@
|
||||
"""Exercise release packaging without Docker, GitHub writes or product builds."""
|
||||
from pathlib import Path
|
||||
import json, os, subprocess, tarfile, tempfile, unittest
|
||||
import json, os, shutil, subprocess, tarfile, tempfile, unittest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
REV = "a" * 40
|
||||
@@ -8,6 +8,14 @@ DIGEST = "example.invalid/block@sha256:" + "b" * 64
|
||||
|
||||
class ReleaseAssets(unittest.TestCase):
|
||||
def test_active_root_release_contains_tmpfiles(self):
|
||||
self.run_active_root()
|
||||
|
||||
def test_active_root_release_refuses_an_archive_without_exec_bits(self):
|
||||
# An archive whose binaries lost their exec bits (as a tar made off the
|
||||
# Linux job does) stops the job before SHA256SUMS or any upload.
|
||||
self.run_active_root(strip_exec=True)
|
||||
|
||||
def run_active_root(self, strip_exec=False):
|
||||
repo = HERE.parents[2]
|
||||
workflow = (repo / '.github/workflows/block-release.yml').read_text()
|
||||
step = workflow.split(' - name: Publish matching binary tarball\n', 1)[1]
|
||||
@@ -20,6 +28,9 @@ class ReleaseAssets(unittest.TestCase):
|
||||
for name in ('blockmaster', 'blockvolume', 'sw-block'):
|
||||
(image / name).write_bytes(('#!/bin/sh\necho '+name+' release\n').encode())
|
||||
(image / name).chmod(0o755)
|
||||
if strip_exec:
|
||||
real = shutil.which('tar')
|
||||
(tools / 'tar').write_text('#!/bin/sh\ncase "$*" in *-czf*) exec ' + real + ' --mode=a-x "$@";; esac\nexec ' + real + ' "$@"\n')
|
||||
(tools / 'docker').write_text('''#!/usr/bin/env python3
|
||||
import os,pathlib,shutil,sys
|
||||
a=sys.argv[1:]
|
||||
@@ -34,8 +45,16 @@ elif a[0]=='cp': shutil.copy2(pathlib.Path(os.environ['IMAGE'])/a[1].rsplit('/',
|
||||
GITHUB_REPOSITORY='example/block', NOTES=str(root/'notes'))
|
||||
result = subprocess.run(['bash', '-c', script], cwd=repo, env=env,
|
||||
capture_output=True, text=True, timeout=15)
|
||||
if strip_exec:
|
||||
self.assertNotEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn('refusing to publish: blockmaster', result.stderr)
|
||||
self.assertFalse((root/'block-release/SHA256SUMS').exists())
|
||||
return
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
with tarfile.open(root/'block-release/sw-block-v1.1.2-linux-amd64.tar.gz') as tar:
|
||||
for member in tar.getmembers():
|
||||
if member.name != 'sw-block.tmpfiles.conf':
|
||||
self.assertEqual(member.mode & 0o111, 0o111, member.name)
|
||||
self.assertEqual(set(tar.getnames()), {'blockmaster', 'blockvolume', 'sw-block', 'sw-block.tmpfiles.conf'})
|
||||
self.assertEqual(tar.extractfile('sw-block.tmpfiles.conf').read(),
|
||||
(repo/'seaweed-block/deploy/systemd/sw-block.tmpfiles.conf').read_bytes())
|
||||
|
||||
Reference in new issue
Block a user