Skip to content

Commit c3481c8

Browse files
committed
GH Actions: split workflow
GitHub has the annoying habit of disabling workflows with a cron job after two months if the repo doesn't see any activity. This is regularly the case for this repo and this creates the following problem: * If the same workflow is used for both the cron job as well as the push/pull_request CI checks... * ... and a repo doesn't have any activity in two months time... * ... the workflow gets disabled... * ... which then also means that CI checks will no longer be run for new PRs.... * ... which means new PRs can't be merged as (in most cases) the repo has branch protection in place and requires that the CI checks pass before a PR can be merged. This commit basically changes the original workflow to a reusable workflow and then creates two new workflows, with different `on` targets, which each trigger the reusable workflow. * One workflow will be triggered via `cron`. * One workflow will have all the other triggers (`push`/`pull_request`/`workflow_dispatch`). This way, if the cron job workflow gets disabled, the workflow which is used for the other triggers will continue to function. The downside of this, is that it may go unnoticed that the cron job has stopped running, but so be it.
1 parent 9f331d1 commit c3481c8

File tree

3 files changed

+110
-94
lines changed

3 files changed

+110
-94
lines changed

.github/workflows/ci-cron.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI Cronjob
2+
3+
on:
4+
# Run this workflow on day 15 of every month as the repo isn't that active.
5+
schedule:
6+
- cron: '0 0 15 * *'
7+
8+
permissions: {}
9+
10+
jobs:
11+
QA:
12+
# Don't run the cron job on forks.
13+
if: ${{ github.event.repository.fork == false }}
14+
15+
uses: ./.github/workflows/reusable-qa-checks.yml

.github/workflows/ci.yml

Lines changed: 2 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,11 @@ on:
66
branches:
77
- master
88
pull_request:
9-
# Also run this workflow on day 15 of every month as the repo isn't that active.
10-
schedule:
11-
- cron: '0 0 15 * *'
129
# Allow manually triggering the workflow.
1310
workflow_dispatch:
1411

1512
permissions: {}
1613

1714
jobs:
18-
xmllint:
19-
# Don't run the cron job on forks.
20-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
21-
22-
name: 'Check XML'
23-
runs-on: ubuntu-latest
24-
25-
env:
26-
XMLLINT_INDENT: ' '
27-
28-
steps:
29-
- name: Checkout code
30-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31-
with:
32-
persist-credentials: false
33-
34-
- name: Install PHP
35-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
36-
with:
37-
php-version: 'latest'
38-
coverage: none
39-
40-
# Install dependencies to make sure the PHPCS XSD file is available.
41-
- name: Install dependencies
42-
run: composer install --no-dev --no-interaction --no-progress
43-
44-
- name: Validate Ruleset XML file against schema
45-
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
46-
with:
47-
pattern: "./*/ruleset.xml"
48-
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
49-
50-
# Check the code-style consistency of the xml file.
51-
# Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner.
52-
- name: Check code style
53-
run: diff -B ./PHPCompatibilityJoomla/ruleset.xml <(xmllint --format "./PHPCompatibilityJoomla/ruleset.xml")
54-
55-
test:
56-
# Don't run the cron job on forks.
57-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
58-
59-
needs: xmllint
60-
runs-on: ubuntu-latest
61-
62-
strategy:
63-
matrix:
64-
php: ['5.4', 'latest']
65-
phpcompat: ['stable']
66-
experimental: [false]
67-
68-
include:
69-
- php: '7.4'
70-
phpcompat: 'dev-develop as 10.99.99'
71-
experimental: true
72-
73-
name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}"
74-
continue-on-error: ${{ matrix.experimental }}
75-
76-
steps:
77-
- name: Checkout code
78-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
79-
with:
80-
persist-credentials: false
81-
82-
- name: Install PHP
83-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
84-
with:
85-
php-version: ${{ matrix.php }}
86-
ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On
87-
coverage: none
88-
89-
- name: Conditionally update PHPCompatibility to develop version
90-
if: ${{ matrix.phpcompat != 'stable' }}
91-
run: |
92-
composer config minimum-stability dev
93-
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" --no-interaction
94-
95-
- name: Install dependencies
96-
run: composer install --no-interaction --no-progress
97-
98-
# Validate the composer.json file.
99-
# @link https://getcomposer.org/doc/03-cli.md#validate
100-
- name: Validate Composer installation
101-
run: composer validate --no-check-all --strict
102-
103-
# Make sure that known polyfills don't trigger any errors.
104-
- name: Test the ruleset
105-
run: >
106-
vendor/bin/phpcs -ps ./Test/JoomlaTest.php --standard=PHPCompatibilityJoomla
107-
--exclude=PHPCompatibility.Upgrade.LowPHP
108-
--runtime-set testVersion 5.3-
15+
QA:
16+
uses: ./.github/workflows/reusable-qa-checks.yml
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
on:
4+
workflow_call:
5+
6+
permissions: {}
7+
8+
jobs:
9+
xmllint:
10+
name: 'Check XML'
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
XMLLINT_INDENT: ' '
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
with:
20+
persist-credentials: false
21+
22+
- name: Install PHP
23+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
24+
with:
25+
php-version: 'latest'
26+
coverage: none
27+
28+
# Install dependencies to make sure the PHPCS XSD file is available.
29+
- name: Install dependencies
30+
run: composer install --no-dev --no-interaction --no-progress
31+
32+
- name: Validate Ruleset XML file against schema
33+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
34+
with:
35+
pattern: "./*/ruleset.xml"
36+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
37+
38+
# Check the code-style consistency of the xml file.
39+
# Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner.
40+
- name: Check code style
41+
run: diff -B ./PHPCompatibilityJoomla/ruleset.xml <(xmllint --format "./PHPCompatibilityJoomla/ruleset.xml")
42+
43+
test:
44+
needs: xmllint
45+
runs-on: ubuntu-latest
46+
47+
strategy:
48+
matrix:
49+
php: ['5.4', 'latest']
50+
phpcompat: ['stable']
51+
experimental: [false]
52+
53+
include:
54+
- php: '7.4'
55+
phpcompat: 'dev-develop as 10.99.99'
56+
experimental: true
57+
58+
name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}"
59+
continue-on-error: ${{ matrix.experimental }}
60+
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
64+
with:
65+
persist-credentials: false
66+
67+
- name: Install PHP
68+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
69+
with:
70+
php-version: ${{ matrix.php }}
71+
ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On
72+
coverage: none
73+
74+
- name: Conditionally update PHPCompatibility to develop version
75+
if: ${{ matrix.phpcompat != 'stable' }}
76+
run: |
77+
composer config minimum-stability dev
78+
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" --no-interaction
79+
80+
- name: Install dependencies
81+
run: composer install --no-interaction --no-progress
82+
83+
# Validate the composer.json file.
84+
# @link https://getcomposer.org/doc/03-cli.md#validate
85+
- name: Validate Composer installation
86+
run: composer validate --no-check-all --strict
87+
88+
# Make sure that known polyfills don't trigger any errors.
89+
- name: Test the ruleset
90+
run: >
91+
vendor/bin/phpcs -ps ./Test/JoomlaTest.php --standard=PHPCompatibilityJoomla
92+
--exclude=PHPCompatibility.Upgrade.LowPHP
93+
--runtime-set testVersion 5.3-

0 commit comments

Comments
 (0)