Update .gitea/workflows/ci.yml
Some checks failed
Generate Map Previews for Switzerland25 Tournament / Full CI/CD Pipeline (push) Failing after 50s

This commit is contained in:
Arlind
2025-09-19 13:30:37 +02:00
parent ff21ca3606
commit 617af3be85

View File

@@ -1,221 +1,226 @@
name: Generate Map Previews for Switzerland25 Tournament name: Generate Map Previews for Switzerland25 Tournament
on: on:
push: push:
paths: paths:
- '.gitea/workflows/*' - '.gitea/workflows/*'
- 'replays/**' - 'replays/**'
workflow_dispatch: workflow_dispatch:
env: env:
DANSER_PATH: "/app/danser/danser-cli" DANSER_PATH: "/app/danser/danser-cli"
DANSER_DIR: "/app/danser" DANSER_DIR: "/app/danser"
DANSER_VIDEO_DIR: "/app/danser/videos" DANSER_VIDEO_DIR: "/app/danser/videos"
DANSER_SKINS_DIR: "/app/danser/skins" DANSER_SKINS_DIR: "/app/danser/skins"
DANSER_MAPS_DIR: "/app/danser/songs" DANSER_MAPS_DIR: "/app/danser/songs"
SKINS_DIR: "${{ github.workspace }}/skins" SKINS_DIR: "${{ github.workspace }}/skins"
REPLAY_DIR: "${{ github.workspace }}/replays" REPLAY_DIR: "${{ github.workspace }}/replays"
MAPS_DIR: "${{ github.workspace }}/maps" MAPS_DIR: "${{ github.workspace }}/maps"
OUTPUT_DIR: "${{ github.workspace }}/outputs" OUTPUT_DIR: "${{ github.workspace }}/outputs"
TIMESTAMPS_JSON: "${{ github.workspace }}/.gitea/workflows/timestamps.json" TIMESTAMPS_JSON: "${{ github.workspace }}/.gitea/workflows/timestamps.json"
IMAGE_NAME: osc/skins-image IMAGE_NAME: osc/skins-image
REGISTRY_URL: "https://${{ vars.CONTAINER_REGISTRY }}" REGISTRY_URL: "https://${{ vars.CONTAINER_REGISTRY }}"
jobs: jobs:
generate_everything: generate_everything:
name: Full CI/CD Pipeline name: Full CI/CD Pipeline
runs-on: danser runs-on: danser
container: container:
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
options: >- options: >-
--gpus all --gpus all
--privileged --privileged
--security-opt seccomp=unconfined --security-opt seccomp=unconfined
--security-opt apparmor=unconfined --security-opt apparmor=unconfined
--cap-add=ALL --cap-add=ALL
--env NVIDIA_DRIVER_CAPABILITIES=all --env NVIDIA_DRIVER_CAPABILITIES=all
--env NVIDIA_VISIBLE_DEVICES=all --env NVIDIA_VISIBLE_DEVICES=all
--user 0:0 --user 0:0
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
tags: true tags: true
lfs: true lfs: true
- name: Set XDG_RUNTIME_DIR - name: Set XDG_RUNTIME_DIR
shell: bash shell: bash
run: | run: |
echo "Setting XDG_RUNTIME_DIR..." echo "Setting XDG_RUNTIME_DIR..."
mkdir -p /tmp/xdg_runtime_dir mkdir -p /tmp/xdg_runtime_dir
chmod 0700 /tmp/xdg_runtime_dir chmod 0700 /tmp/xdg_runtime_dir
echo "XDG_RUNTIME_DIR=/tmp/xdg_runtime_dir" >> "$GITHUB_ENV" echo "XDG_RUNTIME_DIR=/tmp/xdg_runtime_dir" >> "$GITHUB_ENV"
echo "XDG_RUNTIME_DIR set." echo "XDG_RUNTIME_DIR set."
- name: Move necessary files to Danser directory - name: Move necessary files to Danser directory
shell: bash shell: bash
run: | run: |
echo "Moving necessary files to Danser directory..." echo "Moving necessary files to Danser directory..."
mkdir -p "$DANSER_SKINS_DIR" mkdir -p "$DANSER_SKINS_DIR"
mv "$SKINS_DIR"/* "$DANSER_SKINS_DIR" mv "$SKINS_DIR"/* "$DANSER_SKINS_DIR"
mkdir -p "$DANSER_MAPS_DIR" mkdir -p "$DANSER_MAPS_DIR"
find "$MAPS_DIR" -type f -name '*.osz' -exec mv -t "$DANSER_MAPS_DIR" {} + find "$MAPS_DIR" -type f -name '*.osz' -exec mv -t "$DANSER_MAPS_DIR" {} +
echo "Files moved." echo "Files moved."
- name: Generate Danser videos - name: Generate Danser videos
shell: bash shell: bash
run: | run: |
set +e set +e
JSON_FILE="$TIMESTAMPS_JSON" JSON_FILE="$TIMESTAMPS_JSON"
mapfile -t REPLAYS < <(find "$REPLAY_DIR" -type f -name "*.osr") mapfile -t REPLAYS < <(find "$REPLAY_DIR" -type f -name "*.osr")
if [ ! -f "$JSON_FILE" ]; then if [ ! -f "$JSON_FILE" ]; then
echo "WARNING: Timestamps JSON file not found at $JSON_FILE - skipping video generation" echo "WARNING: Timestamps JSON file not found at $JSON_FILE - skipping video generation"
exit 0 exit 0
fi fi
echo "Found $(echo "${REPLAYS[@]}" | wc -w) replay files" echo "Found $(echo "${REPLAYS[@]}" | wc -w) replay files"
choose_skin() { choose_skin() {
local name="$1" local name="$1"
case "$name" in case "$name" in
*FM*) echo "Aristia(Edit)+trail" ;; *FM*) echo "Aristia(Edit)+trail" ;;
*HD*) echo "Aristia(Edit)+trail" ;; *HD*) echo "Aristia(Edit)+trail" ;;
*DT*) echo "boop" ;; *DT*) echo "boop" ;;
*EZ*) echo "Jace 6.25" ;; *EZ*) echo "Jace 6.25" ;;
*TB*) echo "Aristia(Edit)+trail" ;; *TB*) echo "Aristia(Edit)+trail" ;;
*HR*) echo "Aristia(Edit)+trail" ;; *HR*) echo "Aristia(Edit)+trail" ;;
*) echo "Aristia(Edit)+trail" ;; *) echo "Aristia(Edit)+trail" ;;
esac esac
} }
processed=0 processed=0
skipped=0 skipped=0
for REPLAY in "${REPLAYS[@]}"; do for REPLAY in "${REPLAYS[@]}"; do
if [ ! -f "$REPLAY" ]; then if [ ! -f "$REPLAY" ]; then
echo "WARNING: Replay file not found: $REPLAY" echo "WARNING: Replay file not found: $REPLAY"
continue continue
fi fi
REPLAY_NAME=$(basename "$REPLAY" .osr) REPLAY_NAME=$(basename "$REPLAY" .osr)
STAGE="${REPLAY_NAME%%_*}" STAGE="${REPLAY_NAME%%_*}"
echo "Processing replay: $REPLAY_NAME" echo "Processing replay: $REPLAY_NAME"
ENTRY=$(jq -c --arg name "$REPLAY_NAME" ' ENTRY=$(jq -c --arg name "$REPLAY_NAME" '
.[] | map(select(.name == $name)) | .[]' "$JSON_FILE" 2>/dev/null) .[] | map(select(.name == $name)) | .[]' "$JSON_FILE" 2>/dev/null)
if [ -z "$ENTRY" ]; then if [ -z "$ENTRY" ]; then
echo " No timestamp entry found for $REPLAY_NAME - skipping" echo " No timestamp entry found for $REPLAY_NAME - skipping"
((skipped++)) ((skipped++))
continue continue
fi fi
DONE=$(echo "$ENTRY" | jq -r '.done' 2>/dev/null) DONE=$(echo "$ENTRY" | jq -r '.done' 2>/dev/null)
if [ "$DONE" = "true" ]; then if [ "$DONE" = "true" ]; then
echo " Already processed $REPLAY_NAME - skipping" echo " Already processed $REPLAY_NAME - skipping"
((skipped++)) ((skipped++))
continue continue
fi fi
START=$(echo "$ENTRY" | jq -r '.start' 2>/dev/null) START=$(echo "$ENTRY" | jq -r '.start' 2>/dev/null)
END=$(echo "$ENTRY" | jq -r '.end' 2>/dev/null) END=$(echo "$ENTRY" | jq -r '.end' 2>/dev/null)
if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then
echo " Invalid timestamp format for $REPLAY_NAME - skipping" echo " Invalid timestamp format for $REPLAY_NAME - skipping"
((skipped++)) ((skipped++))
continue continue
fi fi
if [ "$START" -eq 0 ] && [ "$END" -eq 0 ]; then if [ "$START" -eq 0 ] && [ "$END" -eq 0 ]; then
echo " No timestamps set for $REPLAY_NAME - skipping" echo " No timestamps set for $REPLAY_NAME - skipping"
((skipped++)) ((skipped++))
continue continue
fi fi
OUT_VIDEO_DIR="$OUTPUT_DIR/$STAGE" OUT_VIDEO_DIR="$OUTPUT_DIR/$STAGE"
OUT_VIDEO_FILE="$OUT_VIDEO_DIR/$REPLAY_NAME.mp4" OUT_VIDEO_FILE="$OUT_VIDEO_DIR/$REPLAY_NAME.mp4"
mkdir -p "$OUT_VIDEO_DIR" 2>/dev/null mkdir -p "$OUT_VIDEO_DIR" 2>/dev/null
SKIN=$(choose_skin "$REPLAY_NAME") SKIN=$(choose_skin "$REPLAY_NAME")
echo " Using skin: $SKIN" echo " Using skin: $SKIN"
echo " Timestamps: ${START}s - ${END}s" echo " Timestamps: ${START}s - ${END}s"
echo " Generating video with danser-cli..." echo " Generating video with danser-cli..."
if ! xvfb-run -a "$DANSER_DIR/danser-cli" \ if ! xvfb-run -a "$DANSER_DIR/danser-cli" \
-replay "$REPLAY" -record -skip -settings="tourneypreview" -skin="$SKIN" -start=$START -end=$END -noupdatecheck \ -replay "$REPLAY" -record -skip -settings="tourneypreview" -skin="$SKIN" -start=$START -end=$END -noupdatecheck \
-out="$REPLAY_NAME" >/dev/null 2>&1; then -out="$REPLAY_NAME" >/dev/null 2>&1; then
echo " ERROR: Danser failed for $REPLAY_NAME" echo " ERROR: Danser failed for $REPLAY_NAME"
((skipped++)) ((skipped++))
continue continue
fi fi
if [ -f "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" ]; then if [ -f "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" ]; then
echo " Moving video to output directory..." echo " Moving video to output directory..."
mv "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" "$OUT_VIDEO_FILE" 2>/dev/null mv "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" "$OUT_VIDEO_FILE" 2>/dev/null
echo " Post-processing with ffmpeg..." echo " Post-processing with ffmpeg..."
ffmpeg_output=$(ffmpeg -hide_banner -loglevel error \ ffmpeg_output=$(ffmpeg -hide_banner -loglevel error \
-ss 5 \ -ss 5 \
-i "$OUT_VIDEO_FILE" \ -i "$OUT_VIDEO_FILE" \
-c:v h264_nvenc -preset slow -rc vbr -cq 19 -b:v 10M -maxrate 20M \ -c:v h264_nvenc -preset slow -rc vbr -cq 19 -b:v 10M -maxrate 20M \
-c:a aac -b:a 192k \ -c:a aac -b:a 192k \
"${OUT_VIDEO_FILE}.tmp.mp4" 2>&1) "${OUT_VIDEO_FILE}.tmp.mp4" 2>&1)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo " ERROR: FFmpeg failed for $REPLAY_NAME:" echo " ERROR: FFmpeg failed for $REPLAY_NAME:"
echo "$ffmpeg_output" echo "$ffmpeg_output"
((skipped++)) ((skipped++))
continue continue
fi fi
mv "${OUT_VIDEO_FILE}.tmp.mp4" "$OUT_VIDEO_FILE" 2>/dev/null mv "${OUT_VIDEO_FILE}.tmp.mp4" "$OUT_VIDEO_FILE" 2>/dev/null
echo " Marking as completed in timestamps..." echo " Marking as completed in timestamps..."
tmp=$(mktemp) tmp=$(mktemp)
jq --arg name "$REPLAY_NAME" ' jq --arg name "$REPLAY_NAME" '
(.. | objects | select(has("name")) | select(.name == $name)) (.. | objects | select(has("name")) | select(.name == $name))
|= (.done = true)' "$JSON_FILE" > "$tmp" && mv "$tmp" "$JSON_FILE" 2>/dev/null |= (.done = true)' "$JSON_FILE" > "$tmp" && mv "$tmp" "$JSON_FILE" 2>/dev/null
echo " Successfully generated: $OUT_VIDEO_FILE" echo " Successfully generated: $OUT_VIDEO_FILE"
((processed++)) ((processed++))
else else
echo " Failed to generate video for $REPLAY_NAME" echo " Failed to generate video for $REPLAY_NAME"
fi fi
done done
echo "" echo ""
echo "Summary:" echo "Summary:"
echo " Videos processed: $processed" echo " Videos processed: $processed"
echo " Files skipped: $skipped" echo " Files skipped: $skipped"
exit 0 exit 0
- name: Configure Git - name: test
shell: bash shell: bash
run: | run: |
echo "Configuring Git user settings..." cat /app/danser/settings/default.json
git config user.email "arlind@sulej.ch"
git config user.name "ci-bot" - name: Configure Git
echo "Git user configured." shell: bash
run: |
- name: Add and Commit changes echo "Configuring Git user settings..."
shell: bash git config user.email "arlind@sulej.ch"
run: | git config user.name "ci-bot"
echo "Configuring Git settings..." echo "Git user configured."
git config advice.addIgnoredFile false
- name: Add and Commit changes
echo "Adding output files to Git..." shell: bash
git add outputs/ run: |
echo "Configuring Git settings..."
echo "Committing changes..." git config advice.addIgnoredFile false
git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
echo "Adding output files to Git..."
- name: Push changes and create tag git add outputs/
shell: bash
run: | echo "Committing changes..."
echo "Pushing changes to repository..." git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
git push origin main || echo "No changes to push"
- name: Push changes and create tag
shell: bash
run: |
echo "Pushing changes to repository..."
git push origin main || echo "No changes to push"