From 8bf6f3f6040deca56be3244e85146489f0c801df Mon Sep 17 00:00:00 2001 From: amiabot Date: Wed, 17 Jan 2024 01:11:27 +0000 Subject: [PATCH 1/3] Update: created local '.github/workflows/phpcs.yml' from remote 'workflows/phpcs-default.yml' --- .github/workflows/phpcs.yml | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/phpcs.yml diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..4a008cb --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,44 @@ +# This file is managed in https://github.com/happyprime/projects +name: PHPCS (Default, PHP 8.2) + +on: pull_request + +# The GITHUB_TOKEN used by Dependabot has read-only permissions +# by default, so we provide write permissions to this workflow +# so that comments can be left on the pull request. +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions +permissions: + contents: read + pull-requests: write + +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + tools: composer, cs2pr + + - name: Cache Composer + id: cache-composer + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + with: + path: ${{ steps.cache-composer.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + run: | + composer install --prefer-dist --no-progress + + - name: Detect coding standard violations + run: vendor/bin/phpcs -q --report=checkstyle . | cs2pr --notices-as-warnings From 7b6858c55a05d5382c07eee044a84a6e91b9c335 Mon Sep 17 00:00:00 2001 From: amiabot Date: Wed, 17 Jan 2024 01:11:27 +0000 Subject: [PATCH 2/3] Update: created local '.github/workflows/verify-build.yml' from remote 'workflows/verify-build-default.yml' --- .github/workflows/verify-build.yml | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/verify-build.yml diff --git a/.github/workflows/verify-build.yml b/.github/workflows/verify-build.yml new file mode 100644 index 0000000..57d1f7b --- /dev/null +++ b/.github/workflows/verify-build.yml @@ -0,0 +1,82 @@ +# This file is managed in https://github.com/happyprime/projects +name: Verify build (Node 18) + +on: [ pull_request ] + +# The GITHUB_TOKEN used by Dependabot has read-only permissions +# by default, so we provide write permissions to this workflow +# so that comments can be left on the pull request. +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions +permissions: + contents: read + pull-requests: write + +jobs: + build: + name: Check built files + + runs-on: ubuntu-latest + + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: 'npm' + + - name: Verify Node dependency cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: node-dependencies-${{ hashFiles('package-lock.json') }} + restore-keys: node-dependencies- + + - name: Install Node dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Capture Git status + id: git + shell: bash + run: | + echo 'changes<> $GITHUB_OUTPUT + echo "$(git status --porcelain --untracked-files=all)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + echo "nodeVersion=$(node --version)" >> $GITHUB_OUTPUT + echo "npmVersion=$(npm --version)" >> $GITHUB_OUTPUT + + - name: Fail if changes detected + shell: bash + run: | + if [[ -n "${{ steps.git.outputs.changes }}" ]]; then + exit 1 + fi + + - name: Comment on pull request + if: failure() + uses: actions/github-script@v7 + with: + script: | + const output = `Changed files were detected after build. Please run project build workflows and check \`git status\` for any missed changes. + + \`\`\` + ${{ steps.git.outputs.changes }} + \`\`\` + + You may need to update your local NPM configuration if different than below: + * Node ${{ steps.git.outputs.nodeVersion }} + * NPM ${{ steps.git.outputs.npmVersion }} + `; + + github.rest.issues.createComment({ + ...context.repo, + issue_number: context.payload.pull_request.number, + body: output + }) From c87b5accee1e3fd5ca6fce068cf14709043d6763 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Tue, 16 Jan 2024 17:13:14 -0800 Subject: [PATCH 3/3] Exclude specific files from PHPCS --- phpcs.xml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3c67e30..03ff6c4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,6 +10,9 @@ node_modules/ vendor/ + db.php + *.svg.php + ^plugins/(?!happyprime-*)