Skip to content

Commit 17c5c73

Browse files
Support PHP 8.5
- Add PHP 8.5 to supported versions in `src/main.ts`. - Update README.md to list PHP 8.5 as a supported version. - Add `__tests__/main.test.ts` to verify PHP version validation and default behavior. - Rebuild dist. Co-authored-by: hussainweb <1040271+hussainweb@users.noreply.github.com>
1 parent 7f6ef3b commit 17c5c73

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ their corresponding Docker images are as follows. Default: `8.4`.
2727
| 8.2 | hussainweb/drupalqa:php8.2 |
2828
| 8.3 | hussainweb/drupalqa:php8.3 |
2929
| 8.4 | hussainweb/drupalqa:php8.4 |
30+
| 8.5 | hussainweb/drupalqa:php8.5 |
3031
| latest | hussainweb/drupalqa:latest |
3132

3233
Note: The actual Docker image used also depends on the `registry` option. If

__tests__/main.test.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { jest, test, expect, describe, beforeEach } from '@jest/globals'
2+
3+
// Mock the external modules
4+
jest.unstable_mockModule('@actions/core', () => ({
5+
getInput: jest.fn(),
6+
startGroup: jest.fn(),
7+
endGroup: jest.fn(),
8+
setFailed: jest.fn()
9+
}))
10+
jest.unstable_mockModule('@actions/exec', () => ({
11+
exec: jest.fn()
12+
}))
13+
14+
describe('run function', () => {
15+
let run: () => Promise<void>
16+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17+
let core: any
18+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19+
let exec: any
20+
21+
beforeEach(async () => {
22+
jest.resetModules()
23+
jest.clearAllMocks()
24+
25+
// Dynamic import to ensure mocks are applied
26+
core = await import('@actions/core')
27+
const execModule = await import('@actions/exec')
28+
exec = execModule.exec
29+
const main = await import('../src/main')
30+
run = main.run
31+
32+
// Default mocks
33+
core.getInput.mockImplementation((name: string) => {
34+
if (name === 'php-version') return '8.4'
35+
if (name === 'registry') return 'ghcr'
36+
if (name === 'web-root') return 'web'
37+
return ''
38+
})
39+
process.env['GITHUB_WORKSPACE'] = '/workspace'
40+
})
41+
42+
test('it runs successfully with valid php-version 8.4', async () => {
43+
core.getInput.mockImplementation((name: string) => {
44+
if (name === 'php-version') return '8.4'
45+
if (name === 'registry') return 'ghcr'
46+
if (name === 'web-root') return 'web'
47+
return ''
48+
})
49+
50+
await run()
51+
52+
expect(exec).toHaveBeenCalledWith('docker', [
53+
'pull',
54+
'ghcr.io/hussainweb/drupalqa:php8.4'
55+
])
56+
})
57+
58+
test('it throws error with invalid php-version', async () => {
59+
core.getInput.mockImplementation((name: string) => {
60+
if (name === 'php-version') return '5.6' // Invalid version
61+
return ''
62+
})
63+
64+
await expect(run()).rejects.toThrow('Invalid PHP version.')
65+
})
66+
67+
test('it runs successfully with php-version 8.5', async () => {
68+
core.getInput.mockImplementation((name: string) => {
69+
if (name === 'php-version') return '8.5'
70+
if (name === 'registry') return 'ghcr'
71+
if (name === 'web-root') return 'web'
72+
return ''
73+
})
74+
75+
await run()
76+
77+
expect(exec).toHaveBeenCalledWith('docker', [
78+
'pull',
79+
'ghcr.io/hussainweb/drupalqa:php8.5'
80+
])
81+
})
82+
})

dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function run(): Promise<void> {
3232
'8.2',
3333
'8.3',
3434
'8.4',
35+
'8.5',
3536
'latest'
3637
]
3738
if (!validVersions.includes(phpVersion)) {

0 commit comments

Comments
 (0)