Selaa lähdekoodia

Add linting, php8, release builds to github actions

Jordi Boggiano 5 vuotta sitten
vanhempi
commit
a849e2b244

+ 24 - 12
.github/workflows/continuous-integration.yml

@@ -1,10 +1,14 @@
-# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
-
 name: "Continuous Integration"
 
 on:
-  - "push"
-  - "pull_request"
+  push:
+    paths-ignore:
+      - '.github/**'
+      - 'doc/**'
+  pull_request:
+    paths-ignore:
+      - '.github/**'
+      - 'doc/**'
 
 env:
   COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"
@@ -12,14 +16,13 @@ env:
 
 jobs:
   tests:
-    name: "Tests"
+    name: "CI"
 
     runs-on: ${{ matrix.os }}
+    continue-on-error: ${{ matrix.experimental }}
 
     strategy:
       matrix:
-        os: [ubuntu-latest]
-        dependencies: [locked]
         php-version:
           - "5.3"
           - "5.4"
@@ -30,22 +33,28 @@ jobs:
           - "7.2"
           - "7.3"
           - "7.4"
+        dependencies: [locked]
+        os: [ubuntu-latest]
         include:
           - php-version: 5.3
-            os: ubuntu-latest
             dependencies: highest
-          - php-version: 5.3
             os: ubuntu-latest
+          - php-version: 5.3
             dependencies: lowest
-          - php-version: 7.4
             os: ubuntu-latest
+          - php-version: 7.4
             dependencies: highest
+            os: ubuntu-latest
           - php-version: 7.4
             os: windows-latest
             dependencies: locked
           - php-version: 7.4
             os: macos-latest
             dependencies: locked
+          - php-version: 8.0
+            dependencies: highest
+            os: ubuntu-latest
+            experimental: true
 
     steps:
       - name: "Checkout"
@@ -72,9 +81,9 @@ jobs:
 
       - name: "Install highest dependencies from composer.json using composer binary provided by system"
         if: "matrix.dependencies == 'highest'"
-        run: "composer update ${{ env.COMPOSER_FLAGS }}"
+        run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}"
 
-      - name: "Install lowest dependencies from composer.lock using composer binary provided by system"
+      - name: "Install lowest dependencies from composer.json using composer binary provided by system"
         if: "matrix.dependencies == 'lowest'"
         run: "composer update ${{ env.COMPOSER_FLAGS }} --prefer-lowest"
 
@@ -85,6 +94,9 @@ jobs:
       - name: "Run install again using composer binary from source"
         run: "bin/composer install ${{ env.COMPOSER_FLAGS }}"
 
+      - name: "Validate composer.json"
+        run: "bin/composer validate"
+
       - name: "Prepare git environment"
         run: "git config --global user.name composer && git config --global user.email composer@example.com"
 

+ 38 - 0
.github/workflows/lint.yml

@@ -0,0 +1,38 @@
+name: "PHP Lint"
+
+on:
+  push:
+    paths-ignore:
+      - '.github/**'
+      - 'doc/**'
+  pull_request:
+    paths-ignore:
+      - '.github/**'
+      - 'doc/**'
+
+jobs:
+  tests:
+    name: "Lint"
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        php-version:
+          - "5.3"
+          - "7.4"
+
+    steps:
+      - name: "Checkout"
+        uses: "actions/checkout@v2"
+
+      - name: "Install PHP"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          extensions: "intl"
+          ini-values: "memory_limit=-1"
+          php-version: "${{ matrix.php-version }}"
+
+      - name: "Lint PHP files"
+        run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"

+ 57 - 0
.github/workflows/release.yml

@@ -0,0 +1,57 @@
+name: "Release"
+
+on:
+  push:
+    - tags
+
+env:
+  COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"
+
+jobs:
+  build:
+    name: Upload Release Asset
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      - name: "Install PHP"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          extensions: "intl"
+          ini-values: "memory_limit=-1"
+          php-version: "7.4"
+
+      - name: "Install dependencies from composer.lock using composer binary provided by system"
+        run: "composer install ${{ env.COMPOSER_FLAGS }}"
+
+      - name: "Run install again using composer binary from source"
+        run: "bin/composer install ${{ env.COMPOSER_FLAGS }}"
+
+      - name: "Validate composer.json"
+        run: "bin/composer validate"
+
+      - name: Build phar file
+        run: "php -d phar.readonly=0 bin/compile"
+
+      - name: Create release
+        id: create_release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ github.ref }}
+          release_name: ${{ github.ref }}
+          draft: true
+          body: TODO
+
+      - name: Upload phar
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./composer.phar
+          asset_name: composer.phar
+          asset_content_type: application/octet-stream