From 5011b74c07c8bcdad9b0a89d94b610c55e28b143 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Tue, 31 Dec 2024 16:11:03 -0600 Subject: [PATCH] consolidate test jobs --- .github/workflows/all-pr-tests.yml | 67 ++++++++++++++++++++++++++ .github/workflows/code-quality.yml | 12 ----- .github/workflows/coding-standards.yml | 16 ------ .github/workflows/node-tests.yml | 18 ------- .github/workflows/unit-test.yml | 21 -------- package.json | 6 +-- 6 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/all-pr-tests.yml delete mode 100644 .github/workflows/code-quality.yml delete mode 100644 .github/workflows/coding-standards.yml delete mode 100644 .github/workflows/node-tests.yml delete mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/all-pr-tests.yml b/.github/workflows/all-pr-tests.yml new file mode 100644 index 00000000..777456c3 --- /dev/null +++ b/.github/workflows/all-pr-tests.yml @@ -0,0 +1,67 @@ +name: "All Pull Request Tests" + +on: + pull_request: + branches: + - develop + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + # We use a single job to ensure that all steps run in the same environment and + # reduce the number of minutes used. + pr-tests: + # Don't run on draft PRs + if: github.event.pull_request.draft == false + # Timeout after 10 minutes + timeout-minutes: 10 + # Define a matrix of PHP/WordPress versions to test against + strategy: + matrix: + php: [8.2, 8.3] + wordpress: ["latest"] + runs-on: ubuntu-latest + # Cancel any existing runs of this workflow + concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }} + cancel-in-progress: true + # Name the job in the matrix + name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }}" + steps: + - uses: actions/checkout@v4 + + - name: Run General Tests + # See https://github.com/alleyinteractive/action-test-general for more options + uses: alleyinteractive/action-test-general@develop + + - name: Run Node Tests + # See https://github.com/alleyinteractive/action-test-node for more options. + # Defaults to the latest LTS version. + uses: alleyinteractive/action-test-node@develop + + - name: Run PHP Tests + # See https://github.com/alleyinteractive/action-test-php for more options + uses: alleyinteractive/action-test-php@develop + with: + php-version: '${{ matrix.php }}' + wordpress-version: '${{ matrix.wordpress }}' + skip-wordpress-install: 'true' + # This required job ensures that all PR checks have passed before merging. + all-pr-checks-passed: + name: All PR checks passed + needs: + - pr-tests + runs-on: ubuntu-latest + if: always() + steps: + - name: Check job statuses + run: | + if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then + echo "One or more jobs failed" + exit 1 + elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then + echo "One or more jobs were cancelled" + exit 1 + else + echo "All jobs passed or were skipped" + exit 0 + fi \ No newline at end of file diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml deleted file mode 100644 index 100e8643..00000000 --- a/.github/workflows/code-quality.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Code Quality - -on: - push: - branches: - - develop - -jobs: - phpstan: - uses: alleyinteractive/.github/.github/workflows/php-code-quality.yml@main - with: - php: '8.2' diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml deleted file mode 100644 index 4adcf4ef..00000000 --- a/.github/workflows/coding-standards.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Coding Standards - -on: - push: - branches: - - develop - pull_request: - # Uncomment and edit the following to run on a schedule. - # schedule: - # - cron: '0 5 * * 0' # Run once per week at 5am UTC on Sundays. - -jobs: - coding-standards: - uses: alleyinteractive/.github/.github/workflows/php-coding-standards.yml@main - with: - php: '8.2' diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml deleted file mode 100644 index 51e52be2..00000000 --- a/.github/workflows/node-tests.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Node Tests - -on: - push: - branches: - - develop - pull_request: - # Uncomment and edit the following to run on a schedule. - # schedule: - # - cron: '15 5 * * 0' # Run once per week at 5:15am UTC on Sundays. - -jobs: - node-tests: - uses: alleyinteractive/.github/.github/workflows/node-tests.yml@main - with: - run-audit: true - node: 22 - npm: 10 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index 12b7eb1d..00000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Testing Suite - -on: - push: - branches: - - develop - pull_request: - # Uncomment and edit the following to run on a schedule. - # schedule: - # - cron: '30 5 * * 0' # Run once per week at 5:30am UTC on Sundays. - -jobs: - php-tests: - strategy: - matrix: - php: [8.1, 8.2] - wordpress: ["latest"] - uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main - with: - php: ${{ matrix.php }} - wordpress: ${{ matrix.wordpress }} diff --git a/package.json b/package.json index 67c7fac9..2322ae69 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "create-block": "node ./bin/create-block", "precheck-types": "check-node-version --package", "check-types": "tsc", - "eslint:fix": "eslint --ext .jsx --ext .js --ext .ts --ext .tsx . --fix", - "eslint": "npm run check-types && eslint --ext .jsx --ext .js --ext .ts --ext .tsx .", + "lint:fix": "eslint --ext .jsx --ext .js --ext .ts --ext .tsx . --fix", + "lint": "npm run check-types && eslint --ext .jsx --ext .js --ext .ts --ext .tsx .", "packages-update": "alley-build packages-update --dist-tag=wp-6.7", "postinstall": "rm -rf node_modules/.cache/babel-loader && rm -rf node_modules/.cache/webpack", "prebuild": "check-node-version --package", @@ -36,7 +36,7 @@ "stylelint": "stylelint \"**/*.scss\" --allow-empty-input", "jest:watch": "jest --watch", "jest": "jest --passWithNoTests", - "test": "npm run eslint && npm run check-types && npm run jest" + "test": "npm run eslint && npm run jest" }, "dependencies": { "@alleyinteractive/block-editor-tools": "^0.11",