From c6e0eab5b9fb87144009c16255078dff82a300ed Mon Sep 17 00:00:00 2001 From: Arif Kurkchi <11618962+justnero@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:34:25 +0300 Subject: [PATCH] Add coding standards and psalm checks on PRs (#620) --- .github/workflows/pr.yaml | 95 +++++++++++++++++++++++++++++++++++++++ psalm.xml | 30 +++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/pr.yaml create mode 100644 psalm.xml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 000000000..989ee6216 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,95 @@ +name: "Check SDK" + +on: + pull_request: + paths: + - '.github/workflows/pr.yaml' + - 'src/**' + +jobs: + psalm: + name: "Psalm" + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['8.0', '8.1', '8.2'] + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: "Install PHP w/ Extensions" + uses: rebilly/setup-php@main + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl, curl, json + tools: composer:v2 + + - name: "Get composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: "Install dependencies" + run: composer install --no-interaction --no-scripts --no-suggest + + - name: "Run tests" + run: vendor/bin/psalm + + cs: + name: "Coding Standards" + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['8.0', '8.1', '8.2'] + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: "Install PHP w/ Extensions" + uses: rebilly/setup-php@main + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl, curl, json + tools: composer:v2 + + - name: "Get composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: "Install dependencies" + run: composer install --no-interaction --no-scripts --no-suggest + + - uses: actions/cache@v3 + with: + path: .php-cs-fixer.cache + key: ${{ runner.os }}-cs-fixer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-cs-fixer- + + - name: "Run tests" + run: vendor/bin/php-cs-fixer fix -vv --dry-run diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 000000000..2fe263ade --- /dev/null +++ b/psalm.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +