ci: create pr preview and e2e workflow #5
Workflow file for this run
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: E2E and Preview | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - '[0-9]+.x.x' | |
| pull_request: | |
| branches: | |
| - master | |
| - '[0-9]+.x.x' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.head_ref || github.ref_name || github.event.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NX_CLOUD_DISTRIBUTED_EXECUTION: 'false' | |
| CYPRESS_VERIFY_TIMEOUT: 120000 | |
| PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium | |
| PERCY_SKIP_UPDATE_CHECK: 'true' | |
| PUPPETEER_EXECUTABLE_PATH: /usr/bin/chromium | |
| PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true' | |
| SB_CHROMIUM_PATH: /usr/bin/chromium | |
| jobs: | |
| e2e: | |
| if: ${{ github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| path: 'skyux-icons' | |
| fetch-depth: '0' | |
| token: '${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}' | |
| - name: Checkout skyux | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: 'blackbaud/skyux' | |
| # TODO: change back to main after testing | |
| ref: 'icons-e2e' | |
| path: 'skyux' | |
| token: '${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: 'skyux/.nvmrc' | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: '${{ github.workspace }}/skyux-icons' | |
| - name: Build project | |
| run: npm run build | |
| working-directory: '${{ github.workspace }}/skyux-icons' | |
| - name: Install skyux | |
| run: npm ci | |
| working-directory: '${{ github.workspace }}/skyux' | |
| env: | |
| CYPRESS_INSTALL_BINARY: 0 | |
| - name: Review affected icons | |
| id: affected | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| HAS_RENAMES_OR_DELETES=$(git diff --name-status origin/${{ github.base_ref }} | grep -E '^(D|R)' || echo '') | |
| NOT_JUST_CUSTOM_ICONS=$(git diff --name-only origin/${{ github.base_ref }} | grep -v '^src/svg/' || echo '') | |
| if [ -n "$HAS_RENAMES_OR_DELETES" ] || [ -n "$NOT_JUST_CUSTOM_ICONS" ]; then | |
| # Everything. | |
| AFFECTED="tag:icons-e2e" | |
| else | |
| # Specific icons plus icon-storybook-e2e. | |
| AFFECTED="$((git diff --name-only origin/${{ github.base_ref }} | grep '^src/svg/' || echo '') | xargs basename | sed -E 's~-[0-9]+-[a-z]+.svg$~~' | sort -u | sed 's~^~tag:icon:~' | tr '\n' ,)icon-storybook-e2e" | |
| fi | |
| echo "AFFECTED=$AFFECTED" | |
| echo "affected=${AFFECTED}" >> $GITHUB_OUTPUT | |
| working-directory: '${{ github.workspace }}/skyux-icons' | |
| # TODO: run e2e tests and push to Percy | |
| - name: Build Storybooks with icon changes | |
| run: | | |
| npx nx run-many -t build-storybook --no-dte | |
| echo "::group::Adding skyux-icons.svg to Storybook iframes" | |
| for idx in dist/storybook/*/iframe.html; do | |
| echo "Adding skyux-icons.svg to $idx" | |
| echo >> $idx | |
| cat ../skyux-icons/dist/assets/svg/skyux-icons.svg >> $idx | |
| done | |
| echo "::endgroup::" | |
| working-directory: '${{ github.workspace }}/skyux' | |
| env: | |
| NX_CLOUD_ACCESS_TOKEN: '${{ secrets.NX_CLOUD_ACCESS_TOKEN }}' | |
| - name: Run e2e tests | |
| run: | | |
| npx cypress install | |
| npx nx run-many -t e2e -c prebuilt \ | |
| --projects=${{ steps.affected.outputs.affected }} \ | |
| --no-dte \ | |
| --parallel=1 | |
| working-directory: '${{ github.workspace }}/skyux' | |
| env: | |
| NX_CLOUD_ACCESS_TOKEN: '${{ secrets.NX_CLOUD_ACCESS_TOKEN }}' |