Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
name: Moodle Plugin CI
2
 
3
on: [push, pull_request]
4
 
5
jobs:
6
  test:
7
    runs-on: ubuntu-22.04
8
 
9
    services:
10
      postgres:
11
        image: postgres:13
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
        include:
34
          - php: '8.0'
35
            moodle-branch: 'MOODLE_311_STABLE'
36
            database: 'pgsql'
37
          - php: '7.3'
38
            moodle-branch: 'MOODLE_311_STABLE'
39
            database: 'mariadb'
40
          - php: '8.0'
41
            moodle-branch: 'MOODLE_400_STABLE'
42
            database: 'mariadb'
43
          - php: '7.3'
44
            moodle-branch: 'MOODLE_400_STABLE'
45
            database: 'pgsql'
46
          - php: '8.1'
47
            moodle-branch: 'MOODLE_401_STABLE'
48
            database: 'pgsql'
49
          - php: '7.4'
50
            moodle-branch: 'MOODLE_401_STABLE'
51
            database: 'mariadb'
52
          - php: '8.2'
53
            moodle-branch: 'MOODLE_402_STABLE'
54
            database: 'mariadb'
55
          - php: '8.0'
56
            moodle-branch: 'MOODLE_402_STABLE'
57
            database: 'pgsql'
58
          - php: '8.2'
59
            moodle-branch: 'MOODLE_403_STABLE'
60
            database: 'pgsql'
61
          - php: '8.0'
62
            moodle-branch: 'MOODLE_403_STABLE'
63
            database: 'mariadb'
64
          - php: '8.3'
65
            # Main job. Run all checks that do not require setup and only need to be run once.
66
            runchecks: 'all'
67
            moodle-branch: 'MOODLE_404_STABLE'
68
            database: 'mariadb'
69
          - php: '8.1'
70
            moodle-branch: 'MOODLE_404_STABLE'
71
            database: 'pgsql'
72
 
73
    steps:
74
      - name: Check out repository code
75
        uses: actions/checkout@v4
76
        with:
77
          path: plugin
78
 
79
      - name: Setup PHP ${{ matrix.php }}
80
        uses: shivammathur/setup-php@v2
81
        with:
82
          php-version: ${{ matrix.php }}
83
          extensions: ${{ matrix.extensions }}
84
          ini-values: max_input_vars=5000
85
          # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
86
          # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
87
          coverage: none
88
 
89
      - name: Initialise moodle-plugin-ci
90
        run: |
91
          civersion=$(if [[ "${{ matrix.php }}" =~ ^7.[23]$ ]]; then echo "^3"; fi)
92
          composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci  ${civersion:-^4}
93
          echo $(cd ci/bin; pwd) >> $GITHUB_PATH
94
          echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
95
          sudo locale-gen en_AU.UTF-8
96
          echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
97
 
98
      - name: Install moodle-plugin-ci
99
        run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
100
        env:
101
          DB: ${{ matrix.database }}
102
          MOODLE_BRANCH: ${{ matrix.moodle-branch }}
103
          # Uncomment this to run Behat tests using the Moodle App.
104
          # MOODLE_APP: 'true'
105
 
106
      - name: PHP Lint
107
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
108
        run: moodle-plugin-ci phplint
109
 
110
      - name: PHP Mess Detector
111
        continue-on-error: true # This step will show errors but will not fail
112
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
113
        run: moodle-plugin-ci phpmd
114
 
115
      - name: Moodle Code Checker
116
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
117
        run: moodle-plugin-ci phpcs --max-warnings 0
118
 
119
      - name: Moodle PHPDoc Checker
120
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
121
        run: moodle-plugin-ci phpdoc --max-warnings 0
122
 
123
      - name: Validating
124
        if: ${{ !cancelled() }}
125
        run: moodle-plugin-ci validate
126
 
127
      - name: Check upgrade savepoints
128
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
129
        run: moodle-plugin-ci savepoints
130
 
131
      - name: Mustache Lint
132
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
133
        run: moodle-plugin-ci mustache
134
 
135
      - name: Grunt
136
        if: ${{ !cancelled() && matrix.runchecks == 'all' }}
137
        run: moodle-plugin-ci grunt --max-lint-warnings 0
138
 
139
      - name: PHPUnit tests
140
        if: ${{ !cancelled() }}
141
        run: moodle-plugin-ci phpunit --fail-on-warning
142
 
143
      - name: Behat features
144
        id: behat
145
        if: ${{ !cancelled() }}
146
        run: moodle-plugin-ci behat --profile chrome
147
 
148
      - name: Upload Behat Faildump
149
        if: ${{ failure() && steps.behat.outcome == 'failure' }}
150
        uses: actions/upload-artifact@v4
151
        with:
152
          name: Behat Faildump (${{ join(matrix.*, ', ') }})
153
          path: ${{ github.workspace }}/moodledata/behat_dump
154
          retention-days: 7
155
          if-no-files-found: ignore
156
 
157
      - name: Mark cancelled jobs as failed.
158
        if: ${{ cancelled() }}
159
        run: exit 1