Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed version of wrangler not being used with v3.7.0 using yarn v1.22.22 in CI #277

Closed
acusti opened this issue Jul 11, 2024 · 1 comment

Comments

@acusti
Copy link
Contributor

acusti commented Jul 11, 2024

i’m very excited for the changes introduced in v3.7.0 to use existing wrangler installation when appropriate (from #271). my app relies on getPlatformProxy so it cannot be deployed with any version of wrangler that doesn’t include that API. however, in my case, the logic to check that existing install and version if somehow falling through to the ⚠️ Wrangler not found or version is incompatible. Installing... fallback logic.

here is my output from the workflow run, which shows that i am using yarn v1.22.22 and shows that /usr/local/bin/yarn wrangler --version, as invoked by wrangler-action, is returning the version number (3.63.2) correctly:

Run cloudflare/wrangler-action@v3.7.0
  with:
    apiToken: ***
    quiet: false
🔍 Checking for existing Wrangler installation
  /usr/local/bin/yarn wrangler --version
  yarn run v1.22.22
  $ /home/runner/work/outlyne/outlyne/node_modules/.bin/wrangler --version
  3.63.2
  Done in 0.57s.
  ⚠️ Wrangler not found or version is incompatible. Installing...
📥 Installing Wrangler
  /usr/local/bin/yarn add wrangler@3.13.2
  yarn add v1.22.22
  [1/5] Validating package.json...
  [2/5] Resolving packages...
  [3/5] Fetching packages...
  [4/5] Linking dependencies...

my hypothesis is that the issue is due to the fallback regex starting with the “start of string” token (/^):

stdout.match(/wrangler (\d+\.\d+\.\d+)/) ?? stdout.match(/^(\d+\.\d+\.\d+)/);

i’m not sure how stdout is derived, but if it includes anything before the version output (e.g. \n3.63.2, or even /home/runner/work/outlyne/outlyne/node_modules/.bin/wrangler --version\n3.63.2), the regex won’t match it.

the most obvious solution, then, is to use multi-line mode so that ^ matches the start of every line as well as the start of the string:

		const versionMatch =
 			stdout.match(/wrangler (\d+\.\d+\.\d+)/) ??
 			stdout.match(/^(\d+\.\d+\.\d+)/);

in case it’s helpful, this is my yaml from the workflow file itself:

    deploy:
        name: 🚀 Deploy
        runs-on: ubuntu-latest
        needs: [lint, typecheck, vitest]
        # only deploy main branch on pushes
        if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}

        steps:
            - name: ⬇️ Checkout repo
              uses: actions/checkout@v4

            - name: ⎔ Setup node
              uses: actions/setup-node@v4
              with:
                  cache: yarn
                  cache-dependency-path: ./yarn.lock
                  node-version: 20

            - name: 📥 Install deps
              run: yarn

            - name: 🚀 Deploy Production
              uses: cloudflare/wrangler-action@v3.7.0
              with:
                  apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
acusti added a commit to acusti/wrangler-action that referenced this issue Jul 11, 2024
@acusti acusti changed the title Install version of wrangler not being used with v3.7.0 Installed version of wrangler not being used with v3.7.0 using yarn v1.22.22 in CI Jul 11, 2024
acusti added a commit to acusti/wrangler-action that referenced this issue Oct 7, 2024
acusti added a commit to acusti/wrangler-action that referenced this issue Oct 7, 2024
@acusti
Copy link
Contributor Author

acusti commented Oct 15, 2024

this is fixed for me as of v3.9.0

@acusti acusti closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant