Skip to content

Commit 1145685

Browse files
Update codecoverage-main.yml
1 parent f517faf commit 1145685

File tree

1 file changed

+100
-100
lines changed

1 file changed

+100
-100
lines changed

.github/workflows/codecoverage-main.yml

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,106 +4,106 @@ name: Codecoverage-Main
44
# GitHub Pages, generates a README badge with the coverage percentage.
55

66
on:
7-
push:
8-
branches:
9-
- main
7+
push:
8+
branches:
9+
- main
1010

1111
jobs:
1212

13-
codecoverage-main:
14-
runs-on: ubuntu-latest
15-
16-
services:
17-
mysql:
18-
image: mysql:8.0
19-
env:
20-
MYSQL_ROOT_PASSWORD: password
21-
MYSQL_DATABASE: tests-wordpress
22-
ports:
23-
- 33306:3306
24-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
25-
26-
strategy:
27-
matrix:
28-
php: [ '7.4' ]
29-
30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@v3
33-
34-
- name: Check does gh-pages branch need to be created
35-
run: |
36-
if [[ $(git branch -l gh-pages) == "" ]]; then
37-
gh_pages_branch_needed=true
38-
else
39-
gh_pages_branch_needed=false
40-
fi
41-
echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
42-
mkdir gh-pages
43-
44-
- name: Maybe create gh-pages branch
45-
if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
46-
uses: peaceiris/actions-gh-pages@v4
47-
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
publish_dir: ./gh-pages
50-
force_orphan: true
51-
allow_empty_commit: true
52-
commit_message: "🤖 Creating gh-pages branch"
53-
54-
- name: Checkout GitHub Pages branch for code coverage report
55-
uses: actions/checkout@v3
56-
with:
57-
ref: gh-pages
58-
path: gh-pages
59-
60-
- name: Install PHP
61-
uses: shivammathur/setup-php@2.11.0
62-
with:
63-
php-version: ${{ matrix.php }}
64-
coverage: xdebug
65-
tools: composer, jaschilz/php-coverage-badger
66-
extensions: zip
67-
68-
- name: Read .env.testing
69-
uses: c-py/action-dotenv-to-setenv@v2
70-
with:
71-
env-file: .env.testing
72-
73-
- name: Run composer install
74-
continue-on-error: true
75-
run: composer install -v
76-
77-
- name: Allow writing to wp-content
78-
run: sudo chmod -R a+w wp-content
79-
80-
- name: Clear previous code coverage
81-
run: |
82-
rm -rf gh-pages/phpunit || true;
83-
mkdir gh-pages/phpunit || true;
84-
85-
- name: Run tests
86-
run: XDEBUG_MODE=coverage composer test-coverage
87-
88-
- name: Merge code coverage
89-
run: vendor/bin/phpcov merge --clover gh-pages/phpunit/clover.xml --php gh-pages/phpunit/phpunit.cov --html gh-pages/phpunit/html/ tests/_output/;
90-
91-
# See: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
92-
- name: Add `.nojekyll` file so code coverage report successfully deploys to gh-pages
93-
working-directory: gh-pages/phpunit
94-
run: |
95-
touch .nojekyll
96-
git add -- .nojekyll *
97-
98-
- name: Update README badge
99-
run: php-coverage-badger gh-pages/phpunit/clover.xml gh-pages/phpunit/coverage.svg
100-
101-
- name: Commit code coverage to gh-pages
102-
uses: stefanzweifel/git-auto-commit-action@v5
103-
with:
104-
repository: gh-pages
105-
branch: gh-pages
106-
commit_message: "🤖 Save code coverage report to gh-pages" # TODO: include the percentage change in the message.
107-
commit_options: ""
108-
env:
109-
GITHUB_TOKEN: "${{ github.token }}"
13+
codecoverage-main:
14+
runs-on: ubuntu-latest
15+
16+
services:
17+
mysql:
18+
image: mysql:8.0
19+
env:
20+
MYSQL_ROOT_PASSWORD: password
21+
MYSQL_DATABASE: tests-wordpress
22+
ports:
23+
- 33306:3306
24+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
25+
26+
strategy:
27+
matrix:
28+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
34+
- name: Check does gh-pages branch need to be created
35+
run: |
36+
if [[ $(git branch -l gh-pages) == "" ]]; then
37+
gh_pages_branch_needed=true
38+
else
39+
gh_pages_branch_needed=false
40+
fi
41+
echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
42+
mkdir gh-pages
43+
44+
- name: Maybe create gh-pages branch
45+
if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
46+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: ./gh-pages
50+
force_orphan: true
51+
allow_empty_commit: true
52+
commit_message: "🤖 Creating gh-pages branch"
53+
54+
- name: Checkout GitHub Pages branch for code coverage report
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
with:
57+
ref: gh-pages
58+
path: gh-pages
59+
60+
- name: Install PHP
61+
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
62+
with:
63+
php-version: ${{ matrix.php }}
64+
coverage: xdebug
65+
tools: composer, jaschilz/php-coverage-badger
66+
extensions: zip
67+
68+
- name: Read .env.testing
69+
uses: c-py/action-dotenv-to-setenv@925b5d99a3f1e4bd7b4e9928be4e2491e29891d9 # v5
70+
with:
71+
env-file: .env.testing
72+
73+
- name: Run composer install
74+
continue-on-error: true
75+
run: composer install -v
76+
77+
- name: Allow writing to wp-content
78+
run: sudo chmod -R a+w wp-content
79+
80+
- name: Clear previous code coverage
81+
run: |
82+
rm -rf gh-pages/phpunit || true;
83+
mkdir gh-pages/phpunit || true;
84+
85+
- name: Run tests
86+
run: XDEBUG_MODE=coverage composer test-coverage
87+
88+
- name: Merge code coverage
89+
run: vendor/bin/phpcov merge --clover gh-pages/phpunit/clover.xml --php gh-pages/phpunit/phpunit.cov --html gh-pages/phpunit/html/ tests/_output/;
90+
91+
# See: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
92+
- name: Add `.nojekyll` file so code coverage report successfully deploys to gh-pages
93+
working-directory: gh-pages/phpunit
94+
run: |
95+
touch .nojekyll
96+
git add -- .nojekyll *
97+
98+
- name: Update README badge
99+
run: php-coverage-badger gh-pages/phpunit/clover.xml gh-pages/phpunit/coverage.svg
100+
101+
- name: Commit code coverage to gh-pages
102+
uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0
103+
with:
104+
repository: gh-pages
105+
branch: gh-pages
106+
commit_message: "🤖 Save code coverage report to gh-pages" # TODO: include the percentage change in the message.
107+
commit_options: ""
108+
env:
109+
GITHUB_TOKEN: "${{ github.token }}"

0 commit comments

Comments
 (0)