Skip to content

Commit

Permalink
add exit
Browse files Browse the repository at this point in the history
  • Loading branch information
khuezy committed Aug 30, 2023
1 parent f361cd3 commit baad9ea
Showing 1 changed file with 128 additions and 109 deletions.
237 changes: 128 additions & 109 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,132 +20,151 @@ permissions:
contents: read # This is required for actions/checkout

jobs:
e2e:
check_next_version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get Latest Release
id: get_release
- name: Get Latest Next Version
id: get_latest_version
run: |
latest_release=$(curl -s https://api.github.com/repos/vercel/next.js/releases/latest | jq -r '.tag_name')
echo "Latest release: $latest_release"
echo "LATEST_RELEASE=$latest_release" >> $GITHUB_ENV
- name: Download Previous Release Artifact
uses: actions/download-artifact@v3
continue-on-error: true
latest_version=$(curl -s https://api.github.com/repos/vercel/next.js/releases/latest | jq -r '.tag_name')
echo "Latest version: $latest_version"
echo "LATEST_VERSION=$latest_version" >> $GITHUB_ENV
echo "LATEST_VERSION=$latest_version" >> $GITHUB_OUTPUT
- name: Restore Cache Previous Version
id: cache-previous
uses: actions/cache/restore@v3
with:
name: previous-release
path: previous_version.txt
key: ${{ runner.os }}-previous

- name: Compare Releases
id: compare_releases
- name: Compare Versions
id: compare_versions
run: |
latest_release=$LATEST_RELEASE
if [ -f previous_release.txt ]; then
previous_release=$(cat previous_release.txt)
latest_version=$LATEST_VERSION
if [ -f previous_version.txt ]; then
previous_version=$(cat previous_version.txt)
echo "pv: $previous_version"
else
previous_release=""
previous_version=""
fi
echo "$previous_release"
if [ "$latest_release" != "$previous_release" ]; then
echo "Releases are different. Continuing the pipeline."
if [ "$latest_version" != "$previous_version" ]; then
echo "Versions are different. Continuing the pipeline."
else
echo "Releases are the same. Exiting with success."
exit 0
echo "Versions are the same. Exiting with success."
echo "SKIP=true" >> $GITHUB_OUTPUT
fi
- name: Store Latest Release
run: echo "$LATEST_RELEASE" > previous_release.txt
outputs:
skip: ${{ steps.compare_versions.outputs.SKIP }}
previousNextVersion: ${{ steps.get_latest_version.outputs.LATEST_VERSION }}
cacheKey: ${{ steps.cache-previous.outputs.cache-primary-key }}

- name: Upload Previous Release Artifact
uses: actions/upload-artifact@v3
with:
name: previous-release
path: previous_release.txt
e2e:
needs: check_next_version
if: needs.check_next_version.outputs.skip != 'true'
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up NodeJS v18
uses: actions/setup-node@v3
with:
cache: pnpm # cache pnpm store
node-version: 18.16.1

- name: Install packages
run: pnpm install

- name: Get Playwright version
id: playwright-version
run: echo "version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//' | sed 's/ .*//' )"

- name: Cache Playwright
uses: actions/cache@v3
id: playwright-cache
with:
path: "~/.cache/ms-playwright"
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install chromium --with-deps

# Cache turbo runs
- name: Cache Turbo
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
# Build all the packages
- name: Build
run: pnpm run build

# Deploy e2e stage
- name: Deploy NextjsSite
working-directory: examples/sst
run: npx sst deploy --stage e2e

# Load app urls from .sst/output.json file
- name: Set environments
working-directory: examples/sst
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1

# - name: Setup pnpm
# uses: pnpm/action-setup@v2
# with:
# version: 8

# - name: Set up NodeJS v18
# uses: actions/setup-node@v3
# with:
# cache: pnpm # cache pnpm store
# node-version: 18.16.1

# - name: Install packages
# run: pnpm install

# - name: Get Playwright version
# id: playwright-version
# run: echo "version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//' | sed 's/ .*//' )"

# - name: Cache Playwright
# uses: actions/cache@v3
# id: playwright-cache
# with:
# path: "~/.cache/ms-playwright"
# key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
# restore-keys: |
# ${{ runner.os }}-playwright-

# - name: Install Playwright
# if: steps.playwright-cache.outputs.cache-hit != 'true'
# run: pnpm exec playwright install chromium --with-deps

# # Cache turbo runs
# - name: Cache Turbo
# uses: actions/cache@v3
# with:
# path: .turbo
# key: ${{ runner.os }}-turbo-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-turbo-

# # Build all the packages
# - name: Build
# run: pnpm run build

# # Deploy e2e stage
# - name: Deploy NextjsSite
# working-directory: examples/sst
# run: npx sst deploy --stage e2e

# # Load app urls from .sst/output.json file
# - name: Set environments
# working-directory: examples/sst
# run: |
# APP_ROUTER_URL=$(jq -r '.["e2e-example-AppRouter"].url' .sst/outputs.json)
# echo "APP_ROUTER_URL=$APP_ROUTER_URL" >> $GITHUB_ENV
# PAGES_ROUTER_URL=$(jq -r '.["e2e-example-PagesRouter"].url' .sst/outputs.json)
# echo "PAGES_ROUTER_URL=$PAGES_ROUTER_URL" >> $GITHUB_ENV
# APP_PAGES_ROUTER_URL=$(jq -r '.["e2e-example-AppPagesRouter"].url' .sst/outputs.json)
# echo "APP_PAGES_ROUTER_URL=$APP_PAGES_ROUTER_URL" >> $GITHUB_ENV

# - name: Run e2e Test
# run: npm run e2e:test

# - name: Archive
# if: failure()
# uses: actions/upload-artifact@v3
# with:
# name: sst
# path: |
# .sst/
# .next/

- name: debug
run: |
APP_ROUTER_URL=$(jq -r '.["e2e-example-AppRouter"].url' .sst/outputs.json)
echo "APP_ROUTER_URL=$APP_ROUTER_URL" >> $GITHUB_ENV
PAGES_ROUTER_URL=$(jq -r '.["e2e-example-PagesRouter"].url' .sst/outputs.json)
echo "PAGES_ROUTER_URL=$PAGES_ROUTER_URL" >> $GITHUB_ENV
APP_PAGES_ROUTER_URL=$(jq -r '.["e2e-example-AppPagesRouter"].url' .sst/outputs.json)
echo "APP_PAGES_ROUTER_URL=$APP_PAGES_ROUTER_URL" >> $GITHUB_ENV
- name: Run e2e Test
run: npm run e2e:test

echo "cache key: ${{ needs.check_next_version.outputs.cacheKey }}"
echo "version: ${{ needs.check_next_version.outputs.previousNextVersion }}"


- name: Archive
if: failure()
uses: actions/upload-artifact@v3
- name: Store Latest Version
run: |
echo "version: ${{ needs.check_next_version.outputs.previousNextVersion }}"
echo "${{ needs.check_next_version.outputs.previousNextVersion }}" > previous_version.txt
- name: Cache Previous Version
uses: actions/cache/save@v3
with:
name: sst
path: |
.sst/
.next/
path: previous_version.txt
key: ${{ needs.check_next_version.outputs.cacheKey }}

0 comments on commit baad9ea

Please sign in to comment.