Skip to content

Commit 27f0883

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 deae3fe commit 27f0883

File tree

3 files changed

+119
-103
lines changed

3 files changed

+119
-103
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 & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +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: |
54-
diff -B ./PHPCompatibilityPasswordCompat/ruleset.xml <(xmllint --format "./PHPCompatibilityPasswordCompat/ruleset.xml")
55-
56-
test:
57-
# Don't run the cron job on forks.
58-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
59-
60-
needs: xmllint
61-
runs-on: ubuntu-latest
62-
63-
strategy:
64-
matrix:
65-
php: ['5.4', 'latest']
66-
phpcompat: ['stable']
67-
experimental: [false]
68-
69-
include:
70-
- php: '7.4'
71-
phpcompat: 'dev-develop as 10.99.99'
72-
experimental: true
73-
74-
name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}"
75-
continue-on-error: ${{ matrix.experimental }}
76-
77-
steps:
78-
- name: Checkout code
79-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
80-
with:
81-
persist-credentials: false
82-
83-
- name: Install PHP
84-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
85-
with:
86-
php-version: ${{ matrix.php }}
87-
ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On
88-
coverage: none
89-
90-
- name: Conditionally update PHPCompatibility to develop version
91-
if: ${{ matrix.phpcompat != 'stable' }}
92-
run: |
93-
composer config minimum-stability dev
94-
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" --no-interaction
95-
96-
- name: Install dependencies
97-
run: composer install --no-interaction --no-progress
98-
99-
# Validate the composer.json file.
100-
# @link https://getcomposer.org/doc/03-cli.md#validate
101-
- name: Validate Composer installation
102-
run: composer validate --no-check-all --strict
103-
104-
# Make sure that known polyfills don't trigger any errors.
105-
- name: Test the ruleset
106-
run: >
107-
vendor/bin/phpcs -ps ./Test/PasswordCompatTest.php --standard=PHPCompatibilityPasswordCompat
108-
--exclude=PHPCompatibility.Upgrade.LowPHP
109-
--runtime-set testVersion 5.4-
110-
111-
# Check that the ruleset doesn't throw unnecessary errors for the compat library itself.
112-
- name: Test running against the polyfills
113-
run: >
114-
vendor/bin/phpcs -ps ./vendor/ircmaxell/ --standard=PHPCompatibilityPasswordCompat
115-
--exclude=PHPCompatibility.Upgrade.LowPHP
116-
--ignore=/password-compat/test/*
117-
--runtime-set testVersion 5.4-
15+
QA:
16+
uses: ./.github/workflows/reusable-qa-checks.yml
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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: |
42+
diff -B ./PHPCompatibilityPasswordCompat/ruleset.xml <(xmllint --format "./PHPCompatibilityPasswordCompat/ruleset.xml")
43+
44+
test:
45+
needs: xmllint
46+
runs-on: ubuntu-latest
47+
48+
strategy:
49+
matrix:
50+
php: ['5.4', 'latest']
51+
phpcompat: ['stable']
52+
experimental: [false]
53+
54+
include:
55+
- php: '7.4'
56+
phpcompat: 'dev-develop as 10.99.99'
57+
experimental: true
58+
59+
name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}"
60+
continue-on-error: ${{ matrix.experimental }}
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
65+
with:
66+
persist-credentials: false
67+
68+
- name: Install PHP
69+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
70+
with:
71+
php-version: ${{ matrix.php }}
72+
ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On
73+
coverage: none
74+
75+
- name: Conditionally update PHPCompatibility to develop version
76+
if: ${{ matrix.phpcompat != 'stable' }}
77+
run: |
78+
composer config minimum-stability dev
79+
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" --no-interaction
80+
81+
- name: Install dependencies
82+
run: composer install --no-interaction --no-progress
83+
84+
# Validate the composer.json file.
85+
# @link https://getcomposer.org/doc/03-cli.md#validate
86+
- name: Validate Composer installation
87+
run: composer validate --no-check-all --strict
88+
89+
# Make sure that known polyfills don't trigger any errors.
90+
- name: Test the ruleset
91+
run: >
92+
vendor/bin/phpcs -ps ./Test/PasswordCompatTest.php --standard=PHPCompatibilityPasswordCompat
93+
--exclude=PHPCompatibility.Upgrade.LowPHP
94+
--runtime-set testVersion 5.4-
95+
96+
# Check that the ruleset doesn't throw unnecessary errors for the compat library itself.
97+
- name: Test running against the polyfills
98+
run: >
99+
vendor/bin/phpcs -ps ./vendor/ircmaxell/ --standard=PHPCompatibilityPasswordCompat
100+
--exclude=PHPCompatibility.Upgrade.LowPHP
101+
--ignore=/password-compat/test/*
102+
--runtime-set testVersion 5.4-

0 commit comments

Comments
 (0)