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

[Question] Can I fetch dependacies from a private repo? #569

Closed
khamiltonuk opened this issue Jun 10, 2022 · 6 comments
Closed

[Question] Can I fetch dependacies from a private repo? #569

khamiltonuk opened this issue Jun 10, 2022 · 6 comments

Comments

@khamiltonuk
Copy link

Firstly thank you for your repo

What's the problem
I have supplied my github token and my .npmrc but it I still get 401 Unauthorized when trying to fetch my dependancies

this is my config

name: End-to-end tests
on: [push]
jobs:
  cypress-run:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Cypress install
        uses: cypress-io/github-action@v4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_RC: ${{ secrets.NPM_RC }}
      # Install NPM dependencies, cache them correctly
      # and run all Cypress tests
      - name: Cypress run
        uses: cypress-io/github-action@v4

but this is my output

Run cypress-io/github-action@v4
/usr/local/bin/yarn --frozen-lockfile
yarn install v1.22.18
[1/4] Resolving packages...
warning Resolution field "@babel/[email protected]" is incompatible with requested version "@babel/[email protected]"
warning Resolution field "[email protected]" is incompatible with requested version "[email protected]"
[2/4] Fetching packages...
error An unexpected error occurred: "https://npm.pkg.github.com/download/XXXXXX: Request failed \"401 Unauthorized\"".
info If you think this is a bug, please open a bug report with the information provided in "/home/runner/work/workflow-client/workflow-client/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: The process '/usr/local/bin/yarn' failed with exit code 1
@max-sym
Copy link

max-sym commented Oct 18, 2022

@khamiltonuk did you solve it? Thanks!

@khamiltonuk
Copy link
Author

@max-sym nope, Never managed to solve it, just abandoned it. I will give it another try tomorrow. Perhaps the future version of me is more competent than the past version of me

@n10v
Copy link

n10v commented Dec 16, 2022

It may sound radical, but my solution was to not use cypress github action and do everything manually :D

name: 'E2E Tests'

on:
  pull_request:

jobs:
  E2E:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v3
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          # IMPORTANT: We must not use yarn cache here, otherwise you will get an error with Cypress binary not found
          node-version: '16'
          registry-url: 'https://npm.pkg.github.com'
      - run: yarn install --frozen-lockfile
        env:
          NODE_AUTH_TOKEN: ${{ secrets.YOUR_TOKEN }}
      - name: Build app
        run: yarn build
      - name: Run app in background
        run: yarn start & yarn wait-on http://localhost:8000 --timeout 5000
      - name: Run Cypress tests
        run: yarn cypress run
      - name: Upload screenshots of failed e2e tests
        uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots
      - name: Upload videos of e2e tests
        uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cypress-videos
          path: cypress/videos

@n10v
Copy link

n10v commented Dec 16, 2022

And with cache:

name: 'E2E Tests'

on:
  pull_request:

jobs:
  E2E:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            ~/.cache/Cypress
            node_modules
          key: e2e-cache-${{ hashFiles('yarn.lock') }}
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '16'
          registry-url: 'https://npm.pkg.github.com'
      - run: yarn install --frozen-lockfile
        env:
          NODE_AUTH_TOKEN: ${{ secrets.YOUR_TOKEN }}
      - name: Build app
        run: yarn build
      - name: Run app in background
        run: yarn start & yarn wait-on http://localhost:8000 --timeout 5000
      - name: Run Cypress tests
        run: yarn cypress run
      - name: Upload screenshots of failed e2e tests
        uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots
      - name: Upload videos of e2e tests
        uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cypress-videos
          path: cypress/videos

@CharlieGreenman
Copy link

I was able to solve doing the following:

- name: Checkout
        uses: actions/checkout@v3
      - name: Authenticate with npm registry
        run: |
            echo "//npm.pkg.github.com/:_authToken=${{ secrets.GitHubToken }}" >> ~/.npmrc
      - name: Cypress run

Import piece is make sure it's after checkout so npmrc registered against repo. Also before Cypress Run so repo has it.

@MikeMcC399
Copy link
Collaborator

@khamiltonuk

Was the answer from @CharlieGreenman helpful to you?

Can we close this issue?

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

5 participants