Skip to content

Commit b6b4476

Browse files
committed
Tests: Switch Github actions workflows to reusable workflows by Moodle an Hochschulen e.V.
1 parent ea086e2 commit b6b4476

File tree

3 files changed

+25
-169
lines changed

3 files changed

+25
-169
lines changed
Lines changed: 15 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,19 @@
11
name: Moodle Plugin CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
moodle-core-branch:
9+
description: 'Moodle core branch to test against (if not provided, the branch will be auto-detected)'
10+
required: false
11+
type: string
12+
repository_dispatch:
13+
types: [moodle-plugin-ci]
414

515
jobs:
6-
test:
7-
runs-on: ubuntu-22.04
8-
9-
services:
10-
postgres:
11-
image: postgres:14
12-
env:
13-
POSTGRES_USER: 'postgres'
14-
POSTGRES_HOST_AUTH_METHOD: 'trust'
15-
ports:
16-
- 5432:5432
17-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
18-
19-
mariadb:
20-
image: mariadb:10
21-
env:
22-
MYSQL_USER: 'root'
23-
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
24-
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
25-
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
26-
ports:
27-
- 3306:3306
28-
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
29-
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
php: ['8.2', '8.3', '8.4']
34-
moodle-branch: ['MOODLE_500_STABLE']
35-
database: [pgsql, mariadb]
36-
37-
steps:
38-
- name: Check out repository code
39-
uses: actions/checkout@v4
40-
with:
41-
path: plugin
42-
43-
- name: Setup PHP ${{ matrix.php }}
44-
uses: shivammathur/setup-php@v2
45-
with:
46-
php-version: ${{ matrix.php }}
47-
extensions: ${{ matrix.extensions }}
48-
ini-values: max_input_vars=5000
49-
coverage: none
50-
51-
- name: Initialise moodle-plugin-ci
52-
run: |
53-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
54-
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
55-
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
56-
sudo locale-gen en_AU.UTF-8
57-
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
58-
59-
- name: Install moodle-plugin-ci
60-
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
61-
env:
62-
DB: ${{ matrix.database }}
63-
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
64-
65-
- name: PHP Lint
66-
if: ${{ !cancelled() }}
67-
run: moodle-plugin-ci phplint
68-
69-
- name: PHP Mess Detector
70-
continue-on-error: true # This step will show errors but will not fail
71-
if: ${{ !cancelled() }}
72-
run: moodle-plugin-ci phpmd
73-
74-
- name: Moodle Code Checker
75-
if: ${{ !cancelled() }}
76-
run: moodle-plugin-ci phpcs --max-warnings 0
77-
78-
- name: Moodle PHPDoc Checker
79-
if: ${{ !cancelled() }}
80-
run: moodle-plugin-ci phpdoc --max-warnings 0
81-
82-
- name: Validating
83-
if: ${{ !cancelled() }}
84-
run: moodle-plugin-ci validate
85-
86-
- name: Check upgrade savepoints
87-
if: ${{ !cancelled() }}
88-
run: moodle-plugin-ci savepoints
89-
90-
- name: Mustache Lint
91-
if: ${{ !cancelled() }}
92-
run: moodle-plugin-ci mustache
93-
94-
- name: Grunt
95-
if: ${{ !cancelled() }}
96-
run: moodle-plugin-ci grunt --max-lint-warnings 0
97-
98-
- name: PHPUnit tests
99-
if: ${{ !cancelled() }}
100-
run: moodle-plugin-ci phpunit --fail-on-warning
101-
102-
- name: Behat features
103-
id: behat
104-
if: ${{ !cancelled() }}
105-
run: moodle-plugin-ci behat --profile chrome
106-
107-
- name: Upload Behat Faildump
108-
if: ${{ failure() && steps.behat.outcome == 'failure' }}
109-
uses: actions/upload-artifact@v4
110-
with:
111-
name: Behat Faildump (${{ join(matrix.*, ', ') }})
112-
path: ${{ github.workspace }}/moodledata/behat_dump
113-
retention-days: 7
114-
if-no-files-found: ignore
115-
116-
- name: Mark cancelled jobs as failed.
117-
if: ${{ cancelled() }}
118-
run: exit 1
16+
moodle-plugin-ci:
17+
uses: moodle-an-hochschulen/moodle-workflows/.github/workflows/moodle-plugin-ci.yml@main
18+
with:
19+
moodle-core-branch: ${{ inputs.moodle-core-branch || github.event.client_payload.moodle-core-branch }}
Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,17 @@
1-
#
2-
# Whenever a new tag starting with "v" is pushed, add the tagged version
3-
# to the Moodle Plugins directory at https://moodle.org/plugins
4-
#
5-
# revision: 2021070201
6-
#
7-
name: Releasing in the Plugins directory
1+
name: Moodle Plugin Release
82

93
on:
104
push:
115
tags:
126
- v*
13-
147
workflow_dispatch:
158
inputs:
169
tag:
17-
description: 'Tag to be released'
10+
description: 'Git tag to be released'
1811
required: true
1912

20-
defaults:
21-
run:
22-
shell: bash
23-
2413
jobs:
25-
release-at-moodle-org:
26-
runs-on: ubuntu-latest
27-
env:
28-
PLUGIN: local_bulkenrol
29-
CURL: curl -s
30-
ENDPOINT: https://moodle.org/webservice/rest/server.php
31-
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
32-
FUNCTION: local_plugins_add_version
33-
34-
steps:
35-
- name: Call the service function
36-
id: add-version
37-
run: |
38-
if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then
39-
TAGNAME="${{ github.event.inputs.tag }}"
40-
elif [[ $GITHUB_REF = refs/tags/* ]]; then
41-
TAGNAME="${GITHUB_REF##*/}"
42-
fi
43-
if [[ -z "${TAGNAME}" ]]; then
44-
echo "No tag name has been provided!"
45-
exit 1
46-
fi
47-
ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}"
48-
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
49-
--data-urlencode "wsfunction=${FUNCTION}" \
50-
--data-urlencode "moodlewsrestformat=json" \
51-
--data-urlencode "frankenstyle=${PLUGIN}" \
52-
--data-urlencode "zipurl=${ZIPURL}" \
53-
--data-urlencode "vcssystem=git" \
54-
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
55-
--data-urlencode "vcstag=${TAGNAME}" \
56-
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
57-
--data-urlencode "altdownloadurl=${ZIPURL}")
58-
echo "response=${RESPONSE}" >> $GITHUB_OUTPUT
59-
60-
- name: Evaluate the response
61-
id: evaluate-response
62-
env:
63-
RESPONSE: ${{ steps.add-version.outputs.response }}
64-
run: |
65-
jq <<< ${RESPONSE}
66-
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null
14+
release:
15+
uses: moodle-an-hochschulen/moodle-workflows/.github/workflows/moodle-release.yml@main
16+
secrets:
17+
MOODLE_ORG_TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ moodle-local_bulkenrol
44
Changes
55
-------
66

7+
### Unreleased
8+
9+
* 2025-10-15 - Tests: Switch Github actions workflows to reusable workflows by Moodle an Hochschulen e.V.
10+
711
### v5.0-r3
812

913
* 2025-09-11 - Improvement: Make enrollment instructions gender-neutral, solved by #40.

0 commit comments

Comments
 (0)