From a9d65ec65322a7cf559f2bc47fcd470620d8812d Mon Sep 17 00:00:00 2001 From: Al Munnings Date: Sat, 3 Feb 2024 12:39:05 +1100 Subject: [PATCH] Workflows, add lint and lando start --- .github/workflows/build.yml | 8 +++++++ .github/workflows/lint.yml | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f75789..23393ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,19 +4,27 @@ on: push: branches: [main] +env: + TERM: xterm + jobs: lando: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: lando/setup-lando@v2 with: lando-version: latest + - run: lando start ddev: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: ddev/github-action-setup-ddev@v1 with: version: latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..92a850e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,47 @@ +name: Lint + +on: + pull_request: + +env: + PHP_VERSION: 8.1 + TERM: xterm + +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v42 + with: + files: "{docroot,web}/{modules,themes}/custom/**/*.{php,module,inc,install,test,profile,theme,yml}" + files_ignore: | + *Test.php + *TestBase.php + **/tests/ + + - name: Set up PHP + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ env.PHP_VERSION }}" + tools: "cs2pr, phpcs, composer" + if: ${{ steps.changed-files.outputs.any_changed == 'true' }} + + - name: Install Drupal Coder + run: | + composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer global require --ignore-platform-reqs drupal/coder + if: ${{ steps.changed-files.outputs.any_changed == 'true' }} + + - name: PHPCS + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + phpcs -q --report=checkstyle --standard=Drupal,DrupalPractice -n $file | cs2pr + done + if: ${{ steps.changed-files.outputs.any_changed == 'true' }}