Skip to content

Commit

Permalink
Merge pull request #197 from stellarwp/1.7.1
Browse files Browse the repository at this point in the history
1.7.1
  • Loading branch information
lucatume authored Aug 30, 2024
2 parents fa20039 + 06ce841 commit 2e7dedd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [1.7.1] - 2024-08-30
* Fixed - Run the `playwright install` command as root, allow running Playwright tests as the `slic` user.
* Change - The `playwright install` command will now install only the Chromium browser and its dependencies.

# [1.7.0] - 2024-06-06
* Fixed - Properly read changes and restart stack after using the `slic php-version set` command.
* Added - PHP 8.3 docker images.
Expand Down
2 changes: 2 additions & 0 deletions slic-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ services:
COLUMNS: "${COLUMNS:-80}"
# Explicitly set the env var that will define the Function Mocker cache path: it will be picked up by the config file.
FUNCTION_MOCKER_CACHE_PATH: "/cache"
# Explicitly set the path to the Playwright browsers cache to make sure it will be the same for all users.
PLAYWRIGHT_BROWSERS_PATH: "/home/slic/.cache/ms-playwright"
volumes:
# Paths are relative to the directory that contains this file, NOT the current working directory.
# Share the WordPress core installation files in the `_wordpress` directory.
Expand Down
2 changes: 1 addition & 1 deletion slic.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
] );

$cli_name = 'slic';
const CLI_VERSION = '1.7.0';
const CLI_VERSION = '1.7.1';

// If the run-time option `-q`, for "quiet", is specified, then do not print the header.
if ( in_array( '-q', $argv, true ) || ( in_array( 'exec', $argv, true ) && ! in_array( 'help', $argv, true ) ) ) {
Expand Down
48 changes: 34 additions & 14 deletions src/commands/playwright.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,40 @@

setup_id();
$playwright_args = $args( '...' );
$status = slic_realtime()(
array_merge(
[
'exec',
'--user',
sprintf( '"%s:%s"', getenv( 'SLIC_UID' ), getenv( 'SLIC_GID' ) ),
'--workdir',
escapeshellarg( get_project_container_path() ),
'slic',
'node_modules/.bin/playwright',
],
$playwright_args
)
);
$is_install_command = $playwright_args[0] === 'install';

if ( $is_install_command ) {
// Install commands will need to run as root.
$user = '0:0';
} else {
// Other commands will run as the current user.
$user = sprintf( '"%s:%s"', getenv( 'SLIC_UID' ), getenv( 'SLIC_GID' ) );
}

if ( $playwright_args === ['install'] ) {
// It's exactly the `playwright install` command and nothing more.
$command = [
'exec',
'--user',
'0:0',
'--workdir',
escapeshellarg( get_project_container_path() ),
'slic',
'node_modules/.bin/playwright install chromium --with-deps',
];
} else {
$command = array_merge( [
'exec',
'--user',
$user,
'--workdir',
escapeshellarg( get_project_container_path() ),
'slic',
'node_modules/.bin/playwright',
], $playwright_args );
}

$status = slic_realtime()( $command );

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

0 comments on commit 2e7dedd

Please sign in to comment.