Updated README #677
This file contains 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: Cypress Local Tests | |
on: | |
pull_request: | |
paths-ignore: | |
- docs/** | |
- '**/*.md' | |
jobs: | |
run-lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.11.0' | |
- name: Install dependencies | |
run: npm ci | |
- name: ESLint | |
run: npx eslint . | |
cypress-component: | |
name: Cypress Run Component Tests on GitHub machine | |
runs-on: ubuntu-latest | |
needs: [ run-lint ] | |
outputs: | |
PR_ID: ${{ steps.save-cypress-outputs.outputs.PR_ID }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.18.0' | |
- name: Write environment variables | |
run: | | |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env | |
echo "" > cypress.config.json | |
- name: Run Component Tests | |
uses: cypress-io/github-action@v6 | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_ACCESS_TOKEN }} | |
with: | |
install: true | |
browser: chrome | |
component: true | |
- name: Save cypress outputs | |
id: save-cypress-outputs | |
run: | | |
echo "PR_ID=$CYPRESS_PULL_REQUEST_ID" >> $GITHUB_OUTPUT | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: component-test-results | |
path: cypress/reports/components/components*.json | |
component-results-report: | |
name: Report component test results | |
runs-on: ubuntu-latest | |
if: always() | |
needs: [ cypress-component ] | |
permissions: | |
pull-requests: write | |
issues: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download test results | |
uses: actions/download-artifact@v3 | |
with: | |
name: component-test-results | |
path: cypress/reports | |
- name: Merge reports to 1 report file | |
run: | | |
npx mochawesome-merge cypress/reports/*.json > cypress/reports/test_results.json | |
- name: Convert report file to markdown | |
run: | | |
npx [email protected] -p cypress/reports/test_results.json -o cypress/reports/test_results.md --reportTitle="Component Test Results" | |
- name: Try to find existing report comment | |
uses: peter-evans/find-comment@v3 | |
id: find-comment | |
env: | |
PR_ID: ${{ needs.cypress-component.outputs.PR_ID || github.event.number }} | |
with: | |
issue-number: ${{ env.PR_ID }} | |
body-includes: Component Test Results | |
- name: Create report and post on PR | |
uses: peter-evans/create-or-update-comment@v3 | |
continue-on-error: true | |
env: | |
PR_ID: ${{ needs.cypress-component.outputs.PR_ID || github.event.number }} | |
with: | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
issue-number: ${{ env.PR_ID }} | |
body-path: cypress/reports/test_results.md | |
edit-mode: replace |