From 533673707358c654d8f4a6e54533143e083aed74 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 15 May 2026 02:24:35 +0000 Subject: [PATCH] chore: remove ci workflow and tests --- .gitea/workflows/ci.yaml | 17 ------ README.md | 5 -- tests/entrypoint.sh | 115 --------------------------------------- 3 files changed, 137 deletions(-) delete mode 100644 .gitea/workflows/ci.yaml delete mode 100644 tests/entrypoint.sh diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml deleted file mode 100644 index 6b95472..0000000 --- a/.gitea/workflows/ci.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: CI - -on: - push: - branches: - - develop - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install jq - run: sudo apt-get update && sudo apt-get install -y jq - - name: Run shell tests - run: bash tests/entrypoint.sh diff --git a/README.md b/README.md index d1e6a91..32a7a37 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,6 @@ jobs: KEEP_COUNT: 2 ``` -## 測試 - -- Shell 測試: [`tests/entrypoint.sh`](tests/entrypoint.sh) -- Gitea workflow: [`.gitea/workflows/ci.yaml`](.gitea/workflows/ci.yaml) - ## 相關檔案 - Action 定義: [`action.yaml`](action.yaml) diff --git a/tests/entrypoint.sh b/tests/entrypoint.sh deleted file mode 100644 index 762e3ee..0000000 --- a/tests/entrypoint.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash -set -euo pipefail - -ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -TMP_DIR="$(mktemp -d)" -trap 'rm -rf "${TMP_DIR}"' EXIT - -assert_contains() { - local needle="$1" - local haystack="$2" - - if ! grep -Fq "$needle" <<<"$haystack"; then - printf 'Expected output to contain: %s\n' "$needle" >&2 - exit 1 - fi -} - -write_mock_curl() { - cat > "${TMP_DIR}/curl" <<'EOF' -#!/bin/sh -method=GET -out_file= -headers_file= -url= -while [ "$#" -gt 0 ]; do - case "$1" in - -X) - method=$2 - shift 2 - ;; - -D) - headers_file=$2 - shift 2 - ;; - -o) - out_file=$2 - shift 2 - ;; - -w) - shift 2 - ;; - -H|-sS) - shift 1 - ;; - *) - url=$1 - shift - ;; - esac -done - -status='HTTP/1.1 200 OK' -code='200' -body='[]' - -case "$url" in - *'/api/v1/packages/test-owner?type=nuget&page=1&limit=100') - body='[{"name":"pkg-a","version":"1.0.0","created_at":"2023-01-01T00:00:00Z"},{"name":"pkg-a","version":"1.1.0","created_at":"2023-02-01T00:00:00Z"},{"name":"pkg-b","version":"0.1.0","created_at":"2023-03-01T00:00:00Z"}]' - ;; - *'/api/v1/packages/test-owner/nuget/pkg-a/1.0.0') - if [ "$method" = "DELETE" ]; then - status='HTTP/1.1 204 No Content' - code='204' - body='' - fi - ;; -esac - -printf '%s' "$body" > "$out_file" -{ - printf '%s\n' "$status" - printf 'X-Request-Id: req-123\n' -} > "$headers_file" - -if [ "$method" = "DELETE" ] && [ -n "${MOCK_DELETE_FILE:-}" ]; then - printf '%s %s\n' "$method" "$url" >> "$MOCK_DELETE_FILE" -fi - -printf '%s' "$code" -EOF - chmod +x "${TMP_DIR}/curl" -} - -run_entrypoint() { - PATH="${TMP_DIR}:$PATH" \ - GITEA_SERVER_URL="https://gitea.example.com" \ - GITEA_REPOSITORY="test-owner/test-repo" \ - env "$@" "${ROOT_DIR}/entrypoint.sh" 2>&1 -} - -write_mock_curl - -output="$(run_entrypoint INPUT_RUNNER_TOKEN=abc INPUT_KEEP_COUNT=1)" -assert_contains "Using token from inputs.RUNNER_TOKEN" "$output" -assert_contains "keep_count=1" "$output" -assert_contains "request_id=req-123" "$output" -assert_contains "Deleted package pkg-a version 1.0.0 -> 204 No Content" "$output" - -output="$(run_entrypoint GITEA_TOKEN=secret INPUT_KEEP_COUNT=1)" -assert_contains "Using token from secrets.GITEA_TOKEN" "$output" - -if run_entrypoint INPUT_KEEP_COUNT=-1 >/dev/null 2>&1; then - printf 'Expected invalid keep_count to fail\n' >&2 - exit 1 -fi - -if run_entrypoint >/dev/null 2>&1; then - printf 'Expected missing token to fail\n' >&2 - exit 1 -fi - -delete_log="${TMP_DIR}/delete.log" -output="$(MOCK_DELETE_FILE="$delete_log" run_entrypoint INPUT_RUNNER_TOKEN=abc INPUT_KEEP_COUNT=1)" -assert_contains "Summary: packages=2 versions=3 kept=2 candidates=1 deleted=1 errors=0" "$output" -assert_contains "DELETE https://gitea.example.com/api/v1/packages/test-owner/nuget/pkg-a/1.0.0" "$(cat "$delete_log")"