diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..01230d04 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,121 @@ +name: "CI" + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + format: + name: Format + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Run Format + run: | + docker run --rm -v $PWD:/app composer:2.8 sh -c \ + "composer install --profile --ignore-platform-reqs && composer format:check" + + analyze: + name: Analyze + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Run Analyze + run: | + docker run --rm -v $PWD:/app composer:2.8 sh -c \ + "composer install --profile --ignore-platform-reqs && composer analyze" + + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Run Unit Tests + run: | + docker run --rm \ + -v $PWD:/app \ + -w /app \ + phpswoole/swoole:5.1.2-php8.3-alpine \ + sh -c " + apk update && \ + apk add zip unzip && \ + composer install --profile --ignore-platform-reqs && \ + composer test:unit + " + + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Build Docker image + run: docker compose build + + - name: Save Docker image + run: docker save -o executor-image.tar executor-openruntimes-executor + + - name: Upload Docker image artifact + uses: actions/upload-artifact@v6 + with: + name: executor-image + path: executor-image.tar + retention-days: 1 + + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + needs: build + + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Download Docker image artifact + uses: actions/download-artifact@v7 + with: + name: executor-image + + - name: Load Docker image + run: docker load -i executor-image.tar + + - name: Start Test Stack + run: docker compose up -d --wait --wait-timeout 300 + + - name: Doctor + run: | + docker compose logs + docker ps + docker network ls + + - name: Run E2E Tests + run: | + docker run --rm \ + -v $PWD:/app \ + -v /tmp:/tmp \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --network executor_runtimes \ + -w /app \ + phpswoole/swoole:5.1.2-php8.3-alpine \ + sh -c " + apk update && \ + apk add docker-cli zip unzip && \ + composer install --profile --ignore-platform-reqs && \ + composer test:e2e + " diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 3408058d..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "CodeQL" - -on: [pull_request] -jobs: - lint: - name: CodeQL - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Run CodeQL - run: | - docker run --rm -v $PWD:/app composer:2.6 sh -c \ - "composer install --profile --ignore-platform-reqs && composer check" \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 28f4c6a0..00000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Linter" - -on: [pull_request] -jobs: - lint: - name: Linter - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Run Linter - run: | - docker run --rm -v $PWD:/app composer sh -c \ - "composer install --profile --ignore-platform-reqs && composer lint" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c1bbe28..3e84bb75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 9d20b1d4..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: "Tests" - -on: [pull_request] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - unit-tests: - name: Unit Tests - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Run Unit Tests - run: | - docker run --rm \ - -v $PWD:/app \ - -w /app \ - phpswoole/swoole:5.1.2-php8.3-alpine \ - sh -c " - apk update && \ - apk add zip unzip && \ - composer install --profile --ignore-platform-reqs && \ - composer test -- --testsuite=unit - " - - executor-tests: - name: Executor Tests - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Start Test Stack - run: | - docker compose build - docker compose up -d --wait --wait-timeout 300 - - - name: Doctor - run: | - docker compose logs - docker ps - docker network ls - - - name: Run Executor Tests - run: | - docker run --rm \ - -v $PWD:/app \ - -v /tmp:/tmp \ - -v /var/run/docker.sock:/var/run/docker.sock \ - --network executor_runtimes \ - -w /app \ - phpswoole/swoole:5.1.2-php8.3-alpine \ - sh -c " - apk update && \ - apk add docker-cli zip unzip && \ - composer install --profile --ignore-platform-reqs && \ - composer test -- --testsuite=e2e - " diff --git a/composer.json b/composer.json index 4b2c21fa..0cc74111 100644 --- a/composer.json +++ b/composer.json @@ -6,14 +6,16 @@ "autoload": { "psr-4": { "OpenRuntimes\\": "src/", - "Tests\\": "tests" + "Tests\\E2E\\": "tests/e2e", + "Tests\\Unit\\": "tests/unit" } }, "scripts": { - "lint": "./vendor/bin/pint --test --config pint.json", "format": "./vendor/bin/pint --config pint.json", - "check": "./vendor/bin/phpstan analyse --level 8 --memory-limit=2G -c phpstan.neon app src tests", - "test": "./vendor/bin/phpunit --configuration phpunit.xml --debug" + "format:check": "./vendor/bin/pint --test --config pint.json", + "analyze": "./vendor/bin/phpstan analyse --level 8 --memory-limit=2G -c phpstan.neon app src tests", + "test:unit": "./vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite=unit", + "test:e2e": "./vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite=e2e" }, "require": { "php": ">=8.3.0", diff --git a/phpunit.xml b/phpunit.xml index 857beb2b..a35661e7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,7 +11,7 @@ > - ./tests/ExecutorTest.php + ./tests/e2e ./tests/unit diff --git a/tests/Client.php b/tests/e2e/Client.php similarity index 99% rename from tests/Client.php rename to tests/e2e/Client.php index 0357e382..a9daa605 100644 --- a/tests/Client.php +++ b/tests/e2e/Client.php @@ -1,6 +1,6 @@