Skip to content

Commit

Permalink
fix(e2e): fix the e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanAyaz committed Oct 10, 2024
1 parent db10d3c commit b14022b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 50 deletions.
94 changes: 45 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ permissions:
id-token: write

jobs:
setup:
runs-on: ubuntu-20.04
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -21,54 +21,51 @@ jobs:
with:
node-version: 20
cache: 'npm'
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
- name: Get Date
id: get-date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v4
id: cache
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm ci --legacy-peer-deps
- uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}

main:
needs: setup
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-
${{ runner.os }}-node-
- name: Install Dependencies
run: npm ci --legacy-peer-deps
- uses: nrwl/nx-set-shas@v4
- run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
- run: npx nx affected -t lint test build
- uses: actions/cache/save@v4
if: always()
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/package-lock.json') }}

deploy:
needs: main
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v3
cache: 'npm'
- uses: actions/cache/restore@v4
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/package-lock.json') }}
- name: Install Dependencies
run: npm ci --legacy-peer-deps
- name: Build the app
run: npx nx build demo-app --baseHref "/ng-gc-ws/"
- name: Setup Pages
Expand All @@ -83,24 +80,23 @@ jobs:

e2e:
needs: [deploy]
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v3
cache: 'npm'
- uses: actions/cache/restore@v4
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install Playwright browsers and dependencies
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/package-lock.json') }}
- name: Install Dependencies
run: npm ci --legacy-peer-deps
- name: Install Playwright
run: npx playwright install --with-deps
- name: Install additional WebKit dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libnotify4 libxslt1.1 libevent-2.1-7 libgles2 libvpx6 libxcomposite1 libatk1.0-0 libatk-bridge2.0-0 libepoxy0 libgtk-3-0 libharfbuzz-icu0
sudo apt-get install -y libgstreamer-gl1.0-0 libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-good gstreamer1.0-libav
- name: Run e2e tests against deployed app
- name: Run e2e tests
run: CI=true && npx nx e2e demo-app-e2e
2 changes: 1 addition & 1 deletion apps/demo-app-e2e/src/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ test('has title', async ({ page }) => {

// Expect h1 to contain a substring.
expect(await page.locator('header nav').innerText()).toContain(
'Angular Gemini Demo App'
'Sentiment Analyzer with Google Gemini & Angular'
);
});

0 comments on commit b14022b

Please sign in to comment.