From 3ba6483bf3173ca018c0147b3fc79d0bb6045464 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:27:57 +0200 Subject: [PATCH 01/11] Try caching composer stuff Especially the GCM stuff may be quite large, so caching may be a good idea. I tried following https://github.com/shivammathur/setup-php#cache-composer-dependencies --- .github/workflows/tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 73fa11a..8504624 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,17 +20,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} extensions: gd, sqlite3 + + # composer cache - name: Remove composer lock run: rm composer.lock + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + # http://man7.org/linux/man-pages/man1/date.1.html + # https://github.com/actions/cache#creating-a-cache-key + - name: Get Date + id: get-date + run: | + echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" + shell: bash + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # composer - name: Setup PHPunit run: composer install -n - name: Install Google Cloud Storage run: composer require google/cloud-storage + + # testing - name: Run unit tests run: ../vendor/bin/phpunit --no-coverage working-directory: tst From a8f7840d2548f063b53d0990e37990c30cb1587e Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:29:48 +0200 Subject: [PATCH 02/11] Only restore cache from current date then --- .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 8504624..465003a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- # composer - name: Setup PHPunit From 507a10adc58a4bb6f3696718af875c1ac83fe768 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:32:57 +0200 Subject: [PATCH 03/11] Use composer.json instead of composer.lock In a cache --- .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 465003a..3c979bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- # composer From 3f7bceb86246d2825e5376fa06f96392f4e0256c Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:38:21 +0200 Subject: [PATCH 04/11] Also cache PHP extensions See https://github.com/shivammathur/cache-extensions#workflow --- .github/workflows/tests.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c979bc..271cfc5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,15 +17,33 @@ jobs: matrix: php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} + env: + extensions: gd, sqlite3 steps: - name: Checkout uses: actions/checkout@v2 + # cache PHP extensions + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ runner.os }}-phpextensions + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ env.extensions }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: gd, sqlite3 + extensions: ${{ env.extensions }} # composer cache - name: Remove composer lock From e2ae0da4e1d310447c2847ea7cdde84e3109bc40 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:41:54 +0200 Subject: [PATCH 05/11] Style cleanup adding newlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems to be the unofficial GitHub Actions YAML style and arguably makes things a lot more readable if you have a lot of steps… --- .github/workflows/tests.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 271cfc5..5cf16ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,6 +2,7 @@ name: Tests on: [push] jobs: + Composer: runs-on: ubuntu-latest steps: @@ -11,6 +12,7 @@ jobs: run: composer validate - name: Install dependencies run: composer install --prefer-dist --no-dev + PHPunit: runs-on: ubuntu-latest strategy: @@ -19,7 +21,10 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 + steps: + + # let's get started! - name: Checkout uses: actions/checkout@v2 @@ -48,9 +53,11 @@ jobs: # composer cache - name: Remove composer lock run: rm composer.lock + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" + # http://man7.org/linux/man-pages/man1/date.1.html # https://github.com/actions/cache#creating-a-cache-key - name: Get Date @@ -58,6 +65,7 @@ jobs: run: | echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" shell: bash + - name: Cache dependencies uses: actions/cache@v2 with: @@ -75,20 +83,26 @@ jobs: - name: Run unit tests run: ../vendor/bin/phpunit --no-coverage working-directory: tst + Mocha: runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v2 + - name: Setup Node uses: actions/setup-node@v1 with: node-version: '12' + - name: Setup Mocha run: npm install -g mocha + - name: Setup Node modules run: npm install working-directory: js + - name: Run unit tests run: mocha working-directory: js From a372ee92e950a164e15f162af37ceccd09fe81a5 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:43:54 +0200 Subject: [PATCH 06/11] Fix wrong cache key --- .github/workflows/tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5cf16ee..a991262 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,7 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 + extensions-cache-key: ${{ runner.os }}-phpextensions steps: @@ -35,14 +36,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} - key: ${{ runner.os }}-phpextensions + key: ${{ env.extensions-cache-key }} - name: Cache extensions uses: actions/cache@v2 with: path: ${{ steps.extcache.outputs.dir }} key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ env.extensions }} + restore-keys: ${{ env.extensions-cache-key }} - name: Setup PHP uses: shivammathur/setup-php@v2 From b80732f8e20bc1e2fb824b5edcdb87efab16580e Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:55:08 +0200 Subject: [PATCH 07/11] Add caching for NodeJS --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a991262..250aedb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -93,9 +93,11 @@ jobs: uses: actions/checkout@v2 - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12' + cache: 'npm' + cache-dependency-path: 'js/package-lock.json' - name: Setup Mocha run: npm install -g mocha From 5f4fe52eabad233631549b72022eedc00bfdce2c Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 00:56:44 +0200 Subject: [PATCH 08/11] Use package-json instead of package-lock.json for cache --- .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 250aedb..37c8953 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,7 +97,7 @@ jobs: with: node-version: '12' cache: 'npm' - cache-dependency-path: 'js/package-lock.json' + cache-dependency-path: 'js/package.json' - name: Setup Mocha run: npm install -g mocha From ab11fbeb471b7662721970da0f17c72a18fe3eff Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:01:24 +0200 Subject: [PATCH 09/11] Fix syntax error Apparently in envs the OS etc. syntax is not supported, so we need to use it like this. --- .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 37c8953..8c3b1c0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 - extensions-cache-key: ${{ runner.os }}-phpextensions + extensions-cache-key-name: phpextensions steps: @@ -36,14 +36,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} - key: ${{ env.extensions-cache-key }} + key: ${{ runner.os }}-${{ env.extensions-cache-key }} - name: Cache extensions uses: actions/cache@v2 with: path: ${{ steps.extcache.outputs.dir }} key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ env.extensions-cache-key }} + restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }} - name: Setup PHP uses: shivammathur/setup-php@v2 From f43a41c11792fcdb7fd48937663da37a912c8945 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:07:57 +0200 Subject: [PATCH 10/11] Update tests.yml --- .github/workflows/tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c3b1c0..0ef1946 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,6 +50,14 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: ${{ env.extensions }} + + # Setup GitHub CI PHP problem matchers + # https://github.com/shivammathur/setup-php#problem-matchers + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" # composer cache - name: Remove composer lock From f4e68fcc04a8f2567ab230f11645f85664e7e1f1 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 2 Oct 2021 01:12:08 +0200 Subject: [PATCH 11/11] style: better YAML comments --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c3b1c0..c10595e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,9 +74,10 @@ jobs: key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}- - # composer + # composer installation - name: Setup PHPunit run: composer install -n + - name: Install Google Cloud Storage run: composer require google/cloud-storage