diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ab9cb6d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: CI + +on: [pull_request] + +jobs: + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Run format check + run: | + docker run --rm -v $PWD:/app composer:2.7 sh -c \ + "composer install --profile --ignore-platform-reqs && composer format:check" + + analyze: + name: Analyze + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Run static analysis + run: | + docker run --rm -v $PWD:/app composer:2.7 sh -c \ + "composer install --profile --ignore-platform-reqs && composer analyze" + + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Run unit tests + run: | + docker run --rm -v $PWD:/app composer:2.7 sh -c \ + "composer install --profile --ignore-platform-reqs && composer test -- --testsuite unit" + + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: dns-dev + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Start DNS Server + run: | + docker compose up -d + sleep 10 + + - name: Run E2E tests + run: docker compose exec -T dns-server vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 8220ddc..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "CodeQL" - -on: [pull_request] -jobs: - lint: - name: CodeQL - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - run: git checkout HEAD^2 - - - name: Run CodeQL - run: | - docker run --rm -v $PWD:/app composer:2.7 sh -c \ - "composer install --profile --ignore-platform-reqs && composer check" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index c2f8cb6..0000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "Linter" - -on: [pull_request] -jobs: - lint: - name: Linter - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - run: git checkout HEAD^2 - - - 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/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index b8c717e..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: "Tests" - -on: [pull_request] -jobs: - tests: - name: Unit & E2E - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 2 - submodules: recursive - - - run: git checkout HEAD^2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build image - uses: docker/build-push-action@v3 - with: - context: . - push: false - tags: dns-dev - load: true - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Start DNS Server - run: | - docker compose up -d - sleep 10 - - - name: Run Tests - run: docker compose exec -t dns-server vendor/bin/phpunit --configuration phpunit.xml diff --git a/composer.json b/composer.json index a7a9726..d408003 100755 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "license": "MIT", "minimum-stability": "stable", "scripts": { - "lint": "./vendor/bin/pint --test --config pint.json", "format": "./vendor/bin/pint --config pint.json", - "check": "./vendor/bin/phpstan analyse --level 8 -c phpstan.neon src tests", + "format:check": "./vendor/bin/pint --test --config pint.json", + "analyze": "./vendor/bin/phpstan analyse --level 8 -c phpstan.neon src tests", "test": "./vendor/bin/phpunit --configuration phpunit.xml" }, "authors": [ diff --git a/tests/unit/DNS/Resolver/CloudflareTest.php b/tests/e2e/DNS/Resolver/CloudflareTest.php similarity index 100% rename from tests/unit/DNS/Resolver/CloudflareTest.php rename to tests/e2e/DNS/Resolver/CloudflareTest.php diff --git a/tests/unit/DNS/Resolver/GoogleTest.php b/tests/e2e/DNS/Resolver/GoogleTest.php similarity index 100% rename from tests/unit/DNS/Resolver/GoogleTest.php rename to tests/e2e/DNS/Resolver/GoogleTest.php diff --git a/tests/unit/DNS/Resolver/MemoryTest.php b/tests/e2e/DNS/Resolver/MemoryTest.php similarity index 100% rename from tests/unit/DNS/Resolver/MemoryTest.php rename to tests/e2e/DNS/Resolver/MemoryTest.php diff --git a/tests/unit/DNS/Validator/CAATest.php b/tests/e2e/DNS/Validator/CAATest.php similarity index 100% rename from tests/unit/DNS/Validator/CAATest.php rename to tests/e2e/DNS/Validator/CAATest.php diff --git a/tests/unit/DNS/Validator/DNSTest.php b/tests/e2e/DNS/Validator/DNSTest.php similarity index 100% rename from tests/unit/DNS/Validator/DNSTest.php rename to tests/e2e/DNS/Validator/DNSTest.php diff --git a/tests/unit/DNS/Validator/NameTest.php b/tests/e2e/DNS/Validator/NameTest.php similarity index 100% rename from tests/unit/DNS/Validator/NameTest.php rename to tests/e2e/DNS/Validator/NameTest.php