Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmontville committed Jan 11, 2024
1 parent 1e35425 commit b7994ad
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/deploy-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Firebase deploy preview / e2e test
on:
pull_request:
# re-run if new commits are added (synchronize)
types: [opened, reopened, synchronize]

# Cancels a workflow process when new commits are made
concurrency:
group: ci-preview-tests-${{ github.ref }}-1
cancel-in-progress: true

jobs:
build_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'

runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3

- name: Install dependencies and Build
run: npm ci && npm run build:dev

- id: firebase_deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GSE_ROAR_ASSESSMENT }}'
projectId: gse-roar-assessment
target: swr
outputs:
deployUrl: ${{ steps.firebase_deploy.outputs.details_url }}

cypress-run:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
matrix:
browser: [chromium, firefox, edge, electron]
containers: [1, 2] # Uses 2 parallel instances
steps:
- name: Set PR Link as Env Variable
run: |
echo "FIREBASE_DEPLOY_URL=${{ steps.firebase_deploy.outputs.deployURL }}" >> $GITHUB_ENV
echo "Captured URL: ${{ steps.firebase_deploy.outputs.deployURL }}"
- uses: actions/checkout@v4
run: npm ci && npm run build

- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: ${{ matrix.browser }}
build: echo "Build step already completed"
start: echo "App already deployed to Firebase"
wait-on: ${{ env.FIREBASE_DEPLOY_URL }}
wait-on-timeout: 60
record: true
parallel: true # Runs test in parallel using settings above
spec: cypress/e2e/participant/checkLegalDoc.cy.js # Runs tests in this folder
ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}
env:
CYPRESS_BASE_URL: ${{ env.FIREBASE_DEPLOY_URL }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = defineConfig({
// ]
},
env: {
baseUrl: 'https://localhost:5173',
baseUrl: process.env.CYPRESS_BASE_URL || 'https://localhost:5173',
timeout: 10000,
sessionCookieName: process.env.SESSION_COOKIE_NAME,
sessionCookieValue: process.env.SESSION_COOKIE_VALUE,
Expand Down

0 comments on commit b7994ad

Please sign in to comment.