Skip to content

Commit e828ee9

Browse files
committed
ci: use Learnweb workflows for tests and releases
1 parent 50b5218 commit e828ee9

File tree

2 files changed

+18
-226
lines changed

2 files changed

+18
-226
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 10 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,181 +1,14 @@
11
name: Moodle Plugin CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
410

511
jobs:
6-
static:
7-
runs-on: ubuntu-latest
8-
9-
strategy:
10-
matrix:
11-
php: ['8.3']
12-
moodle-branch: ['MOODLE_405_STABLE']
13-
database: ['pgsql']
14-
15-
steps:
16-
- name: Start PostgreSQL
17-
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
18-
19-
- name: Check out repository code
20-
uses: actions/checkout@v3
21-
with:
22-
path: plugin
23-
24-
- name: Setup PHP ${{ matrix.php }}
25-
uses: shivammathur/setup-php@v2
26-
with:
27-
php-version: ${{ matrix.php }}
28-
ini-values: max_input_vars=5000
29-
coverage: none
30-
31-
- name: Get composer cache directory
32-
id: composer-cache
33-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34-
35-
- name: Composer cache
36-
uses: actions/cache@v3
37-
with:
38-
path: ${{ steps.composer-cache.outputs.dir }}
39-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40-
restore-keys: |
41-
${{ runner.os }}-composer-
42-
43-
- name: npm cache
44-
uses: actions/cache@v3
45-
with:
46-
path: ~/.npm
47-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
48-
restore-keys: |
49-
${{ runner.os }}-node-
50-
51-
- name: Initialise moodle-plugin-ci
52-
run: |
53-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
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: |
61-
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 --no-init
62-
env:
63-
DB: ${{ matrix.database }}
64-
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
65-
66-
- name: PHP Lint
67-
if: ${{ always() }}
68-
run: moodle-plugin-ci phplint
69-
70-
- name: PHP Copy/Paste Detector
71-
if: ${{ always() }}
72-
run: moodle-plugin-ci phpcpd
73-
74-
- name: PHP Mess Detector
75-
if: ${{ always() }}
76-
run: moodle-plugin-ci phpmd
77-
78-
- name: Moodle Code Checker
79-
if: ${{ always() }}
80-
run: moodle-plugin-ci codechecker
81-
82-
- name: Moodle PHPDoc Checker
83-
if: ${{ 1==2 }}
84-
run: moodle-plugin-ci phpdoc
85-
continue-on-error: true
86-
87-
- name: Validating
88-
if: ${{ always() }}
89-
run: moodle-plugin-ci validate
90-
91-
- name: Check upgrade savepoints
92-
if: ${{ always() }}
93-
run: moodle-plugin-ci savepoints
94-
95-
- name: Mustache Lint
96-
if: ${{ always() }}
97-
run: moodle-plugin-ci mustache
98-
99-
- name: Grunt
100-
if: ${{ always() }}
101-
run: moodle-plugin-ci grunt
102-
103-
test:
104-
runs-on: ubuntu-latest
105-
needs: static
106-
107-
strategy:
108-
fail-fast: false
109-
matrix:
110-
php: ['8.3']
111-
moodle-branch: ['MOODLE_405_STABLE']
112-
database: ['mariadb', 'pgsql']
113-
include:
114-
- php: '8.3'
115-
moodle-branch: 'MOODLE_405_STABLE'
116-
database: 'mariadb'
117-
- php: '8.3'
118-
moodle-branch: 'MOODLE_405_STABLE'
119-
database: 'pgsql'
120-
121-
steps:
122-
- name: Start MariaDB
123-
if: matrix.database == 'mariadb'
124-
run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10
125-
126-
- name: Start PostgreSQL
127-
if: matrix.database == 'pgsql'
128-
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
129-
130-
- name: Check out repository code
131-
uses: actions/checkout@v3
132-
with:
133-
path: plugin
134-
135-
- name: Setup PHP ${{ matrix.php }}
136-
uses: shivammathur/setup-php@v2
137-
with:
138-
php-version: ${{ matrix.php }}
139-
ini-values: max_input_vars=5000
140-
coverage: none
141-
142-
- name: Get composer cache directory
143-
id: composer-cache
144-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
145-
- name: Composer cache
146-
uses: actions/cache@v3
147-
with:
148-
path: ${{ steps.composer-cache.outputs.dir }}
149-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
150-
restore-keys: |
151-
${{ runner.os }}-composer-
152-
- name: npm cache
153-
uses: actions/cache@v3
154-
with:
155-
path: ~/.npm
156-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
157-
restore-keys: |
158-
${{ runner.os }}-node-
159-
160-
- name: Initialise moodle-plugin-ci
161-
run: |
162-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
163-
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
164-
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
165-
sudo locale-gen en_AU.UTF-8
166-
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
167-
168-
- name: Install moodle-plugin-ci
169-
run: |
170-
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
171-
env:
172-
DB: ${{ matrix.database }}
173-
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
174-
175-
- name: PHPUnit tests
176-
if: ${{ always() }}
177-
run: moodle-plugin-ci phpunit
178-
179-
- name: Behat features
180-
if: ${{ always() }}
181-
run: moodle-plugin-ci behat --auto-rerun 0
12+
call-moodle-ci:
13+
name: "Run CI workflow for Learnweb plugins"
14+
uses: learnweb/moodle-workflows-learnweb/.github/workflows/moodle-ci.yml@main
Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,13 @@
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-
# Changed to be released on Github release with the release notes.
7-
#
8-
name: Releasing in the Plugins directory
1+
name: Moodle Plugin Release
92

103
on:
114
release:
12-
types: [published]
13-
14-
defaults:
15-
run:
16-
shell: bash
5+
types:
6+
- published
177

188
jobs:
19-
release-at-moodle-org:
20-
runs-on: ubuntu-latest
21-
env:
22-
PLUGIN: mod_collaborativefolders
23-
CURL: curl -s
24-
ENDPOINT: https://moodle.org/webservice/rest/server.php
25-
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
26-
FUNCTION: local_plugins_add_version
27-
28-
steps:
29-
- name: Call the service function
30-
id: add-version
31-
run: |
32-
TAGNAME="${{ github.event.release.tag_name }}"
33-
BODY="${{ github.event.release.body }}"
34-
ZIPURL="${{ github.event.release.zipball_url }}"
35-
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
36-
--data-urlencode "wsfunction=${FUNCTION}" \
37-
--data-urlencode "moodlewsrestformat=json" \
38-
--data-urlencode "frankenstyle=${PLUGIN}" \
39-
--data-urlencode "zipurl=${ZIPURL}" \
40-
--data-urlencode "vcssystem=git" \
41-
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
42-
--data-urlencode "vcstag=${TAGNAME}" \
43-
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
44-
--data-urlencode "altdownloadurl=${ZIPURL}" \
45-
--data-urlencode "releasenotes=${BODY}" \
46-
--data-urlencode "releasenotesformat=4")
47-
echo "response=${RESPONSE}" >> $GITHUB_OUTPUT
48-
- name: Evaluate the response
49-
id: evaluate-response
50-
env:
51-
RESPONSE: ${{ steps.add-version.outputs.response }}
52-
run: |
53-
jq <<< ${RESPONSE}
54-
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null
9+
call-moodle-release-workflow:
10+
uses: learnweb/moodle-workflows-learnweb/.github/workflows/moodle-release.yml@main
11+
with:
12+
plugin-name: 'mod_collaborativefolders'
13+
secrets: inherit

0 commit comments

Comments
 (0)