Compare commits

..

21 commits

Author SHA1 Message Date
4fa36f7bde Use black to format the file 2024-03-13 22:16:50 -07:00
b3be74ad3a Add Dockerfile
This sets up the docker container with the necessary dependencies to run the
tasks.
2024-03-07 11:56:34 -08:00
8919ef3dc3 Reorganize assets to match script 2024-03-07 09:56:51 -08:00
21b2e300a2 Add pre-receive hook that blocks binary files
The documentation[1] says that the ‘--numstat’ option for ‘git diff’ will
display ‘-’ for both added and deleted lines for binary files. This script uses
that to detect that binary files are being pushed and will reject them.

This is naive and simplistic. ‘git diff’ shows the same output when binary files
are deleted (or replaced with git-lfs placeholders), so this would prevent us
from fixing errors. But for now it helps us prevent accidental submissions of
binary files.

[1]: man 1 git-diff
2024-02-22 15:48:06 -08:00
bf97e83d24 Add a build script
This script does what was previously done by the git hook script. It takes the
commit before the push and the one after the push and lists the directories that
have been affected in those commits.

This script doesn't yet start an actual process for processing the directories,
it just prints what it thinks a command line might look like.
2023-12-16 23:52:35 -08:00
7f1c755c4e Reduce scope of the git hook script
The git hook script should only extract the necessary information the build
script needs to operate. Right now this is only the commit before the push and
after the push, and the refname is added for future use.

The name of the variables passed to the laminar build are modeled after those
found in the GitLab CI documentation, just for some familiarity.

The functionality of finding the relevant directories has been moved to the
build script.
2023-12-16 23:50:11 -08:00
ae458763ae Add song 2023-12-16 23:46:31 -08:00
eb9f6dc3b1 Add song 2023-12-16 23:46:20 -08:00
72dad84521 Add song 2023-12-16 23:37:06 -08:00
60576fdfe3 Add song 2023-12-16 23:32:18 -08:00
4eb97db9d2 Add song 2023-12-16 23:25:41 -08:00
efd2798f01 Add song 2023-12-16 23:22:45 -08:00
6324734318 Add song 2023-12-16 23:19:49 -08:00
07561cb73f Add song 2023-12-16 23:16:28 -08:00
714382db9f Add song 2023-12-15 14:28:12 -08:00
fff0b171aa Replace git hook with a python script 2023-12-15 12:31:38 -08:00
b02f37cfe4 Add new song 2023-12-15 12:13:00 -08:00
2903951000 Track file with LFS
I think I didn't have git-lfs installed on the machine where I submitted this
file, it seems to be trying to fix that now.
2023-12-15 11:15:54 -08:00
f9b62b2168 Add new song 2023-12-13 14:57:37 -08:00
8db9e084af Move song to more appropriate location 2023-12-13 14:54:31 -08:00
62e1bdf491 Add post-receive script to list modified files 2023-12-13 14:54:05 -08:00
17 changed files with 114 additions and 8 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
*

9
Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM python:3.12-slim
RUN apt update && apt install -y ffmpeg && pip install invoke
VOLUME ["/data"]
WORKDIR /data
CMD /usr/local/bin/invoke probe

BIN
assets/All_I_Want_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Angel_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Go_And_Die_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Heavens_Bells_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/If_You_Want_To_Die_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Last_Day_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Liar_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Loss_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Memories_-_Concrete_Foundation.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Metal_Attack_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/Twisted_Games_-_Grimoff.ogg (Stored with Git LFS) Normal file

Binary file not shown.

28
build/freeloadio.run Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env python
from os import getenv
from os.path import dirname
from re import match
from shlex import quote
from subprocess import run
commit_before_sha = getenv("CI_COMMIT_BEFORE_SHA")
commit_sha = getenv("CI_COMMIT_SHA")
commit_ref_name = getenv("CI_COMMIT_REF_NAME")
directories = set()
cmd = "git clone https://code.ryuslash.org/ryuslash/git-lfs-test.git ."
print(cmd)
run(cmd, shell=True)
if not match(r"^0+$", commit_before_sha):
cmd = f"git diff --name-only {quote(commit_before_sha)} {quote(commit_sha)}"
print(cmd)
process = run(cmd, shell=True, capture_output=True)
process_output = process.stdout.decode()
print(process_output)
for filename in process_output.strip().split("\n"):
directories.add(dirname(filename))
unix_directory_list = str.join(":", directories)
print(f"python tasks.py probe --directories={quote(unix_directory_list)}")

View file

@ -1,9 +1,23 @@
#!/usr/bin/env bash
#!/usr/bin/env python
while read precommit postcommit refname
do
echo "precommit: ${precommit}; postcommit: ${postcommit}; refname: ${refname}"
if [[ "${precommit}" != "0000000000000000000000000000000000000000" ]]; then
git diff --name-status $precommit $postcommit
fi
done
from shlex import quote
from subprocess import run
import os
import sys
for line in sys.stdin:
precommit, postcommit, refname = line.strip().split(' ')
if not refname == "refs/heads/main":
print(f"Skipping ref \"{refname}\"")
continue
os.putenv("LAMINAR_REASON", "Push to git repository")
cmd = "laminarc queue freeloadio " \
f"CI_COMMIT_BEFORE_SHA={quote(precommit)} " \
f"CI_COMMIT_SHA={quote(postcommit)} " \
f"CI_COMMIT_REF_NAME={quote(refname)}"
print(cmd)
process = run(cmd, shell=True, capture_output=True)
buildname, buildrun = process.stdout.decode().strip().split(':')
print(f"Queued build: https://laminar.ryuslash.org/jobs/{buildname}/{buildrun}")

21
build/git-pre-receive-hook Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
block_push=0
while read -r old new refname; do
while read -r added deleted filename; do
if [[ "$added" == "-" && "$deleted" == "-" ]]; then
block_push=1
echo "ERROR: ${filename} is a binary file."
fi
done < <(git diff --numstat "${old}..${new}")
if [[ $block_push -eq 1 ]]; then
echo "The ref '${refname}' has been rejected"
fi
done
if [[ $block_push -eq 1 ]]; then
echo "Binary files blocked. Please use git-lfs to push to this repo."
exit 1
fi