playwright stuff
This commit is contained in:
		
							
								
								
									
										149
									
								
								.github/workflows/playwright.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										149
									
								
								.github/workflows/playwright.yml
									
									
									
									
										vendored
									
									
								
							@ -382,3 +382,152 @@ jobs:
 | 
			
		||||
        path: playwright-report/
 | 
			
		||||
        retention-days: 30
 | 
			
		||||
        overwrite: true
 | 
			
		||||
 | 
			
		||||
  playwright-electron:
 | 
			
		||||
    timeout-minutes: 30
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: check-rust-changes
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Tune GitHub-hosted runner network
 | 
			
		||||
      uses: smorimoto/tune-github-hosted-runner-network@v1
 | 
			
		||||
    - uses: actions/checkout@v4
 | 
			
		||||
    - uses: actions/setup-node@v4
 | 
			
		||||
      with:
 | 
			
		||||
        node-version-file: '.nvmrc'
 | 
			
		||||
        cache: 'yarn'
 | 
			
		||||
    - uses: KittyCAD/action-install-cli@main
 | 
			
		||||
    - name: Install dependencies
 | 
			
		||||
      run: yarn
 | 
			
		||||
    - name: Cache Playwright Browsers
 | 
			
		||||
      uses: actions/cache@v4
 | 
			
		||||
      with:
 | 
			
		||||
        path: |
 | 
			
		||||
          ~/.cache/ms-playwright/
 | 
			
		||||
        key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
 | 
			
		||||
    - name: Install Playwright Browsers
 | 
			
		||||
      run: yarn playwright install chromium --with-deps
 | 
			
		||||
    - name: Download Wasm Cache
 | 
			
		||||
      id: download-wasm
 | 
			
		||||
      if: needs.check-rust-changes.outputs.rust-changed == 'false'
 | 
			
		||||
      uses: dawidd6/action-download-artifact@v6
 | 
			
		||||
      continue-on-error: true
 | 
			
		||||
      with:
 | 
			
		||||
        github_token: ${{secrets.GITHUB_TOKEN}}
 | 
			
		||||
        name: wasm-bundle
 | 
			
		||||
        workflow: build-and-store-wasm.yml
 | 
			
		||||
        branch: main
 | 
			
		||||
        path: src/wasm-lib/pkg
 | 
			
		||||
    - name: copy wasm blob
 | 
			
		||||
      if: needs.check-rust-changes.outputs.rust-changed == 'false'
 | 
			
		||||
      run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
 | 
			
		||||
      continue-on-error: true
 | 
			
		||||
    - name: Setup Rust
 | 
			
		||||
      uses: dtolnay/rust-toolchain@stable
 | 
			
		||||
    - name: Cache Wasm (because rust diff)
 | 
			
		||||
      if: needs.check-rust-changes.outputs.rust-changed == 'true'
 | 
			
		||||
      uses: Swatinem/rust-cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        workspaces: './src/wasm-lib'
 | 
			
		||||
    - name: OR Cache Wasm (because wasm cache failed)
 | 
			
		||||
      if: steps.download-wasm.outcome == 'failure'
 | 
			
		||||
      uses: Swatinem/rust-cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        workspaces: './src/wasm-lib'
 | 
			
		||||
    - name: Install vector
 | 
			
		||||
      run: |
 | 
			
		||||
        curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh
 | 
			
		||||
        chmod +x /tmp/vector.sh
 | 
			
		||||
        /tmp/vector.sh -y -no-modify-path
 | 
			
		||||
        mkdir -p /tmp/vector
 | 
			
		||||
        cp .github/workflows/vector.toml /tmp/vector.toml
 | 
			
		||||
        sed -i "s#GITHUB_WORKFLOW#${GITHUB_WORKFLOW}#g" /tmp/vector.toml
 | 
			
		||||
        sed -i "s#GITHUB_REPOSITORY#${GITHUB_REPOSITORY}#g" /tmp/vector.toml
 | 
			
		||||
        sed -i "s#GITHUB_SHA#${GITHUB_SHA}#g" /tmp/vector.toml
 | 
			
		||||
        sed -i "s#GITHUB_REF_NAME#${GITHUB_REF_NAME}#g" /tmp/vector.toml
 | 
			
		||||
        sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml
 | 
			
		||||
        cat /tmp/vector.toml
 | 
			
		||||
        ${HOME}/.vector/bin/vector --config /tmp/vector.toml &
 | 
			
		||||
    - name: Build Wasm (because rust diff)
 | 
			
		||||
      if: needs.check-rust-changes.outputs.rust-changed == 'true'
 | 
			
		||||
      run: yarn build:wasm
 | 
			
		||||
    - name: OR Build Wasm (because wasm cache failed)
 | 
			
		||||
      if: steps.download-wasm.outcome == 'failure'
 | 
			
		||||
      run: yarn build:wasm
 | 
			
		||||
    - name: build web
 | 
			
		||||
      run: yarn build:local
 | 
			
		||||
    - uses: actions/download-artifact@v4
 | 
			
		||||
      if: always()
 | 
			
		||||
      continue-on-error: true
 | 
			
		||||
      with:
 | 
			
		||||
        name: test-results-ubuntu-${{ github.sha }}
 | 
			
		||||
        path: test-results/
 | 
			
		||||
    - name: run electron
 | 
			
		||||
      run: yarn electron:start &
 | 
			
		||||
    - name: Run ubuntu/chrome flow (with retries)
 | 
			
		||||
      id: retry
 | 
			
		||||
      if: always()
 | 
			
		||||
      run: |
 | 
			
		||||
        if [[ ! -f "test-results/.last-run.json" ]]; then
 | 
			
		||||
            # if no last run artifact, than run plawright normally
 | 
			
		||||
            echo "run playwright normally"
 | 
			
		||||
            yarn playwright test --project="Google Chrome" --grep=@electron || true
 | 
			
		||||
            # # send to axiom
 | 
			
		||||
            node playwrightProcess.mjs | tee /tmp/github-actions.log > /dev/null 2>&1
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        retry=1
 | 
			
		||||
        max_retrys=4
 | 
			
		||||
 | 
			
		||||
        # retry failed tests, doing our own retries because using inbuilt playwright retries causes connection issues
 | 
			
		||||
        while [[ $retry -le $max_retrys ]]; do
 | 
			
		||||
            if [[ -f "test-results/.last-run.json" ]]; then
 | 
			
		||||
                failed_tests=$(jq '.failedTests | length' test-results/.last-run.json)
 | 
			
		||||
                if [[ $failed_tests -gt 0 ]]; then
 | 
			
		||||
                    echo "retried=true" >>$GITHUB_OUTPUT
 | 
			
		||||
                    echo "run playwright with last failed tests and retry $retry"
 | 
			
		||||
                    yarn playwright test --project="Google Chrome" --last-failed --grep=@electron || true
 | 
			
		||||
                    # send to axiom
 | 
			
		||||
                    node playwrightProcess.mjs | tee /tmp/github-actions.log > /dev/null 2>&1
 | 
			
		||||
                    retry=$((retry + 1))
 | 
			
		||||
                else
 | 
			
		||||
                    echo "retried=false" >>$GITHUB_OUTPUT
 | 
			
		||||
                    exit 0
 | 
			
		||||
                fi
 | 
			
		||||
            else
 | 
			
		||||
                echo "retried=false" >>$GITHUB_OUTPUT
 | 
			
		||||
                exit 0
 | 
			
		||||
            fi
 | 
			
		||||
        done
 | 
			
		||||
 | 
			
		||||
        echo "retried=false" >>$GITHUB_OUTPUT
 | 
			
		||||
 | 
			
		||||
        if [[ -f "test-results/.last-run.json" ]]; then
 | 
			
		||||
            failed_tests=$(jq '.failedTests | length' test-results/.last-run.json)
 | 
			
		||||
            if [[ $failed_tests -gt 0 ]]; then
 | 
			
		||||
                # if it still fails after 3 retrys, then fail the job
 | 
			
		||||
                exit 1
 | 
			
		||||
            fi
 | 
			
		||||
        fi
 | 
			
		||||
        exit 0
 | 
			
		||||
      env:
 | 
			
		||||
        CI: true
 | 
			
		||||
        token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
 | 
			
		||||
    - name: send to axiom
 | 
			
		||||
      if: always()
 | 
			
		||||
      shell: bash
 | 
			
		||||
      run: |
 | 
			
		||||
        node playwrightProcess.mjs | tee /tmp/github-actions.log
 | 
			
		||||
    - uses: actions/upload-artifact@v4
 | 
			
		||||
      if: always()
 | 
			
		||||
      with:
 | 
			
		||||
        name: test-results-electron-${{ github.sha }}
 | 
			
		||||
        path: test-results/
 | 
			
		||||
        retention-days: 30
 | 
			
		||||
        overwrite: true
 | 
			
		||||
    - uses: actions/upload-artifact@v4
 | 
			
		||||
      if: always()
 | 
			
		||||
      with:
 | 
			
		||||
        name: playwright-report-electron-${{ github.sha }}
 | 
			
		||||
        path: playwright-report/
 | 
			
		||||
        retention-days: 30
 | 
			
		||||
        overwrite: true
 | 
			
		||||
		Reference in New Issue
	
	Block a user