WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.24k stars 4.09k forks source link

[Env Package]: permalink structure update via wp cli #50538

Open shashwatahalder01 opened 1 year ago

shashwatahalder01 commented 1 year ago

Description

Tried to update the permalink from plain to pretty using wp cli. Still getting errors on git action Linux environment. CLI commands don't work on both env: development and test

The issue should be fixed by this PR. Is the issue still exist or I am doing something wrong?

Git Action:

name: End-to-End Tests

on:
  pull_request:
  push:
    branches:
      - e2e
concurrency:
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
  cancel-in-progress: true

jobs:
  tests:
    name: e2e tests
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v3
        with:
         ref: "e2e"

      - name: Use desired version of NodeJS
        uses: actions/setup-node@v3
        with:
          node-version: '14'
          cache: "npm"

      - name: Install dependencies  & start wp env
        run: |
          cd tests/e2e 
          npm ci 
          npm run wp-env start       

      - name: Set Permalink structure
        run: |
          cd tests/e2e 
          npm run wp-env run cli 'wp rewrite structure /%postname%/'  --hard 
          curl http://localhost:8888/wp-json/wp/v2

.wp-env.json:

{
      "core": null,
      "phpVersion": "7.4",
      "plugins": [
        "https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip"
      ],
      "themes": [
        "https://downloads.wordpress.org/theme/storefront.latest-stable.zip"
      ]
}

Step-by-step reproduction instructions

  1. start wp-env on git action
  2. try to update permalink using cli

Screenshots, screen recording, code snippet

Screenshot at May 11 16-01-22

Environment info

"@wordpress/env": "^7.0.0"

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

github-actions[bot] commented 1 year ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

swissspidy commented 1 year ago

See https://github.com/WordPress/gutenberg/pull/49962#issuecomment-1557513752

One needs to add a custom wp-cli.yml file telling WP-CLI that mod_rewrite is available. Then the .htaccess file seems to be created reliably, at least on my local computer.

Strangely, I didn't get those warnings on GitHub Actions myself.

Perhaps you could give it a try?

If it works, IMHO wp-env could potentially set up this file by default to make everyone's lives easier.

github-actions[bot] commented 1 year ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

jordesign commented 10 months ago

Hi @shashwatahalder01 - were you able to try out the suggestion mentioned in the previous comment?

shashwatahalder01 commented 10 months ago

@jordesign - I tried the suggested soln. and it worked just fine. However, for my project, I kept a .htacess file in my repo and mapped that file in the .wp-env file. I agree with @swissspidy that wp-env should set up this file by default to make everyone's lives easier.