diff --git a/.github/workflows/ci-cron.yml b/.github/workflows/ci-cron.yml new file mode 100644 index 0000000..e387097 --- /dev/null +++ b/.github/workflows/ci-cron.yml @@ -0,0 +1,15 @@ +name: CI Cronjob + +on: + # Run this workflow on day 10 of every month as the repo isn't that active. + schedule: + - cron: '0 0 10 * *' + +permissions: {} + +jobs: + QA: + # Don't run the cron job on forks. + if: ${{ github.event.repository.fork == false }} + + uses: ./.github/workflows/reusable-qa-checks.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89f994d..0dd0bc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,57 +1,14 @@ name: CI on: - # Run on all pushes and pull requests. + # Run on pushes to `main` and on all pull requests. push: branches: - main pull_request: - # Also run this workflow on day 10 of every month as the repo isn't that active. - schedule: - - cron: '0 0 10 * *' # Allow manually triggering the workflow. workflow_dispatch: jobs: - xmllint: - # Don't run the cron job on forks. - if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }} - - name: 'Check install and XML' - runs-on: ubuntu-latest - - env: - XMLLINT_INDENT: ' ' - - steps: - - name: Checkout code - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Install PHP - uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5 - with: - php-version: 'latest' - coverage: none - - # Install dependencies to make sure the PHPCS XSD file is available. - - name: Install dependencies - run: composer install --prefer-dist --no-interaction --no-progress - - # Validate the composer.json file. - # @link https://getcomposer.org/doc/03-cli.md#validate - - name: Validate Composer installation - run: composer validate --no-check-all --strict - - # Validate the xml file. - - name: Validate against schema - uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 - with: - pattern: "PHPCSDev/ruleset.xml" - xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd" - - # Check the code-style consistency of the xml file. - # Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner. - - name: Check code style - run: diff -B ./PHPCSDev/ruleset.xml <(xmllint --format "./PHPCSDev/ruleset.xml") + QA: + uses: ./.github/workflows/reusable-qa-checks.yml diff --git a/.github/workflows/reusable-qa-checks.yml b/.github/workflows/reusable-qa-checks.yml new file mode 100644 index 0000000..61a8bb5 --- /dev/null +++ b/.github/workflows/reusable-qa-checks.yml @@ -0,0 +1,47 @@ +name: CI + +on: + workflow_call: + +permissions: {} + +jobs: + xmllint: + name: 'Check install and XML' + runs-on: ubuntu-latest + + env: + XMLLINT_INDENT: ' ' + + steps: + - name: Checkout code + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Install PHP + uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5 + with: + php-version: 'latest' + coverage: none + + # Install dependencies to make sure the PHPCS XSD file is available. + - name: Install dependencies + run: composer install --prefer-dist --no-interaction --no-progress + + # Validate the composer.json file. + # @link https://getcomposer.org/doc/03-cli.md#validate + - name: Validate Composer installation + run: composer validate --no-check-all --strict + + # Validate the xml file. + - name: Validate against schema + uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 + with: + pattern: "PHPCSDev/ruleset.xml" + xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd" + + # Check the code-style consistency of the xml file. + # Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner. + - name: Check code style + run: diff -B ./PHPCSDev/ruleset.xml <(xmllint --format "./PHPCSDev/ruleset.xml")