Skip to content

Commit 585a105

Browse files
authored
Merge pull request #11 from jackd248/workflows
build: refactor workflows to use reusable GitHub actions for release and tests
2 parents d0d2e02 + ed31fe5 commit 585a105

File tree

2 files changed

+2
-121
lines changed

2 files changed

+2
-121
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,5 @@ on:
66
- '*'
77

88
jobs:
9-
# Job: Create release
109
release:
11-
if: startsWith(github.ref, 'refs/tags/')
12-
runs-on: ubuntu-latest
13-
outputs:
14-
release-notes-url: ${{ steps.create-release.outputs.url }}
15-
steps:
16-
- uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0
19-
20-
# Check if tag is valid
21-
- name: Check tag
22-
run: |
23-
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
24-
exit 1
25-
fi
26-
27-
# Create release
28-
- name: Create release
29-
id: create-release
30-
uses: softprops/action-gh-release@v2
31-
with:
32-
generate_release_notes: true
10+
uses: jackd248/reusable-github-actions/.github/workflows/release.yml@main

.github/workflows/tests.yml

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6,101 +6,4 @@ on:
66

77
jobs:
88
tests:
9-
name: Tests (PHP ${{ matrix.php-version }} & ${{ matrix.dependencies }} dependencies)
10-
runs-on: ubuntu-latest
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
php-version: ["8.1", "8.2", "8.3", "8.4"]
15-
dependencies: ["highest", "lowest"]
16-
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
20-
21-
# Prepare environment
22-
- name: Setup PHP
23-
uses: shivammathur/setup-php@v2
24-
with:
25-
php-version: ${{ matrix.php-version }}
26-
tools: composer:v2
27-
coverage: none
28-
29-
# Install dependencies
30-
- name: Install Composer dependencies
31-
uses: ramsey/composer-install@v3
32-
with:
33-
dependency-versions: ${{ matrix.dependencies }}
34-
35-
# Run tests
36-
- name: Run tests
37-
run: composer test
38-
39-
coverage:
40-
name: Test coverage
41-
runs-on: ubuntu-latest
42-
steps:
43-
- uses: actions/checkout@v4
44-
with:
45-
fetch-depth: 0
46-
47-
# Prepare environment
48-
- name: Setup PHP
49-
uses: shivammathur/setup-php@v2
50-
with:
51-
php-version: 8.4
52-
tools: composer:v2
53-
coverage: pcov
54-
55-
# Install dependencies
56-
- name: Install Composer dependencies
57-
uses: ramsey/composer-install@v3
58-
59-
# Run tests
60-
- name: Build coverage directory
61-
run: mkdir -p .build/coverage
62-
- name: Run tests with coverage
63-
run: composer test:coverage
64-
65-
# Upload artifact
66-
- name: Fix coverage path
67-
working-directory: .build/coverage
68-
run: sed -i 's#/home/runner/work/php-cs-fixer-config/php-cs-fixer-config#${{ github.workspace }}#g' clover.xml
69-
- name: Upload coverage artifact
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: coverage
73-
path: .build/coverage/clover.xml
74-
retention-days: 7
75-
76-
coverage-report:
77-
name: Report test coverage
78-
runs-on: ubuntu-latest
79-
needs: coverage
80-
steps:
81-
- uses: actions/checkout@v4
82-
with:
83-
fetch-depth: 0
84-
85-
# Download artifact
86-
- name: Download coverage artifact
87-
id: download
88-
uses: actions/download-artifact@v5
89-
with:
90-
name: coverage
91-
92-
# CodeClimate
93-
- name: CodeClimate report
94-
uses: paambaati/codeclimate-action@v9.0.0
95-
if: env.CC_TEST_REPORTER_ID
96-
env:
97-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
98-
with:
99-
coverageLocations: |
100-
${{ steps.download.outputs.download-path }}/clover.xml:clover
101-
102-
# Coveralls
103-
- name: Coveralls report
104-
uses: coverallsapp/github-action@v2
105-
with:
106-
file: ${{ steps.download.outputs.download-path }}/clover.xml
9+
uses: jackd248/reusable-github-actions/.github/workflows/tests-php.yml@main

0 commit comments

Comments
 (0)