Skip to content

Commit 2e7dedd

Browse files
authored
Merge pull request #197 from stellarwp/1.7.1
1.7.1
2 parents fa20039 + 06ce841 commit 2e7dedd

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [1.7.1] - 2024-08-30
8+
* Fixed - Run the `playwright install` command as root, allow running Playwright tests as the `slic` user.
9+
* Change - The `playwright install` command will now install only the Chromium browser and its dependencies.
10+
711
# [1.7.0] - 2024-06-06
812
* Fixed - Properly read changes and restart stack after using the `slic php-version set` command.
913
* Added - PHP 8.3 docker images.

slic-stack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ services:
180180
COLUMNS: "${COLUMNS:-80}"
181181
# Explicitly set the env var that will define the Function Mocker cache path: it will be picked up by the config file.
182182
FUNCTION_MOCKER_CACHE_PATH: "/cache"
183+
# Explicitly set the path to the Playwright browsers cache to make sure it will be the same for all users.
184+
PLAYWRIGHT_BROWSERS_PATH: "/home/slic/.cache/ms-playwright"
183185
volumes:
184186
# Paths are relative to the directory that contains this file, NOT the current working directory.
185187
# Share the WordPress core installation files in the `_wordpress` directory.

slic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
] );
3535

3636
$cli_name = 'slic';
37-
const CLI_VERSION = '1.7.0';
37+
const CLI_VERSION = '1.7.1';
3838

3939
// If the run-time option `-q`, for "quiet", is specified, then do not print the header.
4040
if ( in_array( '-q', $argv, true ) || ( in_array( 'exec', $argv, true ) && ! in_array( 'help', $argv, true ) ) ) {

src/commands/playwright.php

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,40 @@
4444

4545
setup_id();
4646
$playwright_args = $args( '...' );
47-
$status = slic_realtime()(
48-
array_merge(
49-
[
50-
'exec',
51-
'--user',
52-
sprintf( '"%s:%s"', getenv( 'SLIC_UID' ), getenv( 'SLIC_GID' ) ),
53-
'--workdir',
54-
escapeshellarg( get_project_container_path() ),
55-
'slic',
56-
'node_modules/.bin/playwright',
57-
],
58-
$playwright_args
59-
)
60-
);
47+
$is_install_command = $playwright_args[0] === 'install';
48+
49+
if ( $is_install_command ) {
50+
// Install commands will need to run as root.
51+
$user = '0:0';
52+
} else {
53+
// Other commands will run as the current user.
54+
$user = sprintf( '"%s:%s"', getenv( 'SLIC_UID' ), getenv( 'SLIC_GID' ) );
55+
}
56+
57+
if ( $playwright_args === ['install'] ) {
58+
// It's exactly the `playwright install` command and nothing more.
59+
$command = [
60+
'exec',
61+
'--user',
62+
'0:0',
63+
'--workdir',
64+
escapeshellarg( get_project_container_path() ),
65+
'slic',
66+
'node_modules/.bin/playwright install chromium --with-deps',
67+
];
68+
} else {
69+
$command = array_merge( [
70+
'exec',
71+
'--user',
72+
$user,
73+
'--workdir',
74+
escapeshellarg( get_project_container_path() ),
75+
'slic',
76+
'node_modules/.bin/playwright',
77+
], $playwright_args );
78+
}
79+
80+
$status = slic_realtime()( $command );
6181

6282
// If there is a status other than 0, we have an error. Bail.
6383
if ( $status ) {

0 commit comments

Comments
 (0)