Files
Copyparty-content-tag/.gitea/workflows/ci.yaml
T
Frog-Lover-Antony a7c20687aa
CI / test (push) Failing after 11s
CI / release (push) Has been skipped
CI v3
2026-07-18 19:13:45 +03:00

129 lines
3.8 KiB
YAML

# Gitea Actions — Copyparty Content Tag CI
# Runs on docker runner; every step uses a Docker container for its dependencies.
name: CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
release:
types: [created]
env:
WS: /workspace
GITEA_HOST: gitea.mse:80
jobs:
test:
runs-on: docker
container:
image: alpine:latest
steps:
# --- Clone repo using x-access-token auth ---
- name: Checkout Source
run: |
apk add --no-cache git
rm -rf $WS
mkdir -p $WS
cd $WS
git clone "http://x-access-token:${{ secrets.PKG_TOKEN }}@${{ env.GITEA_HOST }}/${{ github.repository }}.git" .
git checkout ${{ github.sha }}
# --- TSV Unit Tests inside Node container ---
- name: TSV Unit Tests
run: |
docker run --rm \
-v $WS:$WS \
-w $WS/tests \
node:22-slim \
node tsv-test.js
# --- Copyparty API Sanity Tests ---
- name: Prepare Test Data & Config
run: |
mkdir -p /tmp/copyparty-data/public /tmp/copyparty-data/private/user
cat > /tmp/copyparty-config.ini <<'EOF'
[global]
p = 8086
[accounts]
user = 12345
[/public/]
/data/public
accs:
r = *
[/private/user]
/data/private/user
accs:
A = user
EOF
- name: Start Copyparty Test Server
run: |
apk add --no-cache curl
docker run -d --name cp-test \
-p 8086:8086 \
-v /tmp/copyparty-data:/data \
-v /tmp/copyparty-config.ini:/etc/copyparty/config.ini:ro \
-e CP_CONFIG=/etc/copyparty/config.ini \
9001/copyparty:latest \
|| { docker restart cp-test; true }
# Wait for server to be ready
for i in $(seq 1 30); do
curl -sf http://localhost:8086/?ls >/dev/null 2>&1 && break
sleep 2
done
- name: API Sanity Tests (in job container)
run: |
apk add --no-cache curl jq bash
cd $WS/tests && bash api-tests.sh
- name: Cleanup Test Container
if: always()
run: docker stop cp-test && docker rm cp-test || true
# --- Release Build ---
release:
needs: test
if: github.event_name == 'release'
runs-on: docker
container:
image: alpine:latest
steps:
- name: Checkout Source
run: |
apk add --no-cache git
rm -rf $WS
mkdir -p $WS
cd $WS
git clone "http://x-access-token:${{ secrets.PKG_TOKEN }}@${{ env.GITEA_HOST }}/${{ github.repository }}.git" .
git checkout ${{ github.sha }}
# --- Build release artifact ---
- name: Build Release Artifact
run: |
apk add --no-cache tar coreutils
cd $WS
mkdir -p release/copyparty-content-tag
cp src/*.html src/*.css src/*.js release/copyparty-content-tag/
cd release
sha256sum copyparty-content-tag/* > checksums.sha256
tar czf copyparty-content-tag.tar.gz copyparty-content-tag/
# --- Upload to Gitea Release via API (no JS action needed) ---
- name: Upload Release Artifact
run: |
apk add --no-cache curl
TAG=$(echo "${{ github.ref }}" | sed 's|refs/tags||')
curl -sSf -X POST \
-H "Authorization: token ${{ secrets.PKG_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @$WS/release/copyparty-content-tag.tar.gz \
"http://${{ env.GITEA_HOST }}/api/v1/repos/${{ github.repository }}/releases.attachments?name=copyparty-content-tag.tar.gz&tag=$TAG"