feat: Front-end tests execution #354
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous integration | |
on: | |
push: | |
branches: [ master, release*, feat* ] | |
pull_request: | |
branches: [ master, release*, feat* ] | |
env: | |
node-version: '14.x' | |
jobs: | |
ci: | |
runs-on: ${{ matrix.operating-system }} | |
if: "!contains(github.event.head_commit.message, 'ci: add updated coverage_badge.svg')" | |
strategy: | |
fail-fast: false | |
matrix: | |
operating-system: [ ubuntu-latest ] | |
php-version: [ '7.4' ] | |
node-version: [ 14.x ] | |
include: | |
- php-version: '7.4' | |
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.php-versions == '7.4' | |
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: Install dependencies | |
run: composer install --no-progress | |
- name: Run tests | |
run: ./test.sh ${{ matrix.coverage && '-c' }} | |
continue-on-error: true | |
- name: Front tests | |
working-directory: tao/views/build | |
run: | | |
cat package.json | |
npm ci | |
npx grunt testall --force | |
continue-on-error: true | |
- name: Publish a test report | |
uses: mikepenz/action-junit-report@v3 | |
id: junit | |
with: | |
report_paths: 'log/*/junit.xml' | |
job_summary: false | |
- name: Parse the the reports | |
id: report | |
run: grep testFailed log/*/teamcity.txt -R > /tmp/failures.txt | |
- name: Build 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: Job summary | |
uses: mathiasvr/command-output@v2.0.0 | |
id: summary | |
with: | |
run: | | |
cat << EOF | |
# Summary ${{ matrix.php-version }} | |
${{ steps.report-link.outputs.formatted }} | |
|💯 Total|✅ Passed|⏭️ Skipped|❌ Failed| | |
|-|-|-|-| | |
|${{ steps.junit.outputs.total }}|${{ steps.junit.outputs.passed }}|${{ steps.junit.outputs.skipped }}|${{ steps.junit.outputs.failed }}| | |
EOF | |
php ./.github/parse-reports.php | |
- uses: peter-evans/find-comment@v2 | |
id: summary-comment | |
if: github.event_name == 'pull_request' | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Summary ${{ matrix.php-version }} | |
- name: Create or update summary comment | |
uses: peter-evans/create-or-update-comment@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
comment-id: ${{ steps.summary-comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: ${{ steps.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/phpunit-coverage-badge@v1.2.0 | |
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: Job summary | |
run: echo "${{ steps.summary.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY | |
- name: Fail the job if tests weren't OK | |
run: exit ${{ steps.junit.outputs.failed }} |