diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 3c8231586..1cc8390dc 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -5,7 +5,29 @@ on: pull_request: branches: [ master, develop ] jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: npm + cache-dependency-path: package-lock.json + - name: Build Stackable Free Plugin + run: | + npm ci --legacy-peer-deps + npm run build:no-translate + - name: Archive plugin build + run: tar --exclude=./node_modules --exclude=./.git -czf /tmp/stackable-playwright-build.tar.gz . + - uses: actions/upload-artifact@v4 + with: + name: stackable-playwright-build + path: /tmp/stackable-playwright-build.tar.gz + retention-days: 1 + test: + needs: build timeout-minutes: 60 runs-on: ubuntu-latest strategy: @@ -28,6 +50,16 @@ jobs: - uses: actions/setup-node@v4 with: node-version: lts/* + cache: npm + cache-dependency-path: package-lock.json + - name: Restore plugin build + uses: actions/download-artifact@v4 + with: + name: stackable-playwright-build + - name: Extract plugin build + run: tar -xzf stackable-playwright-build.tar.gz + - name: Install dependencies + run: npm ci --legacy-peer-deps - name: Set the version suffix for the output run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV - name: Set WP Version and create .wp-env.json @@ -52,10 +84,6 @@ jobs: }' > .wp-env.json cat .wp-env.json - - name: Build Stackable Free Plugin - run: | - npm ci --legacy-peer-deps - npm run build:no-translate - name: Cache Playwright Browsers uses: actions/cache@v4 with: @@ -72,22 +100,19 @@ jobs: sleep $((attempt * 30)) done exit 1 - - name: Install wp-env - run: | - npm install -g @wordpress/env - name: Start wp-env - run: wp-env start + run: npx @wordpress/env start - name: Print current WP version - run: wp-env run tests-cli wp core version + run: npx @wordpress/env run tests-cli wp core version - name: Create post with existing blocks run: | - POST_ID=$(wp-env run tests-cli wp post create wp-content/plugins/Stackable/e2e/config/post-content.txt --post_title="Existing Blocks" --post_status=publish --porcelain) + POST_ID=$(npx @wordpress/env run tests-cli wp post create wp-content/plugins/Stackable/e2e/config/post-content.txt --post_title="Existing Blocks" --post_status=publish --porcelain) echo "WP_TEST_POSTID=$POST_ID" >> $GITHUB_ENV continue-on-error: true - name: Disable guided tours run: | TOUR_STATES='["design-system", "editor", "design-library", "blocks"]' - wp-env run tests-cli wp option update stackable_guided_tour_states "$TOUR_STATES" --format=json + npx @wordpress/env run tests-cli wp option update stackable_guided_tour_states "$TOUR_STATES" --format=json - name: Run playwright tests id: run-playwright-tests env: