-
-
Notifications
You must be signed in to change notification settings - Fork 173
chore: removed all e2e env variables and migrated them to constants file #1189
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
Merged
NiallJoeMaher
merged 1 commit into
codu-code:develop
from
JohnAllenTech:chore/remoing-all-e2e-env-variables
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,12 +44,6 @@ jobs: | |
| GITHUB_ID: ${{ secrets.E2E_GITHUB_ID }} | ||
| GITHUB_SECRET: ${{ secrets.E2E_GITHUB_SECRET }} | ||
| NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} | ||
| E2E_USER_ONE_EMAIL: [email protected] | ||
| E2E_USER_ONE_ID: 8e3179ce-f32b-4d0a-ba3b-234d66b836ad | ||
| E2E_USER_ONE_SESSION_ID: df8a11f2-f20a-43d6-80a0-a213f1efedc1 | ||
| E2E_USER_TWO_EMAIL: [email protected] | ||
| E2E_USER_TWO_ID: a15a104a-0e34-4101-8800-ed25c9231345 | ||
| E2E_USER_TWO_SESSION_ID: 10134766-bc6c-4b52-83d7-46ec0a4cb95d | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,22 +7,16 @@ import "dotenv/config"; | |
|
|
||
| import { drizzle, type PostgresJsDatabase } from "drizzle-orm/postgres-js"; | ||
| import postgres from "postgres"; | ||
| import { | ||
| E2E_USER_ONE_EMAIL, | ||
| E2E_USER_ONE_ID, | ||
| E2E_USER_TWO_EMAIL, | ||
| E2E_USER_TWO_ID, | ||
| E2E_USER_ONE_SESSION_ID, | ||
| E2E_USER_TWO_SESSION_ID, | ||
| } from "../e2e/constants"; | ||
|
|
||
| const DATABASE_URL = process.env.DATABASE_URL || ""; | ||
| // These can be removed in a follow on PR. Until this hits main we cant add E2E_USER_* stuff to the env. | ||
| const E2E_USER_ONE_SESSION_ID = | ||
| process.env.E2E_USER_ONE_SESSION_ID || "df8a11f2-f20a-43d6-80a0-a213f1efedc1"; | ||
| const E2E_USER_ONE_ID = | ||
| process.env.E2E_USER_ONE_ID || "8e3179ce-f32b-4d0a-ba3b-234d66b836ad"; | ||
| const E2E_USER_ONE_EMAIL = | ||
| process.env.E2E_USER_ONE_EMAIL || "[email protected]"; | ||
|
|
||
| const E2E_USER_TWO_SESSION_ID = | ||
| process.env.E2E_USER_TWO_SESSION_ID || "10134766-bc6c-4b52-83d7-46ec0a4cb95d"; | ||
| const E2E_USER_TWO_ID = | ||
| process.env.E2E_USER_TWO_ID || "a15a104a-0e34-4101-8800-ed25c9231345"; | ||
| const E2E_USER_TWO_EMAIL = | ||
| process.env.E2E_USER_TWO_EMAIL || "[email protected]"; | ||
|
|
||
| if (!DATABASE_URL) { | ||
| throw new Error("DATABASE_URL is not set"); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export const articleContent = | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vitae ipsum id metus vestibulum rutrum eget a diam. Integer eget vulputate risus, ac convallis nulla. Mauris sed augue nunc. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam congue posuere tempor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut ac augue non libero ullamcorper ornare. Ut commodo ligula vitae malesuada maximus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam sagittis justo non justo placerat, a dapibus sapien volutpat. Nullam ullamcorper sodales justo sed."; | ||
|
|
||
| export const articleExcerpt = "Lorem ipsum dolor sit amet"; | ||
|
|
||
| export const E2E_USER_ONE_EMAIL = "[email protected]"; | ||
| export const E2E_USER_ONE_ID = "8e3179ce-f32b-4d0a-ba3b-234d66b836ad"; | ||
| export const E2E_USER_ONE_SESSION_ID = "df8a11f2-f20a-43d6-80a0-a213f1efedc1"; | ||
JohnAllenTech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const E2E_USER_TWO_EMAIL = "[email protected]"; | ||
| export const E2E_USER_TWO_ID = "a15a104a-0e34-4101-8800-ed25c9231345"; | ||
| export const E2E_USER_TWO_SESSION_ID = "10134766-bc6c-4b52-83d7-46ec0a4cb95d"; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "./constants"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,12 @@ | ||
| import dotenv from "dotenv"; | ||
| import postgres from "postgres"; | ||
| import { drizzle } from "drizzle-orm/postgres-js"; | ||
| import { post, comment } from "@/server/db/schema"; | ||
|
|
||
| dotenv.config(); // Load .env file contents into process.env | ||
| import { E2E_USER_ONE_ID, E2E_USER_TWO_ID } from "./constants"; | ||
|
|
||
| export const setup = async () => { | ||
| if ( | ||
| !process.env.DATABASE_URL || | ||
| !process.env.E2E_USER_ONE_ID || | ||
| !process.env.E2E_USER_TWO_ID | ||
| ) { | ||
| throw new Error("Missing env variables for DB clean up script"); | ||
| } | ||
| const db = drizzle(postgres(process.env.DATABASE_URL as string)); | ||
| const db = drizzle( | ||
| postgres("postgresql://postgres:[email protected]:5432/postgres"), | ||
| ); | ||
JohnAllenTech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const addE2EArticleAndComment = async ( | ||
| authorId: string, | ||
|
|
@@ -52,10 +45,7 @@ export const setup = async () => { | |
| try { | ||
| console.log("creating articles"); | ||
|
|
||
| await addE2EArticleAndComment( | ||
| process.env.E2E_USER_ONE_ID as string, | ||
| process.env.E2E_USER_TWO_ID as string, | ||
| ); | ||
| await addE2EArticleAndComment(E2E_USER_ONE_ID, E2E_USER_TWO_ID); | ||
| console.log("DB setup successful"); | ||
| } catch (err) { | ||
| console.log("Error while setting up DB before E2E test run", err); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,23 @@ | ||
| import dotenv from "dotenv"; | ||
| import postgres from "postgres"; | ||
|
|
||
| dotenv.config(); // Load .env file contents into process.env | ||
| import { E2E_USER_ONE_ID, E2E_USER_TWO_ID } from "./constants"; | ||
|
|
||
| export const teardown = async () => { | ||
| try { | ||
| if ( | ||
| !process.env.DATABASE_URL || | ||
| !process.env.E2E_USER_ONE_ID || | ||
| !process.env.E2E_USER_TWO_ID | ||
| ) | ||
| throw new Error("Missing env variables for DB clean up script"); | ||
| const db = postgres(process.env.DATABASE_URL as string); | ||
| const db = postgres("postgresql://postgres:[email protected]:5432/postgres"); | ||
JohnAllenTech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // the test suit adds posts created by the E2E users. We want to remove them between test runs | ||
| await db` | ||
| DELETE FROM "Post" WHERE "userId" = ${process.env.E2E_USER_ONE_ID as string} | ||
| DELETE FROM "Post" WHERE "userId" = ${E2E_USER_ONE_ID} | ||
| `; | ||
| await db` | ||
| DELETE FROM "Post" WHERE "userId" = ${process.env.E2E_USER_TWO_ID as string} | ||
| DELETE FROM "Post" WHERE "userId" = ${E2E_USER_TWO_ID} | ||
| `; | ||
JohnAllenTech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // the test suit adds comments created by the E2E user. We want to remove them between test runs | ||
| await db` | ||
| DELETE FROM "Comment" WHERE "userId" = ${process.env.E2E_USER_ONE_ID as string} | ||
| DELETE FROM "Comment" WHERE "userId" = ${E2E_USER_ONE_ID} | ||
| `; | ||
| await db` | ||
| DELETE FROM "Comment" WHERE "userId" = ${process.env.E2E_USER_TWO_ID as string} | ||
| DELETE FROM "Comment" WHERE "userId" = ${E2E_USER_TWO_ID} | ||
| `; | ||
|
|
||
| console.log("DB clean up successful"); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,3 @@ GITLAB_ID= ### Replace with GitLab OAuth ID (https://gitlab.com/-/user_settings | |
| GITLAB_SECRET= ### Replace with GitLab OAuth Secret (https://gitlab.com/-/user_settings/applications) | ||
| NEXTAUTH_URL=http://localhost:3000/api/auth | ||
| DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres | ||
|
|
||
| [email protected] | ||
| E2E_USER_ONE_ID=8e3179ce-f32b-4d0a-ba3b-234d66b836ad | ||
| E2E_USER_TWO_ID=a15a104a-0e34-4101-8800-ed25c9231345 | ||
| E2E_USER_ONE_SESSION_ID=df8a11f2-f20a-43d6-80a0-a213f1efedc1 | ||
| E2E_USER_TWO_SESSION_ID=10134766-bc6c-4b52-83d7-46ec0a4cb95d | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.