Skip to content

Commit

Permalink
tags script
Browse files Browse the repository at this point in the history
  • Loading branch information
midleman committed Dec 9, 2024
1 parent e3d1fcf commit 99976ca
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 81 deletions.
53 changes: 8 additions & 45 deletions .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jobs:
with:
node-version-file: .nvmrc

# temporary test
- name: Get Playwright Tags
run: bash scripts/playwright-tags.sh "${{ inputs.project }}" "${{ inputs.grep }}"

- name: Cache node_modules, build, extensions, and remote
uses: ./.github/actions/cache-multi-paths

Expand Down Expand Up @@ -101,48 +105,8 @@ jobs:
if: ${{ inputs.project == 'e2e-browser' }}
run: yarn gulp node

- name: Extract Tags from Grep Input
if: ${{ inputs.project == 'e2e-electron' }}
run: |
# Debug initial grep input
echo "Initial grep input: '${{ inputs.grep }}'"
# Check if grep input is empty or undefined
if [[ -z "${{ inputs.grep }}" ]]; then
echo "No grep input provided. Using no tags."
echo "EXTRACTED_TAGS=" >> $GITHUB_ENV
else
# Extract tags from the grep input, ensuring it's not blank
echo "${{ inputs.grep }}" | grep -o "@[^)]*" | tr '\n' ',' | sed 's/,$//' > tags.txt
echo "EXTRACTED_TAGS=$(cat tags.txt)" >> $GITHUB_ENV
fi
# Debug output
echo "Extracted Tags: $EXTRACTED_TAGS"
shell: bash

- name: Extract Tags from Grep Input
if: ${{ inputs.project == 'e2e-browser' }}
run: |
# Debug initial grep input
echo "Initial grep input: '${{ inputs.grep }}'"
# Extract tags from the grep input, excluding @web
tags=$(echo "${{ inputs.grep }}" | grep -o "@[^)]*" | grep -v "@web" || true)
# Ensure @web is included
if [[ -z "$tags" ]]; then
tags="@web"
else
tags="$tags,@web"
fi
# Remove trailing commas and save to an environment variable
echo "EXTRACTED_TAGS=$(echo $tags | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
# Debug output
echo "Extracted Tags: $tags"
shell: bash
- name: Get Playwright Tags
run: bash scripts/playwright-tags.sh "${{ inputs.project}}" "${{ inputs.grep }}"

- name: Run Playwright Tests (Electron)
env:
Expand All @@ -152,10 +116,9 @@ jobs:
CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.run_attempt }}
COMMIT_INFO_MESSAGE: ${{ github.event.head_commit.message }}
PWTEST_BLOB_DO_NOT_REMOVE: 1
CURRENTS_TAG: "electron,${{ env.EXTRACTED_TAGS }}"
id: e2e-playwright-tests
CURRENTS_TAG: ${{ env.PW_TAGS }}
run: |
DISPLAY=:10 npx playwright test --project ${{ inputs.project}} --workers 2 --grep "${{ env.EXTRACTED_TAGS }}" --repeat-each ${{ inputs.repeat_each }}
DISPLAY=:10 npx playwright test --project ${{ inputs.project}} --workers 2 --grep "${{ env.PW_TAGS }}" --repeat-each ${{ inputs.repeat_each }}
- name: Upload Playwright Report to S3
if: ${{ success() || failure() }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/e2e-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
uses: ./.github/workflows/e2e-windows.yml
with:
grep: "@win"
project: "e2e-windows"
display_name: "e2e-windows"
secrets: inherit

Expand Down
43 changes: 8 additions & 35 deletions .github/workflows/e2e-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ on:
description: "Only run tests matching this regex. Supports tags (comma-separated), titles, filenames, etc. For windows, use this format: (?=.*@win)(?=.*@feature)"
default: "@win"
type: string
project:
required: false
description: "The name of the Playwright project to run tests for."
default: "e2e-electron"
type: string
repeat_each:
required: false
description: "Run each test N times, defaults to one."
Expand All @@ -30,14 +25,6 @@ on:
description: "Only run tests matching this regular expression. Can be tags, test titles, filenames, etc. If left blank, all tests will run."
default: "@win"
type: string
project:
required: false
description: "The name of the Playwright project to run tests for."
default: "e2e-electron"
type: choice
options:
- e2e-electron
- e2e-browser
repeat_each:
required: false
description: "Run each test N times, defaults to one."
Expand Down Expand Up @@ -67,6 +54,10 @@ jobs:
with:
node-version-file: .nvmrc

- name: Get Playwright Tags
run: bash scripts/playwright-tags.sh "e2e-windows" "${{ inputs.grep }}"
shell: bash

- name: Install System Level Python
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -137,26 +128,8 @@ jobs:
role-to-assume: ${{ secrets.QA_AWS_RO_ROLE }}
aws-region: ${{ secrets.QA_AWS_REGION }}

- name: Extract Tags from Grep Input
run: |
# Debug initial grep input
echo "Initial grep input: '${{ inputs.grep }}'"
# Extract tags from the grep input, excluding @win
tags=$(echo "${{ inputs.grep }}" | grep -o "@[^)]*" | grep -v "@win" || true)
# Ensure @win is included
if [[ -z "$tags" ]]; then
tags="@win"
else
tags="$tags,@win"
fi
# Remove trailing commas and save to an environment variable
echo "EXTRACTED_TAGS=$(echo $tags | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
# Debug output
echo "Extracted Tags: $tags"
- name: Get Playwright Tags
run: bash scripts/playwright-tags.sh "e2e-windows" "${{ inputs.grep }}"
shell: bash

- name: Run Tests on Windows (Electron)
Expand All @@ -168,9 +141,9 @@ jobs:
CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.run_attempt }}
COMMIT_INFO_MESSAGE: ${{ github.event.head_commit.message }} # only works on push events
PWTEST_BLOB_DO_NOT_REMOVE: 1
CURRENTS_TAG: "electron,@win,${{ env.EXTRACTED_TAGS }}"
CURRENTS_TAG: ${{ env.PW_TAGS }}
if: ${{ !cancelled() }}
run: npx playwright test --project "e2e-windows" --grep "${{ env.EXTRACTED_TAGS }}" --workers 2 --repeat-each ${{ inputs.repeat_each }}
run: npx playwright test --project "e2e-windows" --grep "${{ env.PW_TAGS }}" --workers 2 --repeat-each ${{ inputs.repeat_each }}

- name: Report Test Results
uses: ./.github/actions/e2e-report
Expand Down
53 changes: 53 additions & 0 deletions scripts/playwright-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# Usage:
# bash scripts/playwright-tags.sh <project> <tags>
# Example:
# bash scripts/playwright-tags.sh "browser" "@feat1,@feat2"

# Input parameters
PROJECT="$1" # The PROJECT (e.g., e2e-electron, e2e-browser, e2e-windows)
TAGS="$2" # Comma-separated tags (e.g., "@feat1,@feat2")

# Debug initial inputs
echo "Project: '$PROJECT'"
echo "Tags: '$TAGS'"

# Initialize regex or output
OUTPUT=""

# Determine prefix based on PROJECT
case "$PROJECT" in
"e2e-browser")
OUTPUT="(?=.*@web)"
;;
"e2e-windows")
OUTPUT="(?=.*@win)"
;;
"e2e-electron")
OUTPUT="" # No prefix for linux
# Append @electron tag to linux
if [[ -n "$TAGS" ]]; then
TAGS="@electron,$TAGS"
else
TAGS="@electron"
fi
;;
esac

# Append tags to the output
if [[ -n "$TAGS" ]]; then
# Convert comma-separated tags into regex format for browser/windows
if [[ "$PROJECT" == "e2e-browser" || "$PROJECT" == "e2e-windows" ]]; then
TAGS_REGEX=$(echo "$TAGS" | tr ',' '\n' | sed 's/^/(?=.*&/' | sed 's/$/)/' | tr -d '\n')
OUTPUT="$OUTPUT$TAGS_REGEX"
else
# Just append tags as-is for linux
OUTPUT="$TAGS"
fi
fi

# Output the final string
echo "$OUTPUT"

# Save to GITHUB_ENV
echo "PW_TAGS=$OUTPUT" >> $GITHUB_ENV

0 comments on commit 99976ca

Please sign in to comment.