Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync staging with main commits #3033

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ jobs:
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-test-playwright-full:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright-full.yml
needs: permissions-check
secrets: inherit
with:
sha: ${{ github.event.pull_request.head.sha }}
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-deploy:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/deploy.yml
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ jobs:
environment: production
runner-label: ${{ vars.PRODUCTION_RUNNER_LABEL }}

call-test-playwright-full:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright-full.yml
needs: [cache-modifier]
secrets: inherit
with:
sha: ${{ github.sha }}
environment: production
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-deploy:
if: (inputs.force-deploy == true || success()) && !cancelled()
uses: ./.github/workflows/deploy.yml
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
default: true
type: boolean
force-deploy:
description: "Deploy even if tests fail"
required: true
default: false
type: boolean
description: "Deploy even if tests fail"
required: true
default: false
type: boolean

jobs:
cache-modifier:
Expand Down Expand Up @@ -59,8 +59,8 @@ jobs:
sha: ${{ github.sha }}
environment: staging
runner-label: ${{ vars.STAGING_RUNNER_LABEL }}
call-test:

call-test:
uses: ./.github/workflows/test.yml
needs: [cache-modifier, call-test-build]
secrets: inherit
Expand All @@ -70,6 +70,16 @@ jobs:
runner-label: ${{ vars.STAGING_RUNNER_LABEL }}
cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }}

call-test-playwright-full:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright-full.yml
needs: [cache-modifier]
secrets: inherit
with:
sha: ${{ github.sha }}
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-deploy:
if: (inputs.force-deploy == true || success()) && !cancelled()
uses: ./.github/workflows/deploy.yml
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/test-playwright-full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Run playwright tests full e2e
on:
workflow_call:
inputs:
environment:
description: The Github environment to load secrets from
type: string
required: true
sha:
description: The commit SHA to run the tests against
type: string
required: true
runner-label:
description: The label of the runner to use
type: string
cache-modifier:
description: A modifier for the cache key used to bypass existing cache
type: string
required: false
default: ""

jobs:
tests:
name: Run Playwright tests
environment: ${{ inputs.environment }}
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Read node modules from cache
id: cache-nodemodules
uses: actions/cache/restore@v4
env:
cache-name: cache-install-folder
with:
path: |
site/gatsby-site/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ inputs.cache-modifier }}

- name: Install NPM dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
working-directory: site/gatsby-site

- name: start in memory mongodb
run: nohup node -r ts-node/register playwright/memory-mongo.ts &
working-directory: site/gatsby-site
env:
MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/

- name: Wait for memory mongodb to start
run: |
while ! nc -z localhost 4110; do
echo "Waiting for Mongodb memory server to start on port 4110..."
sleep 2
done
echo "MongoDB has started on port 4110."

- name: Build using Netlify
run: netlify build --context preview --offline
working-directory: site/gatsby-site
env:
INSTRUMENT: true
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }}
GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }}
MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/
MONGODB_TRANSLATIONS_CONNECTION_STRING: mongodb://127.0.0.1:4110/
MONGODB_MIGRATIONS_CONNECTION_STRING: mongodb://127.0.0.1:4110/
TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }}
GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }}
GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }}
PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }}
GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
SKIP_PAGE_CREATOR: ${{ vars.SKIP_PAGE_CREATOR }}
CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}
CLOUDFLARE_R2_BUCKET_NAME: ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }}
GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL: ${{ vars.GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL }}
CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }}
GATSBY_COMMIT_SHA: ${{ inputs.sha }}
REALM_API_APP_ID: ${{ vars.REALM_API_APP_ID }}
REALM_API_GROUP_ID: ${{ vars.REALM_API_GROUP_ID }}
REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
REALM_API_PUBLIC_KEY: ${{ secrets.REALM_API_PUBLIC_KEY }}
REALM_API_PRIVATE_KEY: ${{ secrets.REALM_API_PRIVATE_KEY }}
ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
API_MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/

- name: Install playwright browsers
run: npx playwright install --with-deps
working-directory: site/gatsby-site

- name: Run playwright tests
run: npx playwright test playwright/e2e-full/ --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
working-directory: site/gatsby-site
env:
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
IS_EMPTY_ENVIRONMENT: ${{ vars.IS_EMPTY_ENVIRONMENT }}
MONGODB_CONNECTION_STRING: mongodb://127.0.0.1:4110/

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: blob-report-full-${{ matrix.shardIndex }}
path: site/gatsby-site/blob-report/
retention-days: 1

merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
needs: [tests]

runs-on: ubuntu-latest
steps:
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-full-*
merge-multiple: true

- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report-full
retention-days: 7
2 changes: 1 addition & 1 deletion .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
working-directory: site/gatsby-site

- name: Run playwright tests
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: npx playwright test playwright/e2e/ --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
working-directory: site/gatsby-site
env:
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion site/gatsby-site/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
["plugins", "./plugins"],
["@reach/router", "@gatsbyjs/reach-router"]
],
"extensions": [".js", ".jsx"]
"extensions": [".js", ".jsx", ".ts"]
}
}
},
Expand Down
12 changes: 10 additions & 2 deletions site/gatsby-site/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ const config: CodegenConfig = {
overwrite: true,
schema: ["./server/schema.ts"],
require: ['ts-node/register', 'dotenv/config'],
// TODO: documents option should be 'src/**/!(*.d).{ts,tsx,js}' instead so it parses the entire project but as far as I'm aware there is no way to parse some queries while ignoring others (we have to ignore gatsby's queries because they use a different schema)
documents: 'src/graphql/**/!(*.d).{ts,tsx,js}',
pluckConfig: {
globalIdentifier: 'gql',
},
generates: {
"server/generated/graphql.ts": {
plugins: ["typescript", "typescript-resolvers", "typescript-mongodb"]
"server/generated/": {
preset: 'client',
presetConfig: {
gqlTagName: "gql",
}
}
}
};
Expand Down
Loading
Loading