Playwright Tests #933
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright Tests | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| push: | |
| branches: | |
| - main # Trigger on pushes to the main branch | |
| workflow_dispatch: # Allow manual triggering of the workflow | |
| inputs: | |
| environment: | |
| description: 'Select environment' | |
| required: true | |
| type: choice | |
| default: 'obdev5' | |
| options: | |
| - obdev3 | |
| - obdev5 | |
| - stg | |
| pull_request: | |
| branches: | |
| - main # Trigger when a pull request targets the main branch | |
| # Serialize all runs that hit the same shared server. Tests are not safe to run | |
| # in parallel (shared session/inventory), so a new run must wait for the current | |
| # one to finish instead of starting concurrently. | |
| concurrency: | |
| group: playwright-e2e-${{ inputs.environment || 'obdev5' }} | |
| cancel-in-progress: false | |
| jobs: | |
| test: | |
| timeout-minutes: 90 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| pages: write | |
| actions: write # Required to delete the stale github-pages artifact before re-upload | |
| environment: ${{ inputs.environment }} # Assign environment dynamically | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run eslint | |
| run: npm run lint | |
| - name: Install Playwright browsers | |
| run: npx playwright install | |
| - name: Run Playwright tests | |
| env: | |
| APP_BASE_URL: ${{ secrets.APP_BASE_URL }} | |
| CI: true | |
| USER_MAIN_USERNAME: ${{ secrets.USER_MAIN_USERNAME }} | |
| USER_MAIN_PASSWORD: ${{ secrets.USER_MAIN_PASSWORD }} | |
| USER_ALT_USERNAME: ${{ secrets.USER_ALT_USERNAME }} | |
| USER_ALT_PASSWORD: ${{ secrets.USER_ALT_PASSWORD }} | |
| USER_MANAGER_USERNAME: ${{ secrets.USER_MANAGER_USERNAME }} | |
| USER_MANAGER_PASSWORD: ${{ secrets.USER_MANAGER_PASSWORD }} | |
| USER_IMPERSONATOR_USERNAME: ${{ secrets.USER_IMPERSONATOR_USERNAME }} | |
| USER_IMPERSONATOR_PASSWORD: ${{ secrets.USER_IMPERSONATOR_PASSWORD }} | |
| USER_ASSISTANT_USERNAME: ${{ secrets.USER_ASSISTANT_USERNAME }} | |
| USER_ASSISTANT_PASSWORD: ${{ secrets.USER_ASSISTANT_PASSWORD }} | |
| LOCATION_MAIN: ${{ secrets.LOCATION_MAIN }} | |
| LOCATION_NO_MANAGE_INVENOTRY_DEPOT: ${{ secrets.LOCATION_NO_MANAGE_INVENOTRY_DEPOT }} | |
| LOCATION_SUPPLIER: ${{ secrets.LOCATION_SUPPLIER }} | |
| LOCATION_SUPPLIER_ALT: ${{ secrets.LOCATION_SUPPLIER_ALT }} | |
| LOCATION_DEPOT: ${{ secrets.LOCATION_DEPOT }} | |
| LOCATION_WARD: ${{ secrets.LOCATION_WARD }} | |
| LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT: ${{ secrets.LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT }} | |
| LOCATION_INTERNAL: ${{ secrets.LOCATION_INTERNAL }} | |
| LOCATION_INTERNAL_TWO: ${{ secrets.LOCATION_INTERNAL_TWO }} | |
| PRODUCT_ONE: ${{ secrets.PRODUCT_ONE }} | |
| PRODUCT_TWO: ${{ secrets.PRODUCT_TWO }} | |
| PRODUCT_THREE: ${{ secrets.PRODUCT_THREE }} | |
| PRODUCT_FOUR: ${{ secrets.PRODUCT_FOUR }} | |
| PRODUCT_FIVE: ${{ secrets.PRODUCT_FIVE }} | |
| RECEIVING_BIN_PREFIX: ${{ secrets.RECEIVING_BIN_PREFIX != null && secrets.RECEIVING_BIN_PREFIX || 'R-' }} | |
| run: | | |
| echo "Running playwright tests on the ${{ inputs.environment || 'obdev5' }} server" | |
| npx playwright test | |
| - name: Upload Playwright Report to Artifacts | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| - name: Remove stale github-pages artifact | |
| # On a re-run, the previous attempt's "github-pages" artifact still exists, | |
| # which makes deploy-pages fail ("Multiple artifacts named github-pages"). | |
| # Delete it so upload-pages-artifact below produces exactly one. | |
| if: ${{ always() }} | |
| uses: geekyeggo/delete-artifact@v5 | |
| with: | |
| name: github-pages | |
| failOnError: false | |
| - name: Save Pages | |
| if: ${{ always() }} | |
| uses: actions/configure-pages@v2 | |
| - name: Upload artifact | |
| if: ${{ always() }} | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: playwright-report/ | |
| - name: Deploy to Github Pages | |
| if: ${{ always() }} | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |