From 0148f60671d6b21de166c1c9b201f012347d1dda Mon Sep 17 00:00:00 2001 From: faisalill Date: Fri, 4 Aug 2023 19:50:36 +0530 Subject: [PATCH 01/11] Migrate to Github Actions Replace travis.yml with github/workflows/tests.yml Add scripts in composer.json --- .github/workflows/tests.yml | 26 ++++++++++++++++++++++++++ .phpunit.result.cache | 1 + composer.json | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml create mode 100644 .phpunit.result.cache diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6196372 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,26 @@ +name: Tests + +on: [pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [8.0, nightly] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@2.25.2 + with: + php-version: ${{ matrix.php-version }} + + - name: Install Dependencies + run: composer install --ignore-platform-reqs + + - name: Run Tests + run: composer test \ No newline at end of file diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..be65102 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":[],"times":{"Utopia\\Tests\\ConfigTest::testTest":0.002}} \ No newline at end of file diff --git a/composer.json b/composer.json index 371a5ba..aecde6b 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "scripts": { "lint": "./vendor/bin/pint --test", "format": "./vendor/bin/pint", - "check": "./vendor/bin/phpstan analyse --level 8 src tests" + "check": "./vendor/bin/phpstan analyse --level 8 src tests", + "test": "./vendor/bin/phpunit --configuration phpunit.xml" }, "require": { "php": ">=8.0" From f9ee1c5cee3b429bf91a7b7a5fa02836f95e9eda Mon Sep 17 00:00:00 2001 From: faisalill Date: Fri, 4 Aug 2023 19:52:16 +0530 Subject: [PATCH 02/11] Remove php unit cache --- .phpunit.result.cache | 1 - .travis.yml | 15 --------------- 2 files changed, 16 deletions(-) delete mode 100644 .phpunit.result.cache delete mode 100644 .travis.yml diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index be65102..0000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -{"version":1,"defects":[],"times":{"Utopia\\Tests\\ConfigTest::testTest":0.002}} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6682db7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: php - -php: -- 8.0 -- nightly - -notifications: - email: - - team@appwrite.io - -before_script: composer install --ignore-platform-reqs - -script: -- vendor/bin/phpunit --configuration phpunit.xml -- vendor/bin/psalm --show-info=true From 6825c5a3ba52fee85b833527a8a0f603d9144d37 Mon Sep 17 00:00:00 2001 From: faisalill Date: Sat, 12 Aug 2023 16:18:59 +0530 Subject: [PATCH 03/11] Replace third party php environment --- .github/workflows/tests.yml | 13 +++++-------- Dockerfile | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6196372..3c52838 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,13 +14,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@2.25.2 - with: - php-version: ${{ matrix.php-version }} - - - name: Install Dependencies - run: composer install --ignore-platform-reqs + - name: Setup Environment + run: | + docker build . -t config-dev + docker run -d --name config-dev config-dev - name: Run Tests - run: composer test \ No newline at end of file + run: docker exec config-dev composer test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c3991ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM php:8.0-cli-alpine + +WORKDIR /usr/src/app + +RUN apk update && apk add \ + zip \ + unzip + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Copy composer.json +COPY composer.json ./ + +# Install dependencies +RUN composer install --ignore-platform-reqs + +# Copy source code +COPY . . + +CMD [ "tail", "-f", "/dev/null" ] \ No newline at end of file From 22856dccfbe76f751cfed948d1b087f4cfd8c8b1 Mon Sep 17 00:00:00 2001 From: faisalill Date: Sat, 12 Aug 2023 16:31:22 +0530 Subject: [PATCH 04/11] Use better image and container name --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c52838..002689e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,8 +16,8 @@ jobs: - name: Setup Environment run: | - docker build . -t config-dev - docker run -d --name config-dev config-dev + docker build . -t php8-env + docker run -d --name tests php8-env - name: Run Tests - run: docker exec config-dev composer test \ No newline at end of file + run: docker exec tests composer test \ No newline at end of file From 7a5f9d9ed482a38022b5728d2696b880cd18c4f4 Mon Sep 17 00:00:00 2001 From: faisalill Date: Sat, 12 Aug 2023 19:50:15 +0530 Subject: [PATCH 05/11] Try different approach for tests --- .github/workflows/tests.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 002689e..22cac31 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,13 +11,14 @@ jobs: php-version: [8.0, nightly] steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Environment - run: | - docker build . -t php8-env - docker run -d --name tests php8-env - - - name: Run Tests - run: docker exec tests composer test \ No newline at end of file + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - run: git checkout HEAD^2 + + - name: Run Tests + run: | + docker run --rm -v $PWD:/app composer sh -c \ + "composer install --profile --ignore-platform-reqs && composer test" \ No newline at end of file From 00c7cad330fdcab0b7ee1de886579f09a69db6e8 Mon Sep 17 00:00:00 2001 From: faisalill Date: Sat, 12 Aug 2023 19:54:27 +0530 Subject: [PATCH 06/11] Remove Dockerfile --- Dockerfile | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c3991ad..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM php:8.0-cli-alpine - -WORKDIR /usr/src/app - -RUN apk update && apk add \ - zip \ - unzip - -# Install composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# Copy composer.json -COPY composer.json ./ - -# Install dependencies -RUN composer install --ignore-platform-reqs - -# Copy source code -COPY . . - -CMD [ "tail", "-f", "/dev/null" ] \ No newline at end of file From 3866e40547a38d1d00a650b7cc3bcf318691c1ee Mon Sep 17 00:00:00 2001 From: faisalill Date: Tue, 15 Aug 2023 08:09:44 +0530 Subject: [PATCH 07/11] Add on push to github workflow tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 22cac31..fa90cfe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,6 @@ name: Tests -on: [pull_request] +on: [push,pull_request] jobs: tests: From f29e48f4529e62c18374ff32388c90b8a886270f Mon Sep 17 00:00:00 2001 From: faisalill Date: Tue, 15 Aug 2023 08:10:33 +0530 Subject: [PATCH 08/11] Remove php version from github workflow tests --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fa90cfe..6f129fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,10 +6,6 @@ jobs: tests: runs-on: ubuntu-latest - strategy: - matrix: - php-version: [8.0, nightly] - steps: - name: Checkout repository uses: actions/checkout@v3 From cc0ab19c4a65287255c43fc94a4343a3d4e36504 Mon Sep 17 00:00:00 2001 From: faisalill Date: Tue, 15 Aug 2023 08:11:31 +0530 Subject: [PATCH 09/11] Remove fetch depth --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6f129fa..f84368b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,10 +9,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - run: git checkout HEAD^2 - name: Run Tests run: | From 1e6b7a6d05d9662d8f882dd844b893d319d0b11d Mon Sep 17 00:00:00 2001 From: faisalill Date: Tue, 15 Aug 2023 08:12:20 +0530 Subject: [PATCH 10/11] Capitalize Test name --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f84368b..cf98f25 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: Tests on: [push,pull_request] jobs: - tests: + Tests: runs-on: ubuntu-latest steps: From de81ed20d76bb58243709c6343b5105cdf28ec93 Mon Sep 17 00:00:00 2001 From: faisalill Date: Sun, 20 Aug 2023 15:33:59 +0530 Subject: [PATCH 11/11] Trigger tests on push only for main and master --- .github/workflows/tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cf98f25..c2f2a5a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,13 @@ name: Tests -on: [push,pull_request] +on: + push: + branches: + - master + - main + pull_request: + branches: + '*' jobs: Tests: