Skip to content

fix: include dist/ in repository for GitHub Actions #29

fix: include dist/ in repository for GitHub Actions

fix: include dist/ in repository for GitHub Actions #29

Workflow file for this run

# Test workflow for ExFig Action
# Tests TypeScript build, unit tests, and E2E without requiring Figma credentials
name: Test Action
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
# ============================================================================
# TypeScript Build & Unit Tests
# ============================================================================
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format:check
- name: Lint
run: npm run lint
- name: Type check
run: npx tsc --noEmit
- name: Run unit tests
run: npm test -- --coverage
- name: Build
run: npm run build
- name: Verify dist/index.js exists
run: |
if [[ -f "dist/index.js" ]]; then
echo "✓ dist/index.js exists"
ls -la dist/
else
echo "✗ dist/index.js not found"
exit 1
fi
# ============================================================================
# E2E Tests - Version Resolution
# ============================================================================
test-version-resolution:
name: Test version resolution
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v6
- name: Resolve latest version
id: resolve
env:
GH_TOKEN: ${{ github.token }}
run: |
RESPONSE=$(curl -sL -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/alexey1312/exfig/releases/latest")
VERSION=$(echo "$RESPONSE" | jq -r '.tag_name' 2>/dev/null || echo "")
if [[ -z "$VERSION" || "$VERSION" == "null" ]]; then
echo "✗ Failed to resolve latest version"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "✓ Resolved latest version: $VERSION"
- name: Verify version format
run: |
VERSION="${{ steps.resolve.outputs.version }}"
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "✓ Version format is valid: $VERSION"
else
echo "✗ Invalid version format: $VERSION (expected v-prefixed semver)"
exit 1
fi
# ============================================================================
# E2E Tests - Binary Download
# ============================================================================
test-binary-download:
name: Test binary download (${{ matrix.os }})
needs: build-and-test
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Resolve version
id: resolve
env:
GH_TOKEN: ${{ github.token }}
run: |
RESPONSE=$(curl -sL -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/alexey1312/exfig/releases/latest")
if command -v jq &>/dev/null; then
VERSION=$(echo "$RESPONSE" | jq -r '.tag_name' 2>/dev/null || echo "")
else
VERSION=$(echo "$RESPONSE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' || echo "")
fi
if [[ -z "$VERSION" || "$VERSION" == "null" ]]; then
echo "✗ Failed to resolve latest version"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Download ExFig binary
env:
VERSION: ${{ steps.resolve.outputs.version }}
RUNNER_TEMP: ${{ runner.temp }}
RUNNER_OS: ${{ runner.os }}
run: |
INSTALL_DIR="${RUNNER_TEMP}/exfig"
mkdir -p "$INSTALL_DIR"
if [[ "$RUNNER_OS" == "macOS" ]]; then
ARCHIVE="exfig-macos.zip"
else
ARCHIVE="exfig-linux-x64.tar.gz"
fi
DOWNLOAD_URL="https://github.com/alexey1312/exfig/releases/download/${VERSION}/${ARCHIVE}"
echo "Downloading ExFig ${VERSION} (${ARCHIVE})..."
echo "URL: ${DOWNLOAD_URL}"
HTTP_CODE=$(curl -sL -w "%{http_code}" -o "${RUNNER_TEMP}/${ARCHIVE}" "${DOWNLOAD_URL}")
if [[ "$HTTP_CODE" != "200" ]]; then
echo "✗ Failed to download ExFig. HTTP status: ${HTTP_CODE}"
exit 1
fi
cd "${RUNNER_TEMP}"
if [[ "$ARCHIVE" == *.zip ]]; then
unzip -o "${ARCHIVE}" -d "${INSTALL_DIR}"
else
tar -xzf "${ARCHIVE}" -C "${INSTALL_DIR}"
fi
chmod +x "${INSTALL_DIR}/ExFig"
echo "✓ ExFig installed to ${INSTALL_DIR}/ExFig"
- name: Verify binary works
env:
RUNNER_TEMP: ${{ runner.temp }}
run: |
"${RUNNER_TEMP}/exfig/ExFig" --version
echo "✓ ExFig binary executes successfully"
# ============================================================================
# E2E Tests - Binary Caching
# ============================================================================
test-binary-caching:
name: Test binary caching
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Resolve version
id: resolve
env:
GH_TOKEN: ${{ github.token }}
run: |
RESPONSE=$(curl -sL -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/alexey1312/exfig/releases/latest")
VERSION=$(echo "$RESPONSE" | jq -r '.tag_name' 2>/dev/null || echo "")
if [[ -z "$VERSION" || "$VERSION" == "null" ]]; then
echo "✗ Failed to resolve latest version"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Check cache
id: cache-binary
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/exfig
key: exfig-binary-${{ runner.os }}-${{ steps.resolve.outputs.version }}
- name: Download if not cached
if: steps.cache-binary.outputs.cache-hit != 'true'
env:
VERSION: ${{ steps.resolve.outputs.version }}
RUNNER_TEMP: ${{ runner.temp }}
run: |
INSTALL_DIR="${RUNNER_TEMP}/exfig"
mkdir -p "$INSTALL_DIR"
ARCHIVE="exfig-linux-x64.tar.gz"
DOWNLOAD_URL="https://github.com/alexey1312/exfig/releases/download/${VERSION}/${ARCHIVE}"
echo "Downloading ExFig ${VERSION}..."
echo "URL: ${DOWNLOAD_URL}"
HTTP_CODE=$(curl -sL -w "%{http_code}" -o "${RUNNER_TEMP}/${ARCHIVE}" "${DOWNLOAD_URL}")
if [[ "$HTTP_CODE" != "200" ]]; then
echo "✗ Failed to download ExFig. HTTP status: ${HTTP_CODE}"
exit 1
fi
cd "${RUNNER_TEMP}"
tar -xzf "${ARCHIVE}" -C "${INSTALL_DIR}"
chmod +x "${INSTALL_DIR}/ExFig"
echo "✓ ExFig downloaded and installed"
- name: Report cache status
env:
CACHE_HIT: ${{ steps.cache-binary.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" == "true" ]]; then
echo "✓ Binary was restored from cache"
else
echo "✓ Binary was downloaded (cache miss expected on first run)"
fi
- name: Verify binary works
env:
RUNNER_TEMP: ${{ runner.temp }}
run: |
"${RUNNER_TEMP}/exfig/ExFig" --version
echo "✓ ExFig binary executes successfully"