playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

[Bug]: Getting error (could not install driver: could not install driver: could not create driver: open /github/home/.cache/ms-playwright-go/1.44.1/node: text file busy\n"}) #469

Closed jackshavryhin closed 1 week ago

jackshavryhin commented 1 week ago

During run tests in -p2 (2 parallel threads), getting error could not install driver: could not install driver: could not create driver: open /github/home/.cache/ms-playwright-go/1.44.1/node: text file busy\n"}

EXAMPLE OF MY TEST: func TestPT_04(t *testing.T) { cnf := config.InitConfig()

err := playwright.Install()
action.HandleBasicError(err)

pw, err := playwright.Run()
action.HandleBasicError(err)

browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
    Headless: playwright.Bool(cnf.Headless),
    Timeout:  playwright.Float(cnf.GeneralTimeout * 1000),
})
action.HandleBasicError(err)

context, err := browser.NewContext(playwright.BrowserNewContextOptions{
    Viewport: &playwright.Size{Width: cnf.DisplayWidth, Height: cnf.DisplayHeight},
})
action.HandleBasicError(err)

page, err := context.NewPage()
page.SetDefaultTimeout(cnf.ActionTimeoutDnD * 1000)
action.HandleBasicError(err)

cookiesChan := make(chan []playwright.Cookie, 1)
user.Login(cnf, page, cookiesChan)
_ = <-cookiesChan

MY YAML FILE:
name: DnD Testing

dnd-e2e-tests: name: DND E2E Tests runs-on: ubuntu-22.04 if: github.event_name != 'workflow_dispatch' container: env: CHANNEL_ID: ${{ secrets.ENGINEERING_CIDS_CHANNEL_ID }} BOT_OAUTH_TOKEN: ${{ secrets.UPLOAD_BOT_OAUTH_TOKEN }}

steps:
  - name: Checkout
    uses: actions/checkout@v4

  - name: Clear Playwright cache
    run: rm -rf ~/.cache/ms-playwright-go/

  - name: Run DND Testing
    id: test
    run: |
      export PATH=$PATH:/usr/local/go/bin
      export GOPATH=/usr/local/go
      export GOROOT=/usr/local/go
      apt update
      apt-get install -y build-essential 
      rm -rf ~/.cache/ms-playwright-go/

      mkdir ./report

      # Run tests
      make test-dnd

      # Check tests result
      if grep -q 'FAIL' ./report/test.out
      then
      exit 1
      fi

      exit 0

  - name: Print report # useful for debuging
    if: ${{ always() }}
    run: |
      cat ./report/test.out

  - name: Remove bad lines # it was causing an error
    if: ${{ always() }}
    run: |
      # removing lines that start not from {
      cat ./report/test.out | grep -E '^{.*' > ./report/test.tmp && mv ./report/test.tmp ./report/test.out

  - name: Upload report
    if: ${{ always() }}
    env:
      CHANNEL_ID: ${{ env.CHANNEL_ID }}
      BOT_OAUTH_TOKEN: ${{ env.BOT_OAUTH_TOKEN }}
    run: |
      export PATH=$PATH:/usr/local/go/bin
      export GOPATH=/usr/local/go
      export GOROOT=/usr/local/go

      # Install all needed to upload report
      go install github.com/Thatooine/go-test-html-report@v1.1.0
      go-test-html-report -f ./report/test.out -o ./report
      apt update
      apt-get install -y curl

      # Check test result
      if [ "${{ steps.test.conclusion }}" = "success" ]; then
        TEST_RESULT="PASSED :white_check_mark:"
      else
        TEST_RESULT="FAILED :warning:"
      fi
      echo "Test result: $TEST_RESULT"

Maybe someone has solution for this.