Skip to content

Commit 6c18b5c

Browse files
committed
ci: Simplify validate-config CI workflow
1 parent 45f6bff commit 6c18b5c

File tree

3 files changed

+32
-47
lines changed

3 files changed

+32
-47
lines changed

.github/workflows/build-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 1
3232
- name: Log in to Docker Hub
@@ -50,7 +50,7 @@ jobs:
5050
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
5151
with:
5252
platforms: ${{ inputs.multiarch == true && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
53-
- name: Build and push images
53+
- name: Build and push image
5454
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
5555
with:
5656
context: ${{ inputs.context }}

.github/workflows/validate-config-for-version.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/validate-config.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,40 @@ on:
66
- 'config.php'
77
- 'php/includes/**'
88
- '.github/workflows/validate-config.yml'
9-
- '.github/workflows/validate-config-for-version.yml'
109

1110
jobs:
1211
validate-config:
13-
uses: ./.github/workflows/validate-config-for-version.yml
12+
name: Validate for PHP ${{ matrix.php-version }}
13+
runs-on: ubuntu-latest
1414
strategy:
1515
fail-fast: true
1616
matrix:
1717
php-version: ['8.4', '5.5']
18-
with:
19-
php-version: ${{ matrix.php-version }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 1
23+
- name: Create symlinks for config.php includes
24+
run: |
25+
sudo mkdir -p /var/www/totara
26+
sudo ln -sf "$GITHUB_WORKSPACE/php/includes" /var/www/totara/includes
27+
- name: Set up PHP ${{ matrix.php-version }}
28+
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
29+
with:
30+
php-version: ${{ matrix.php-version }}
31+
- name: Validate config.php syntax (PHP ${{ matrix.php-version }})
32+
run: php -l ./config.php && find ./php/includes -name '*.php' -exec php -l {} +
33+
- name: Check that required $CFG variables are defined (PHP ${{ matrix.php-version }})
34+
run: |
35+
php -r '
36+
define("CLI_SCRIPT", true);
37+
define("ABORT_AFTER_CONFIG", true);
38+
include "config.php";
39+
foreach (["dbhost", "dbtype", "dbuser", "dbpass", "dbname", "prefix", "wwwroot", "dataroot"] as $var) {
40+
if (!isset($CFG->{$var})) {
41+
fwrite(STDERR, "Missing \$CFG->{$var} from config.php (or from php/includes/) - is it commented out?\n");
42+
exit(1);
43+
}
44+
}
45+
'

0 commit comments

Comments
 (0)