fix: use storage.ErrNotFound sentinel for consistent 404 across backends #117
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Test | |
| on: | |
| push: | |
| branches: ["main", "dev"] | |
| pull_request: | |
| branches: ["main", "dev"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| actions: read | |
| env: | |
| GO_VERSION_LATEST: "1.25" | |
| jobs: | |
| integration-test: | |
| name: Integration Test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' | |
| strategy: | |
| matrix: | |
| go-version: ["1.24", "1.25"] | |
| upload_auth: ["true", "false"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Build nclip binary | |
| env: | |
| CGO_ENABLED: 0 | |
| run: | | |
| VERSION="test-${GITHUB_SHA:0:7}" | |
| go build -v \ | |
| -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ) -X main.gitCommit=${GITHUB_SHA:0:7}" \ | |
| -o nclip \ | |
| . | |
| chmod +x nclip | |
| - name: Start nclip server (filesystem backend) | |
| env: | |
| NCLIP_PORT: 8080 | |
| NCLIP_DATA_DIR: ./data | |
| GIN_MODE: release | |
| run: | | |
| mkdir -p "${NCLIP_DATA_DIR}" | |
| echo "Starting nclip server (filesystem backend only)..." | |
| # When upload_auth is true, the job should set API keys so tests can auth | |
| if [ "${{ matrix.upload_auth }}" = "true" ]; then | |
| TEST_KEY=$(openssl rand -hex 12) | |
| echo "NCLIP_UPLOAD_AUTH=true" >> $GITHUB_ENV | |
| echo "NCLIP_API_KEYS=$TEST_KEY" >> $GITHUB_ENV | |
| echo "NCLIP_TEST_API_KEY=$TEST_KEY" >> $GITHUB_ENV | |
| export NCLIP_UPLOAD_AUTH=true | |
| export NCLIP_API_KEYS=$TEST_KEY | |
| export NCLIP_TEST_API_KEY=$TEST_KEY | |
| echo "Generated test API key for upload auth" | |
| else | |
| echo "NCLIP_UPLOAD_AUTH=false" >> $GITHUB_ENV | |
| export NCLIP_UPLOAD_AUTH=false | |
| fi | |
| # start server with logs redirected and persist pid so later steps can stop it | |
| nohup ./nclip > nclip.log 2>&1 & | |
| echo $! > server.pid | |
| echo "SERVER_PID=$(cat server.pid)" >> $GITHUB_ENV | |
| chmod +r nclip.log || true | |
| echo "nclip started with PID: $(cat server.pid)" | |
| - name: Wait for nclip /health | |
| run: | | |
| set -euo pipefail | |
| URL="http://127.0.0.1:${NCLIP_PORT:-8080}/health" | |
| for i in $(seq 1 60); do | |
| if curl -sSf "$URL" >/dev/null 2>&1; then | |
| echo "nclip ready" | |
| exit 0 | |
| fi | |
| echo "waiting for nclip... ($i/60)" | |
| sleep 1 | |
| done | |
| echo "nclip did not become ready; printing nclip.log" | |
| sed -n '1,200p' nclip.log || true | |
| exit 1 | |
| - name: Run integration tests | |
| env: | |
| NCLIP_URL: http://localhost:8080 | |
| NCLIP_UPLOAD_AUTH: ${{ matrix.upload_auth }} | |
| NCLIP_DATA_DIR: ./data | |
| run: | | |
| echo "Running integration tests (upload_auth=${{ matrix.upload_auth }})..." | |
| # Export any NCLIP_* values injected into the environment by the previous step | |
| if [ -n "${NCLIP_API_KEYS:-}" ]; then export NCLIP_API_KEYS="$NCLIP_API_KEYS"; fi | |
| if [ -n "${NCLIP_TEST_API_KEY:-}" ]; then export NCLIP_TEST_API_KEY="$NCLIP_TEST_API_KEY"; fi | |
| # Run unified integration test suite (orchestrates all test scripts) | |
| bash scripts/integration-test.sh | |
| - name: Stop nclip server | |
| if: always() | |
| run: | | |
| if [ -f server.pid ]; then | |
| PID=$(cat server.pid) | |
| echo "Stopping nclip server (PID: $PID)" | |
| kill $PID || true | |
| sleep 2 | |
| kill -9 $PID 2>/dev/null || true | |
| fi | |
| - name: Upload integration test artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-artifacts-${{ matrix.go-version }}-run${{ github.run_id }} | |
| path: | | |
| nclip | |
| scripts/ | |
| nclip.log | |
| server.pid | |
| retention-days: 7 |