From d19eaae5b6dd7ac88f8958b7670c6d5ac9698b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Tue, 28 Feb 2023 03:41:55 -0700 Subject: [PATCH 1/6] Solves Github actions caching issues (#7431) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create env file workflow * Add env-cache * Fix env setter * Fix * Another fix * Fix * Fix * Fixes * FFS * Fix * Fix * Fix * Fix * Fix * Cache fixes * Fixes * Adds skipping steps * db-cache fixes * Test * Cache fixes * e2e * Possible caching conflicts * Running out of ideas * Caching is hard * One more time * cache-build not skipping * Fingers crossed * a * Test * Pls * Please * LFG * Build fix * fix * Whitespace!! * Zomars/cal 884 paid events not sending the link (#7318) * WIP * Sends correct emails for paid bookings * Update PaymentService.ts * Update webhook.ts * Update webhook.ts * Update settings back button redirect link (#7403) * fix(schedule): close on click #7143 * fix(EventSetupTab): validLocations length will always match validLocations length #7138 * fix(SettingsLayout): go back to right route #7379 * feat: get country code from ip geolocation (#6880) * feat: get coutnry code from ip geolocation Signed-off-by: Udit Takkar * fix: create new api route for fetching code Signed-off-by: Udit Takkar * chore: replace city with country Signed-off-by: Udit Takkar * refactor: create hook for country Signed-off-by: Udit Takkar --------- Signed-off-by: Udit Takkar * Team Workflows (#7038) Co-authored-by: Hariom Balhara Co-authored-by: CarinaWolli Co-authored-by: zomars Co-authored-by: Peer Richelsen * Add destination calendar name to DestinationCalendarSelector (#6701) * Add destination calendar name * Type fix * Search through calendars only for destination calendar credential * Refactor get connected calendars * Clean up --------- Co-authored-by: zomars * Update viewer.tsx (#7428) * Fix - add team members to emails (#7207) * On booking add team members & translation * Add team members to round robin create * Only update calendars on reschedule if there is a calendar reference * Send email on reschedules * Send team email on cancelled event * Add team members to calendar event description * Clean up * Convert other emails to organizer & teams * Type check fixes * More type fixes * Change organizer scheduled input to an object * early return updateCalendarEvent * Introduce team member type * Fix type errors * Put team members before attendees * Remove lodash cloneDeep * Update packages/core/EventManager.ts Co-authored-by: Omar López * Remove booking select object * Revert "Remove booking select object" This reverts commit 9f121ff4ebbaec9a0643111f96c5337b930ddd5b. * Refactor email manager (#7270) Co-authored-by: zomars * Type change * Remove conditional check for updateAllCalendarEvents --------- Co-authored-by: zomars * Typefix * Updates webhook response * Update pr.yml --------- Signed-off-by: Udit Takkar Co-authored-by: Esaú Morais <55207584+esau-morais@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Hariom Balhara Co-authored-by: CarinaWolli Co-authored-by: Peer Richelsen Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> --- .github/actions/cache-build/action.yml | 22 +++-- .github/actions/cache-db/action.yml | 13 ++- .github/actions/env-read-file/action.yml | 23 +++++ .github/actions/yarn-build/action.yml | 105 ----------------------- .github/actions/yarn-install/action.yml | 12 +-- .github/workflows/e2e-app-store.yml | 34 +------- .github/workflows/e2e-embed.yml | 38 +------- .github/workflows/e2e.yml | 51 ++--------- .github/workflows/env-create-file.yml | 49 +++++++++++ .github/workflows/pr.yml | 9 +- .github/workflows/production-build.yml | 64 +------------- gh.env | 1 + 12 files changed, 120 insertions(+), 301 deletions(-) create mode 100644 .github/actions/env-read-file/action.yml delete mode 100644 .github/actions/yarn-build/action.yml create mode 100644 .github/workflows/env-create-file.yml create mode 100644 gh.env diff --git a/.github/actions/cache-build/action.yml b/.github/actions/cache-build/action.yml index 2fdb11ed27..2899075b14 100644 --- a/.github/actions/cache-build/action.yml +++ b/.github/actions/cache-build/action.yml @@ -1,22 +1,26 @@ name: Cache production build binaries description: "Cache or restore if necessary" -env: - node_version: v16.x +inputs: + node_version: + required: false + default: v16.x runs: using: "composite" steps: - name: Cache production build uses: actions/cache@v3 + id: cache-build env: cache-name: prod-build - key-1: ${{ env.node_version }}-${{ hashFiles('yarn.lock') }} - key-2: ${{ hashFiles('apps/web/next.config.js') }} - key-3: ${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + key-1: ${{ inputs.node_version }}-${{ hashFiles('yarn.lock') }} + key-2: ${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + key-3: ${{ github.event.pull_request.number || github.ref }} with: path: | - ${{ github.workspace }}/apps/web/.next/cache + ${{ github.workspace }}/apps/web/.next **/.turbo/** **/dist/** - key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}- + key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }} + - run: yarn build + if: steps.cache-build.outputs.cache-hit != 'true' + shell: bash diff --git a/.github/actions/cache-db/action.yml b/.github/actions/cache-db/action.yml index 27fd0519cc..93fc9ebd2f 100644 --- a/.github/actions/cache-db/action.yml +++ b/.github/actions/cache-db/action.yml @@ -2,7 +2,8 @@ name: Cache database between jobs description: "Cache or restore if necessary" inputs: DATABASE_URL: - required: true + required: false + default: "postgresql://postgres:@localhost:5432/calendso" path: required: false default: "backups/backup.sql" @@ -14,11 +15,15 @@ runs: uses: actions/cache@v3 env: cache-name: cache-db + key-1: ${{ hashFiles('packages/prisma/schema.prisma','packages/prisma/migrations/**.sql','packages/prisma/*.ts') }} with: path: ${{ inputs.path }} - key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ github.sha }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ github.sha }} + - run: yarn db-seed + if: steps.cache-db.outputs.cache-hit != 'true' + shell: bash - name: Postgres Dump Backup if: steps.cache-db.outputs.cache-hit != 'true' uses: tj-actions/pg-dump@v2.3 diff --git a/.github/actions/env-read-file/action.yml b/.github/actions/env-read-file/action.yml new file mode 100644 index 0000000000..78d3ce75da --- /dev/null +++ b/.github/actions/env-read-file/action.yml @@ -0,0 +1,23 @@ +name: "Set environment variables" +description: "Configures environment variables for a workflow" +runs: + using: "composite" + steps: + - name: Create env file + uses: actions/cache@v3 + id: env-cache + with: + path: gh.env + key: env-cache-${{ hashFiles('gh.env') }} + restore-keys: env-cache- + - name: Set Environment Variables + if: steps.env-cache.outputs.cache-hit == 'true' + uses: tw3lveparsecs/github-actions-setvars@latest + with: + envFilePath: gh.env + - name: Set Environment Variables + if: steps.env-cache.outputs.cache-hit != 'true' + shell: bash + run: | + echo "You need to run env-create-file first" + exit 1 diff --git a/.github/actions/yarn-build/action.yml b/.github/actions/yarn-build/action.yml deleted file mode 100644 index a9a2d2b114..0000000000 --- a/.github/actions/yarn-build/action.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: Production Build -description: "Creates a production build, caches it and restores if necessary" -inputs: - DATABASE_URL: - required: true - NEXT_PUBLIC_WEBAPP_URL: - required: true - NEXT_PUBLIC_WEBSITE_URL: - required: true - NEXTAUTH_SECRET: - required: true - GOOGLE_API_CREDENTIALS: - required: true - GOOGLE_LOGIN_ENABLED: - required: true - CRON_API_KEY: - required: false - CALENDSO_ENCRYPTION_KEY: - required: true - DAILY_API_KEY: - required: true - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: - required: true - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: - required: true - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: - required: true - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: - required: true - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: - required: true - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: - required: true - STRIPE_PRIVATE_KEY: - required: true - STRIPE_CLIENT_ID: - required: true - STRIPE_WEBHOOK_SECRET: - required: true - STRIPE_PRO_PLAN_PRODUCT_ID: - required: true - STRIPE_PREMIUM_PLAN_PRODUCT_ID: - required: true - STRIPE_FREE_PLAN_PRODUCT_ID: - required: true - PAYMENT_FEE_PERCENTAGE: - required: true - PAYMENT_FEE_FIXED: - required: true - SAML_DATABASE_URL: - required: true - SAML_ADMINS: - required: true - NEXTAUTH_URL: - required: true - NEXT_PUBLIC_IS_E2E: - required: true - TURBO_TOKEN: - required: true - TURBO_TEAM: - required: true - -runs: - using: "composite" - env: - DATABASE_URL: ${{ inputs.DATABASE_URL }} - NEXT_PUBLIC_WEBAPP_URL: ${{ inputs.NEXT_PUBLIC_WEBAPP_URL }} - NEXT_PUBLIC_WEBSITE_URL: ${{ inputs.NEXT_PUBLIC_WEBSITE_URL }} - NEXTAUTH_SECRET: ${{ inputs.NEXTAUTH_SECRET }} - GOOGLE_API_CREDENTIALS: ${{ inputs.GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: ${{ inputs.GOOGLE_LOGIN_ENABLED }} - CALENDSO_ENCRYPTION_KEY: ${{ inputs.CALENDSO_ENCRYPTION_KEY }} - DAILY_API_KEY: ${{ inputs.DAILY_API_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ inputs.NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: ${{ inputs.NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: ${{ inputs.NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: ${{ inputs.NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: ${{ inputs.NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE }} - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: ${{ inputs.NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN }} - STRIPE_PRIVATE_KEY: ${{ inputs.STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ inputs.STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ inputs.STRIPE_WEBHOOK_SECRET }} - STRIPE_PRO_PLAN_PRODUCT_ID: ${{ inputs.STRIPE_PRO_PLAN_PRODUCT_ID }} - STRIPE_PREMIUM_PLAN_PRODUCT_ID: ${{ inputs.STRIPE_PREMIUM_PLAN_PRODUCT_ID }} - STRIPE_FREE_PLAN_PRODUCT_ID: ${{ inputs.STRIPE_FREE_PLAN_PRODUCT_ID }} - PAYMENT_FEE_PERCENTAGE: ${{ inputs.PAYMENT_FEE_PERCENTAGE }} - PAYMENT_FEE_FIXED: ${{ inputs.PAYMENT_FEE_FIXED }} - SAML_DATABASE_URL: ${{ inputs.SAML_DATABASE_URL }} - SAML_ADMINS: ${{ inputs.SAML_ADMINS }} - NEXTAUTH_URL: ${{ inputs.NEXTAUTH_URL }} - steps: - - uses: ./.github/actions/cache-db - id: cache-db - with: - DATABASE_URL: ${{ env.DATABASE_URL }} - - uses: ./.github/actions/cache-build - id: prod-build-cache - - name: Next.js production build - if: steps.cache-db.outputs.cache-hit != 'true' - shell: bash - run: yarn db-seed - - name: Prisma DB seed - if: steps.prod-build-cache.outputs.cache-hit != 'true' - shell: bash - run: yarn build diff --git a/.github/actions/yarn-install/action.yml b/.github/actions/yarn-install/action.yml index 0d04c529f0..0a9be1454b 100644 --- a/.github/actions/yarn-install/action.yml +++ b/.github/actions/yarn-install/action.yml @@ -1,21 +1,23 @@ name: Yarn install description: "Install all NPM dependencies, caches them and restores if necessary" -env: - node_version: v16.x +inputs: + node_version: + required: false + default: v16.x runs: using: "composite" steps: - - name: Use Node ${{ env.node_version }} + - name: Use Node ${{ inputs.node_version }} uses: actions/setup-node@v3 with: - node-version: ${{ env.node_version }} + node-version: ${{ inputs.node_version }} cache: "yarn" - name: node_modules cache id: node-modules-cache uses: actions/cache@v3 env: cache-name: node-modules-yarn - cache-key: ${{ env.node_version }}-${{ hashFiles('yarn.lock', 'packages/prisma/schema.prisma') }} + cache-key: ${{ inputs.node_version }}-${{ hashFiles('yarn.lock', 'packages/prisma/schema.prisma') }} with: path: | **/node_modules/** diff --git a/.github/workflows/e2e-app-store.yml b/.github/workflows/e2e-app-store.yml index 71c3585862..e3d883bb9e 100644 --- a/.github/workflows/e2e-app-store.yml +++ b/.github/workflows/e2e-app-store.yml @@ -7,37 +7,6 @@ jobs: timeout-minutes: 20 name: E2E App-Store Apps runs-on: ubuntu-latest - - env: - DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000 - NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000 - NEXTAUTH_SECRET: secret - GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: true - # CRON_API_KEY: xxx - CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }} - PAYMENT_FEE_PERCENTAGE: 0.005 - PAYMENT_FEE_FIXED: 10 - SAML_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - SAML_ADMINS: pro@example.com - NEXTAUTH_URL: http://localhost:3000/api/auth - NEXT_PUBLIC_IS_E2E: 1 - # EMAIL_FROM: e2e@cal.com - # EMAIL_SERVER_HOST: ${{ secrets.CI_EMAIL_SERVER_HOST }} - # EMAIL_SERVER_PORT: ${{ secrets.CI_EMAIL_SERVER_PORT }} - # EMAIL_SERVER_USER: ${{ secrets.CI_EMAIL_SERVER_USER }} - # EMAIL_SERVER_PASSWORD: ${{ secrets.CI_EMAIL_SERVER_PASSWORD }} - # MS_GRAPH_CLIENT_ID: xxx - # MS_GRAPH_CLIENT_SECRET: xxx - # ZOOM_CLIENT_ID: xxx - # ZOOM_CLIENT_SECRET: xxx - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} services: postgres: image: postgres:12.1 @@ -54,8 +23,7 @@ jobs: - uses: ./.github/actions/yarn-install - uses: ./.github/actions/yarn-playwright-install - uses: ./.github/actions/cache-db - with: - DATABASE_URL: ${{ env.DATABASE_URL }} + - uses: ./.github/actions/env-read-file - uses: ./.github/actions/cache-build - name: Run Tests run: yarn test-e2e:app-store diff --git a/.github/workflows/e2e-embed.yml b/.github/workflows/e2e-embed.yml index 9fa784441d..db1f6707aa 100644 --- a/.github/workflows/e2e-embed.yml +++ b/.github/workflows/e2e-embed.yml @@ -6,41 +6,6 @@ jobs: e2e-embed: timeout-minutes: 20 runs-on: ubuntu-latest - env: - DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000 - NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000 - NEXTAUTH_SECRET: secret - GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: true - # CRON_API_KEY: xxx - CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: ${{ secrets.NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE }} - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: 1 - STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }} - PAYMENT_FEE_PERCENTAGE: 0.005 - PAYMENT_FEE_FIXED: 10 - SAML_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - SAML_ADMINS: pro@example.com - NEXTAUTH_URL: http://localhost:3000/api/auth - NEXT_PUBLIC_IS_E2E: 1 - # EMAIL_FROM: e2e@cal.com - # EMAIL_SERVER_HOST: ${{ secrets.CI_EMAIL_SERVER_HOST }} - # EMAIL_SERVER_PORT: ${{ secrets.CI_EMAIL_SERVER_PORT }} - # EMAIL_SERVER_USER: ${{ secrets.CI_EMAIL_SERVER_USER }} - # EMAIL_SERVER_PASSWORD: ${{ secrets.CI_EMAIL_SERVER_PASSWORD }} - # MS_GRAPH_CLIENT_ID: xxx - # MS_GRAPH_CLIENT_SECRET: xxx - # ZOOM_CLIENT_ID: xxx - # ZOOM_CLIENT_SECRET: xxx - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} services: postgres: image: postgres:12.1 @@ -57,8 +22,7 @@ jobs: - uses: ./.github/actions/yarn-install - uses: ./.github/actions/yarn-playwright-install - uses: ./.github/actions/cache-db - with: - DATABASE_URL: ${{ env.DATABASE_URL }} + - uses: ./.github/actions/env-read-file - uses: ./.github/actions/cache-build - name: Run Tests run: yarn turbo run embed-tests-update-snapshots:ci --scope=@calcom/embed-react --concurrency=1 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f1fa8cb5f0..c77054f275 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -4,46 +4,8 @@ on: jobs: e2e: timeout-minutes: 20 - runs-on: buildjet-4vcpu-ubuntu-2204 - env: - DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000 - NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000 - NEXTAUTH_SECRET: secret - GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: true - # CRON_API_KEY: xxx - CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }} - DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: ${{ secrets.NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE }} - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: 1 - STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }} - STRIPE_PRO_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_PRO_PLAN_PRODUCT_ID }} - STRIPE_PREMIUM_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_PREMIUM_PLAN_PRODUCT_ID }} - STRIPE_FREE_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_FREE_PLAN_PRODUCT_ID }} - PAYMENT_FEE_PERCENTAGE: 0.005 - PAYMENT_FEE_FIXED: 10 - SAML_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - SAML_ADMINS: pro@example.com - NEXTAUTH_URL: http://localhost:3000/api/auth - NEXT_PUBLIC_IS_E2E: 1 - # EMAIL_FROM: e2e@cal.com - # EMAIL_SERVER_HOST: ${{ secrets.CI_EMAIL_SERVER_HOST }} - # EMAIL_SERVER_PORT: ${{ secrets.CI_EMAIL_SERVER_PORT }} - # EMAIL_SERVER_USER: ${{ secrets.CI_EMAIL_SERVER_USER }} - # EMAIL_SERVER_PASSWORD: ${{ secrets.CI_EMAIL_SERVER_PASSWORD }} - # MS_GRAPH_CLIENT_ID: xxx - # MS_GRAPH_CLIENT_SECRET: xxx - # ZOOM_CLIENT_ID: xxx - # ZOOM_CLIENT_SECRET: xxx - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + name: E2E tests + runs-on: ubuntu-latest services: postgres: image: postgres:12.1 @@ -52,7 +14,6 @@ jobs: POSTGRES_DB: calendso ports: - 5432:5432 - steps: - uses: actions/checkout@v3 - uses: ./.github/actions/dangerous-git-checkout @@ -60,11 +21,11 @@ jobs: - uses: ./.github/actions/yarn-install - uses: ./.github/actions/yarn-playwright-install - uses: ./.github/actions/cache-db - with: - DATABASE_URL: ${{ env.DATABASE_URL }} + - uses: ./.github/actions/env-read-file - uses: ./.github/actions/cache-build - - run: yarn test-e2e - - name: Upload test results + - name: Run Tests + run: yarn test-e2e + - name: Upload Test Results if: ${{ always() }} uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/env-create-file.yml b/.github/workflows/env-create-file.yml new file mode 100644 index 0000000000..7b3f084303 --- /dev/null +++ b/.github/workflows/env-create-file.yml @@ -0,0 +1,49 @@ +name: Create .env file + +on: + workflow_call: + +env: + INPUT_ENV_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso + INPUT_ENV_NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000 + INPUT_ENV_NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000 + INPUT_ENV_NEXTAUTH_SECRET: secret + INPUT_ENV_GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }} + INPUT_ENV_GOOGLE_LOGIN_ENABLED: true + # INPUT_ENV_CRON_API_KEY: xxx + INPUT_ENV_CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }} + INPUT_ENV_NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} + INPUT_ENV_STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }} + INPUT_ENV_STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }} + INPUT_ENV_STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }} + INPUT_ENV_PAYMENT_FEE_PERCENTAGE: 0.005 + INPUT_ENV_PAYMENT_FEE_FIXED: 10 + INPUT_ENV_SAML_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso + INPUT_ENV_SAML_ADMINS: pro@example.com + INPUT_ENV_NEXTAUTH_URL: http://localhost:3000/api/auth + INPUT_ENV_NEXT_PUBLIC_IS_E2E: 1 + # INPUT_ENV_EMAIL_FROM: e2e@cal.com + # INPUT_ENV_EMAIL_SERVER_HOST: ${{ secrets.CI_EMAIL_SERVER_HOST }} + # INPUT_ENV_EMAIL_SERVER_PORT: ${{ secrets.CI_EMAIL_SERVER_PORT }} + # INPUT_ENV_EMAIL_SERVER_USER: ${{ secrets.CI_EMAIL_SERVER_USER }} + # INPUT_ENV_EMAIL_SERVER_PASSWORD: ${{ secrets.CI_EMAIL_SERVER_PASSWORD }} + # INPUT_ENV_MS_GRAPH_CLIENT_ID: xxx + # INPUT_ENV_MS_GRAPH_CLIENT_SECRET: xxx + # INPUT_ENV_ZOOM_CLIENT_ID: xxx + # INPUT_ENV_ZOOM_CLIENT_SECRET: xxx + INPUT_ENV_TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + INPUT_ENV_TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + +jobs: + create_env_file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ozaytsev86/create-env-file@v1 + with: + file-name: ${{ github.workspace }}/gh.env + - uses: actions/cache@v3 + id: env-cache + with: + path: gh.env + key: env-cache-${{ hashFiles('gh.env') }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 92fdc7e71f..e306a557eb 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,6 +32,11 @@ jobs: - 'apps/web/**' - 'packages/embeds/**' + env: + name: Create env file + uses: ./.github/workflows/env-create-file.yml + secrets: inherit + setup: name: Yarn install & cache uses: ./.github/workflows/yarn-install.yml @@ -57,13 +62,13 @@ jobs: build: name: Production build - needs: setup + needs: [setup, env] uses: ./.github/workflows/production-build.yml secrets: inherit e2e: name: E2E tests - needs: [lint, build] + needs: [changes, lint, build] uses: ./.github/workflows/e2e.yml secrets: inherit diff --git a/.github/workflows/production-build.yml b/.github/workflows/production-build.yml index 4a575ab465..5b90ba7bde 100644 --- a/.github/workflows/production-build.yml +++ b/.github/workflows/production-build.yml @@ -3,36 +3,6 @@ name: Production Build on: workflow_call: -env: - DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000 - NEXT_PUBLIC_WEBSITE_URL: http://localhost:3000 - NEXTAUTH_SECRET: secret - GOOGLE_API_CREDENTIALS: ${{ secrets.CI_GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: true - # CRON_API_KEY: xxx - CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }} - DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: ${{ secrets.CI_NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: ${{ secrets.NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE }} - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: 1 - STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }} - STRIPE_PRO_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_PRO_PLAN_PRODUCT_ID }} - STRIPE_PREMIUM_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_PREMIUM_PLAN_PRODUCT_ID }} - STRIPE_FREE_PLAN_PRODUCT_ID: ${{ secrets.CI_STRIPE_FREE_PLAN_PRODUCT_ID }} - PAYMENT_FEE_PERCENTAGE: 0.005 - PAYMENT_FEE_FIXED: 10 - SAML_DATABASE_URL: postgresql://postgres:@localhost:5432/calendso - SAML_ADMINS: pro@example.com - NEXTAUTH_URL: http://localhost:3000/api/auth - NEXT_PUBLIC_IS_E2E: 1 - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} jobs: build: name: Build @@ -49,34 +19,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/actions/yarn-install - - uses: ./.github/actions/yarn-build - with: - # GitHub Composite actions cannot read secrets, we have to pass them in here - DATABASE_URL: ${{ env.DATABASE_URL }} - NEXT_PUBLIC_WEBAPP_URL: ${{ env.NEXT_PUBLIC_WEBAPP_URL }} - NEXT_PUBLIC_WEBSITE_URL: ${{ env.NEXT_PUBLIC_WEBSITE_URL }} - NEXTAUTH_SECRET: ${{ env.NEXTAUTH_SECRET }} - GOOGLE_API_CREDENTIALS: ${{ env.GOOGLE_API_CREDENTIALS }} - GOOGLE_LOGIN_ENABLED: ${{ env.GOOGLE_LOGIN_ENABLED }} - CALENDSO_ENCRYPTION_KEY: ${{ env.CALENDSO_ENCRYPTION_KEY }} - DAILY_API_KEY: ${{ env.DAILY_API_KEY }} - NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${{ env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY }} - NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE: ${{ env.NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE: ${{ env.NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE: ${{ env.NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE }} - NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE: ${{ env.NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE }} - NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN: ${{ env.NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN }} - STRIPE_PRIVATE_KEY: ${{ env.STRIPE_PRIVATE_KEY }} - STRIPE_CLIENT_ID: ${{ env.STRIPE_CLIENT_ID }} - STRIPE_WEBHOOK_SECRET: ${{ env.STRIPE_WEBHOOK_SECRET }} - STRIPE_PRO_PLAN_PRODUCT_ID: ${{ env.STRIPE_PRO_PLAN_PRODUCT_ID }} - STRIPE_PREMIUM_PLAN_PRODUCT_ID: ${{ env.STRIPE_PREMIUM_PLAN_PRODUCT_ID }} - STRIPE_FREE_PLAN_PRODUCT_ID: ${{ env.STRIPE_FREE_PLAN_PRODUCT_ID }} - PAYMENT_FEE_PERCENTAGE: ${{ env.PAYMENT_FEE_PERCENTAGE }} - PAYMENT_FEE_FIXED: ${{ env.PAYMENT_FEE_FIXED }} - SAML_DATABASE_URL: ${{ env.SAML_DATABASE_URL }} - SAML_ADMINS: ${{ env.SAML_ADMINS }} - NEXTAUTH_URL: ${{ env.NEXTAUTH_URL }} - NEXT_PUBLIC_IS_E2E: ${{ env.NEXT_PUBLIC_IS_E2E }} - TURBO_TOKEN: ${{ env.TURBO_TOKEN }} - TURBO_TEAM: ${{ env.TURBO_TEAM }} + - uses: ./.github/actions/env-read-file + - uses: ./.github/actions/cache-db + - uses: ./.github/actions/cache-build diff --git a/gh.env b/gh.env new file mode 100644 index 0000000000..dc7916b2eb --- /dev/null +++ b/gh.env @@ -0,0 +1 @@ +# Do not modify this file, it's needed for CI From a3f3f1f26358a0e0884dbb0c10e013b651f7b548 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 28 Feb 2023 11:30:54 +0000 Subject: [PATCH 2/6] Match env file exactly without restore-keys --- .github/actions/env-read-file/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/env-read-file/action.yml b/.github/actions/env-read-file/action.yml index 78d3ce75da..6d883329f7 100644 --- a/.github/actions/env-read-file/action.yml +++ b/.github/actions/env-read-file/action.yml @@ -9,7 +9,6 @@ runs: with: path: gh.env key: env-cache-${{ hashFiles('gh.env') }} - restore-keys: env-cache- - name: Set Environment Variables if: steps.env-cache.outputs.cache-hit == 'true' uses: tw3lveparsecs/github-actions-setvars@latest From e018eb9ebe3752bce76906cbd3d35dc49be4daca Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 28 Feb 2023 11:39:54 +0000 Subject: [PATCH 3/6] Omit cache-hit exit 1, assuming it'll fail regardless --- .github/actions/env-read-file/action.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/actions/env-read-file/action.yml b/.github/actions/env-read-file/action.yml index 6d883329f7..26ca4e0306 100644 --- a/.github/actions/env-read-file/action.yml +++ b/.github/actions/env-read-file/action.yml @@ -9,14 +9,8 @@ runs: with: path: gh.env key: env-cache-${{ hashFiles('gh.env') }} + restore-keys: env-cache- - name: Set Environment Variables - if: steps.env-cache.outputs.cache-hit == 'true' uses: tw3lveparsecs/github-actions-setvars@latest with: - envFilePath: gh.env - - name: Set Environment Variables - if: steps.env-cache.outputs.cache-hit != 'true' - shell: bash - run: | - echo "You need to run env-create-file first" - exit 1 + envFilePath: gh.env \ No newline at end of file From 31599cdd26631c57bef64dc2ea480a11ff17b1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Tue, 28 Feb 2023 07:38:28 -0700 Subject: [PATCH 4/6] Fixes prod build hashing https://github.com/actions/cache/issues/1125#issuecomment-1447688501 --- .github/actions/cache-build/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/cache-build/action.yml b/.github/actions/cache-build/action.yml index 2899075b14..b892ad544c 100644 --- a/.github/actions/cache-build/action.yml +++ b/.github/actions/cache-build/action.yml @@ -13,7 +13,7 @@ runs: env: cache-name: prod-build key-1: ${{ inputs.node_version }}-${{ hashFiles('yarn.lock') }} - key-2: ${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + key-2: ${{ hashFiles('**/**.[jt]s', '**/**.[jt]sx') }} key-3: ${{ github.event.pull_request.number || github.ref }} with: path: | From feca7c23fb575779427e971e1f01a28e798c49f7 Mon Sep 17 00:00:00 2001 From: zomars Date: Tue, 28 Feb 2023 10:03:13 -0700 Subject: [PATCH 5/6] Removes partial matching for DB --- .github/actions/cache-db/action.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/cache-db/action.yml b/.github/actions/cache-db/action.yml index 93fc9ebd2f..a706e3260c 100644 --- a/.github/actions/cache-db/action.yml +++ b/.github/actions/cache-db/action.yml @@ -15,12 +15,11 @@ runs: uses: actions/cache@v3 env: cache-name: cache-db - key-1: ${{ hashFiles('packages/prisma/schema.prisma','packages/prisma/migrations/**.sql','packages/prisma/*.ts') }} + key-1: ${{ hashFiles('packages/prisma/schema.prisma', 'packages/prisma/migrations/**/**.sql', 'packages/prisma/*.ts') }} + key-2: ${{ github.event.pull_request.number || github.ref }} with: path: ${{ inputs.path }} - key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ github.sha }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ env.key-2 }} - run: yarn db-seed if: steps.cache-db.outputs.cache-hit != 'true' shell: bash From 9c794bac1a9258f2790bf2dcd0325ac075a9638c Mon Sep 17 00:00:00 2001 From: zomars Date: Tue, 28 Feb 2023 10:12:55 -0700 Subject: [PATCH 6/6] Only match exact key --- .github/actions/yarn-install/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/yarn-install/action.yml b/.github/actions/yarn-install/action.yml index 0a9be1454b..d3602bbfff 100644 --- a/.github/actions/yarn-install/action.yml +++ b/.github/actions/yarn-install/action.yml @@ -23,7 +23,6 @@ runs: **/node_modules/** packages/prisma/zod key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.cache-key }} - restore-keys: ${{ runner.os }}-${{ env.cache-name }}- - name: Yarn install shell: bash if: steps.node-modules-cache.outputs.cache-hit != 'true'