Skip to content

chore: init 2024-12 #729

chore: init 2024-12

chore: init 2024-12 #729

name: Continuous integration
on:
push:
branches: [ master, release* ]
pull_request:
branches: [ master, release* ]
jobs:
ci:
runs-on: ${{ matrix.operating-system }}
if: "!contains(github.event.head_commit.message, 'ci: add updated coverage_badge.svg')"
concurrency:
group: ci-${{ matrix.php-version }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-version: [ '7.4', '8.0', '8.3' ]
include:
- php-version: '8.3'
node-version: '18'
coverage: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Use Node.js ${{ matrix.node-version }}
if: ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Configure NPM bridge plugin
run: composer config allow-plugins.oat-sa/composer-npm-bridge $([[ "${{ matrix.node-version }}" ]] && echo "true" || echo "false") --no-interaction --no-plugins
- name: Install dependencies
run: composer install --no-progress
- name: Generate localization files
if: ${{ matrix.node-version }}
run: php tao/scripts/tools/GenerateTranslationBundles.php
- name: Front-end tests
if: ${{ matrix.node-version }}
working-directory: tao/views/build
run: |
npm ci
npx grunt connect:test qunit_junit pcisamplestest qtiitempcitest taotest taoclientdiagnostictest taodeliveryrdftest taoitemstest taomediamanagertest taooutcomeuitest taoproctoringtest taoqtiitemtest taoqtitesttest taoqtitestpreviewertest taotaskqueuetest taoteststest --force --reports=../../../junit-reports
- name: Back-end tests
run: ./test.sh ${{ matrix.coverage && '-c' }}
continue-on-error: true
- name: Publish a back-end test report
uses: mikepenz/action-junit-report@v3
id: be-junit
with:
report_paths: 'log/*/junit.xml'
job_summary: false
- name: Publish a front-end test report
if: ${{ matrix.node-version }}
uses: mikepenz/action-junit-report@v3
id: fe-junit
with:
job_summary: false
- name: Parse the the back-end reports
id: report
run: grep testFailed log/*/teamcity.txt -R > /tmp/failures.txt
- name: Build back-end coverage report link
id: report-link
if: ${{ matrix.coverage }}
run: echo formatted='[🔗 Coverage report](https://oat-sa.github.io/tao-community/${{ github.head_ref || github.ref_name }})' >> $GITHUB_OUTPUT
- name: Back-end job summary
uses: mathiasvr/[email protected]
id: be-summary
with:
run: |
cat << EOF
# Back-end summary PHP ${{ matrix.php-version }}
${{ steps.report-link.outputs.formatted }}
|💯 Total|✅ Passed|⏭️ Skipped|❌ Failed|
|-|-|-|-|
|${{ steps.be-junit.outputs.total }}|${{ steps.be-junit.outputs.passed }}|${{ steps.be-junit.outputs.skipped }}|${{ steps.be-junit.outputs.failed }}|
EOF
php ./.github/parse-reports.php
- name: Front-end job summary
if: ${{ matrix.node-version }}
uses: mathiasvr/[email protected]
id: fe-summary
with:
run: |
cat << EOF
# Front-end summary Node ${{ matrix.node-version }}
|💯 Total|✅ Passed|⏭️ Skipped|❌ Failed|
|-|-|-|-|
|${{ steps.fe-junit.outputs.total }}|${{ steps.fe-junit.outputs.passed }}|${{ steps.fe-junit.outputs.skipped }}|${{ steps.fe-junit.outputs.failed }}|
EOF
php ./.github/parse-reports.php
- uses: peter-evans/find-comment@v2
id: be-summary-comment
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Back-end summary PHP ${{ matrix.php-version }}
- uses: peter-evans/find-comment@v2
id: fe-summary-comment
if: ${{ github.event_name == 'pull_request' && matrix.node-version }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Front-end summary Node ${{ matrix.node-version }}
- name: Create or update back-end summary comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request'
with:
comment-id: ${{ steps.be-summary-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.be-summary.outputs.stdout }}
edit-mode: replace
- name: Create or update front-end summary comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ github.event_name == 'pull_request' && matrix.node-version }}
with:
comment-id: ${{ steps.fe-summary-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.fe-summary.outputs.stdout }}
edit-mode: replace
- name: Merge coverage reports
run: vendor/bin/phpunit-merger coverage coverage --html=clover clover.xml
if: ${{ matrix.coverage }}
- name: Generate a coverage badge
uses: timkrase/[email protected]
if: ${{ matrix.coverage }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Push a coverage badge
uses: EndBug/add-and-commit@v9
if: ${{ matrix.coverage }}
with:
add: coverage_badge.svg
commit: --signoff
message: 'ci: add updated coverage_badge.svg'
- name: Deploy coverage reports
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ matrix.coverage }}
with:
folder: clover
target-folder: ${{ github.head_ref || github.ref_name }}
single-commit: true
token: ${{ secrets.CI_GITHUB_TOKEN }}
- name: Back-end job summary
run: echo "${{ steps.be-summary.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY
- name: Front-end job summary
if: ${{ matrix.node-version }}
run: echo "${{ steps.fe-summary.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY
- name: Fail the job if back-end tests weren't OK
run: exit ${{ steps.be-junit.outputs.failed }}
- name: Fail the job if front-end tests weren't OK
if: ${{ matrix.node-version }}
run: exit ${{ steps.fe-junit.outputs.failed }}