Skip to content

Commit

Permalink
Merge pull request #103 from woocommerce/23-12/debug-ci
Browse files Browse the repository at this point in the history
Use zip from docker
  • Loading branch information
Luc45 authored Dec 21, 2023
2 parents 08c6f16 + bdc9ef3 commit fdf817c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/self-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ jobs:
- name: Connect to QIT
run: ./qit partner:add --user="${{ secrets.QIT_USER }}" --application_password="${{ secrets.QIT_ACCESS_TOKEN }}"

### Cache ZIP Image
- name: Set up date
id: date
run: |
echo "ZIP_YEAR=$(date +'%Y')" >> $GITHUB_ENV
echo "ZIP_MONTH=$(date +'%m')" >> $GITHUB_ENV
- name: Restore ZIP Image Cache if it exists
id: cache-docker-zip
uses: actions/cache@v3
with:
path: cache-zip
key: cache-docker-zip-${{ env.ZIP_YEAR }}-${{ env.ZIP_MONTH }}

- name: Update ZIP Image Cache if cache miss
if: steps.cache-docker-zip.outputs.cache-hit != 'true'
run: docker pull joshkeegan/zip:latest && mkdir -p cache-zip && docker image save joshkeegan/zip:latest --output ./cache-zip/zip.tar

- name: Use ZIP Image Cache if cache hit
if: steps.cache-docker-zip.outputs.cache-hit == 'true'
run: docker image load --input ./cache-zip/zip.tar
## <!-- End Cache ZIP Image -->

- name: Run Self-Tests
id: run-self-tests
working-directory: _tests
Expand Down
42 changes: 15 additions & 27 deletions _tests/QITSelfTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ function run_test_runs( array $test_runs ) {
$qit_process = new Process( $args );
$qit_process->setTimeout( null ); // Let QIT CLI handle timeouts.

// echo "[INFO] Preparing to run command {$qit_process->getCommandLine()}\n";

$qit_process->setEnv( [
'QIT_TEST_PATH' => $t['path'],
'QIT_TEST_TYPE' => $test_type,
Expand Down Expand Up @@ -476,31 +474,21 @@ function generate_zips( array $test_type_test_runs ) {

$generated_zips[] = md5( $path . $slug );

if ( getenv( 'CI' ) ) {
// In CI environment, execute the zipping command directly to avoid downloading the zip docker image.
$args = [
'sh',
'-c',
"cd $path && rm -f sut.zip && zip -r sut.zip $slug"
];
} else {
// Use docker zip on local.
$args = [
"docker",
'run',
'--rm',
'--user',
posix_getuid() . ":" . posix_getgid(),
'-w',
'/app',
'-v',
"$path:/app",
'joshkeegan/zip:latest',
'sh',
'-c',
"rm -f sut.zip && zip -r sut.zip $slug",
];
}
$args = [
"docker",
'run',
'--rm',
'--user',
posix_getuid() . ":" . posix_getgid(),
'-w',
'/app',
'-v',
"$path:/app",
'joshkeegan/zip:latest',
'sh',
'-c',
"rm -f sut.zip && zip -r sut.zip $slug",
];


$zip_process = new Symfony\Component\Process\Process( $args );
Expand Down

0 comments on commit fdf817c

Please sign in to comment.