Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 0 additions & 136 deletions .github/workflows/test-local.yml

This file was deleted.

130 changes: 13 additions & 117 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test Action

on:
push:
branches: [main]
branches: [ main ]
paths:
- 'src/**'
- 'tests/**'
Expand All @@ -12,7 +12,6 @@ on:
- 'bun.lock'

pull_request:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
Expand Down Expand Up @@ -52,129 +51,26 @@ jobs:
exit 1
fi

build-test-image:
name: Build Test Image
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4

- name: Build Docker image
working-directory: tests/integration/phpunit-project
run: docker build -t phpunit-retry-test:latest .

- name: Save image
run: docker save phpunit-retry-test:latest | gzip > /tmp/phpunit-retry-test.tar.gz

- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: phpunit-retry-test-image
path: /tmp/phpunit-retry-test.tar.gz
retention-days: 1

test-action:
name: Test Action - ${{ matrix.scenario }}
runs-on: ubuntu-latest
needs: build-test-image
strategy:
matrix:
include:
- scenario: "Simple Dependencies"
test_path: "tests/SampleTest.php"
container_id: "simple"
test_dir: "tests/integration/phpunit-project/tests"

- scenario: "Complex Dependencies"
test_path: "tests/ProjectTest.php"
container_id: "complex"
test_dir: "tests/integration/phpunit-project/tests"

- scenario: "Full Test Suite"
container_id: "full"
test_dir: "tests/integration/phpunit-project/tests"
steps:
- uses: actions/checkout@v4

- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: phpunit-retry-test-image
path: /tmp

- name: Load Docker image
run: docker load < /tmp/phpunit-retry-test.tar.gz

- name: Start container
run: docker run -d --name phpunit-retry-${{ matrix.container_id }} phpunit-retry-test:latest tail -f /dev/null

- name: Test action with failing tests
id: test-retry
uses: ./
with:
command: docker exec phpunit-retry-${{ matrix.container_id }} vendor/bin/phpunit ${{ matrix.test_path || '' }}
test_dir: ${{ matrix.test_dir }}
max_attempts: 3
retry_wait_seconds: 5
continue-on-error: true

- name: Cleanup
if: always()
run: docker rm -f phpunit-retry-${{ matrix.container_id }} || true

- name: Verify action executed
run: |
echo "Action completed with outcome: ${{ steps.test-retry.outcome }}"

test-action-with-env:
name: Test Action with Environment Variables
runs-on: ubuntu-latest
needs: build-test-image
steps:
- uses: actions/checkout@v4

- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: phpunit-retry-test-image
path: /tmp

- name: Load Docker image
run: docker load < /tmp/phpunit-retry-test.tar.gz

- name: Start container
run: docker run -d --name phpunit-retry-env phpunit-retry-test:latest tail -f /dev/null

- name: Test action with env vars in command
id: test-retry
uses: ./
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
command: _DATABASE_CONFIG=shared_tables _STORAGE_PATH=/tmp/storage docker exec phpunit-retry-env vendor/bin/phpunit tests/SampleTest.php
test_dir: tests/integration/phpunit-project/tests
max_attempts: 3
retry_wait_seconds: 5
continue-on-error: true

- name: Verify action executed
run: |
echo "Action completed with outcome: ${{ steps.test-retry.outcome }}"
bun-version: latest

- name: Test action with env vars and vendor path
id: test-retry-vendor
uses: ./
with:
command: _DATABASE_CONFIG=shared_tables _STORAGE_PATH=/tmp/storage docker exec phpunit-retry-env vendor/bin/phpunit vendor/sample/library/tests/VendorTest.php
test_dir: tests/integration/phpunit-project/vendor/sample/library/tests
max_attempts: 3
retry_wait_seconds: 5
continue-on-error: true
- name: Install dependencies
run: bun install

- name: Verify vendor test executed
run: |
echo "Vendor test completed with outcome: ${{ steps.test-retry-vendor.outcome }}"
- name: Build action
run: bun run build

- name: Cleanup
if: always()
run: docker rm -f phpunit-retry-env || true
- name: Run integration tests
run: bun run test:integration

lint:
name: Lint & Type Check
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/update-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Update Latest Tag

on:
push:
branches:
- main
branches: [ main ]
paths:
- 'dist/**'

jobs:
update-tag:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "prettier --check 'src/**/*.ts'",
"test": "bun test",
"test:unit": "bun test tests/unit/",
"test:integration": "bun run tests/test-integration.ts",
"test:integration": "bun run tests/integration/index.ts",
"check": "bun lint && tsc --noEmit"
},
"devDependencies": {
Expand Down
13 changes: 5 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@ Fast, isolated tests for individual components:
Run: `bun test tests/unit/`

### Integration Tests
End-to-end test using GitHub Actions locally:
- **test-integration.ts** - Runs the full action via `act` (requires Docker)
- Uses `.github/workflows/test.yml` workflow (test-action job)
End-to-end test using the action bundle and Docker:
- **integration/index.ts** - Runs the action against a Dockerized PHPUnit project
- Uses `tests/integration/resources/phpunit-project/docker-compose.yml`
- Tests complete retry flow with real PHPUnit runs
- Validates JUnit parsing, dependency resolution, and retry logic

Run: `bun test:integration` (requires `act` CLI tool)
Run: `bun test:integration` (requires Docker and Docker Compose)

## Running Tests

```bash
# Unit tests (fast)
bun test

# Integration test (slower, requires Docker and act CLI)
# Integration test (slower, requires Docker and Docker Compose)
bun test:integration

# Install act (if not already installed)
brew install act
```
Loading