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

Refactor workflow into jobs #1414

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
7dc529f
create two sample tests
nbeck415 Sep 29, 2023
fcfaaf6
dockerize
nbeck415 Sep 29, 2023
e61f1e5
clean up test
nbeck415 Sep 29, 2023
a0860a7
this seems to get us one step further
nbeck415 Sep 29, 2023
f9f28b5
change printwidth for prettier
nbeck415 Sep 29, 2023
84561b7
fix tabs as requested by prettier
nbeck415 Sep 29, 2023
f49c7b1
trying new docker + compose edits
nbeck415 Oct 5, 2023
c2ab193
rm volumes
nbeck415 Oct 5, 2023
744b3af
remove linter
nbeck415 Oct 5, 2023
5c4c812
update compose
nbeck415 Oct 5, 2023
37df27d
fix indent
nbeck415 Oct 5, 2023
9879b9d
remove more eslint
nbeck415 Oct 5, 2023
b13a20d
add github actions workflow
nbeck415 Oct 5, 2023
f3ac0c2
remove esbuild
nbeck415 Oct 5, 2023
710ed9f
Revert "remove esbuild"
nbeck415 Oct 5, 2023
f85a21f
Update shipyard.yml
nbeck415 Oct 6, 2023
0a939fe
add database volume
nbeck415 Oct 6, 2023
ceda937
localhost cors header
nbeck415 Oct 6, 2023
79b806c
Simplify docker-compose (#1)
elliott-king Oct 6, 2023
ca34918
edit to single service compose
nbeck415 Oct 6, 2023
7cfa5f3
Merge branch 'shipyard-demo' of https://github.com/nbeck415/cypress-r…
nbeck415 Oct 6, 2023
6544acb
update workflow
nbeck415 Oct 6, 2023
7ab8b27
use old SY action
nbeck415 Oct 6, 2023
79ca028
we dont want these tests going on every run
nbeck415 Oct 6, 2023
04ab57f
fix: frontend/backend services pointing to SY domain (#2)
elliott-king Oct 7, 2023
107ab0c
try to set up python in workflow
nbeck415 Oct 7, 2023
a0f618a
try without container in workflow
nbeck415 Oct 7, 2023
ebd98f0
remove bypass token
nbeck415 Oct 7, 2023
c5f7431
reformat secrets, add timeout minutes to fetch env vars
nbeck415 Oct 7, 2023
e5a5453
Add new CI step
nbeck415 Oct 7, 2023
a77b06d
test out installing node in CI
nbeck415 Oct 7, 2023
e57837d
remove python install, try installing dependencies via yarn
nbeck415 Oct 8, 2023
32f28f5
bump node version
nbeck415 Oct 8, 2023
08b599f
add app name
nbeck415 Oct 8, 2023
e21e694
Update domains to use SY env vars
nbeck415 Oct 8, 2023
645bdb1
remove aws config
nbeck415 Oct 8, 2023
9cdb46e
add https:// to env url
nbeck415 Oct 8, 2023
aa38b96
add https:// to baseUrl
nbeck415 Oct 8, 2023
52e1d00
Update shipyard.yml
akshaykalia Oct 8, 2023
31ede46
update env var
akshaykalia Oct 8, 2023
10272ca
Update shipyard.yml
akshaykalia Oct 8, 2023
5f93f87
remove brackets
akshaykalia Oct 8, 2023
df31957
print url in cypress action
akshaykalia Oct 8, 2023
065ced3
try passing env var differently
akshaykalia Oct 8, 2023
47af707
update spec path
akshaykalia Oct 8, 2023
3692fd9
test visiting env w bypass token
nbeck415 Oct 8, 2023
a294c7b
log frontend env var
nbeck415 Oct 8, 2023
158a854
try full URL
nbeck415 Oct 8, 2023
e707eea
test hardcoding URL
nbeck415 Oct 8, 2023
bb67afa
rm bypass token
nbeck415 Oct 8, 2023
d0bc662
don't seed a second time (test)
nbeck415 Oct 8, 2023
afec6d4
Add named volume for db (#4)
elliott-king Oct 8, 2023
c9928dd
try modifying env vars
nbeck415 Oct 9, 2023
0358a9b
change db loc
nbeck415 Oct 9, 2023
ece7d3f
don't seed db
nbeck415 Oct 9, 2023
3eb6352
log current url
nbeck415 Oct 9, 2023
3789a4e
test commit
nbeck415 Oct 9, 2023
e1e2429
upload cypress screenshots in CI
nbeck415 Oct 9, 2023
b1274f4
change upload artifact loc
nbeck415 Oct 9, 2023
2b3802d
add dist dir
nbeck415 Oct 9, 2023
95e8965
hardcode baseUrl
nbeck415 Oct 9, 2023
5524c45
hardcode a few more baseUrl instances
nbeck415 Oct 9, 2023
787b479
Revert "hardcode a few more baseUrl instances"
nbeck415 Oct 9, 2023
8876b12
comment out test 2
nbeck415 Oct 9, 2023
f4edf5d
use env vars for urls
nbeck415 Oct 9, 2023
8b646dd
hardcode frontend
nbeck415 Oct 9, 2023
67a38fe
test removing route from backend
nbeck415 Oct 10, 2023
8ed57eb
use backend port for api url
nbeck415 Oct 10, 2023
0a80b76
Merge branch 'shipyard-demo' of https://github.com/nbeck415/cypress-r…
nbeck415 Oct 10, 2023
27f1b2d
use backend service for db requests
nbeck415 Oct 10, 2023
e64abdf
fix: re-add env urls
akshaykalia Oct 10, 2023
7597606
rm frontend from front of url
nbeck415 Oct 10, 2023
c597fa1
Merge branch 'shipyard-demo' of https://github.com/nbeck415/cypress-r…
nbeck415 Oct 10, 2023
cd974d6
chore: add temp logs
akshaykalia Oct 10, 2023
3c5a1cf
Merge branch 'shipyard-demo' of ssh://github.com/nbeck415/cypress-rea…
akshaykalia Oct 10, 2023
f7f8a77
chore: append https to targetUrl
akshaykalia Oct 10, 2023
c909f43
chore: disable cors
akshaykalia Oct 10, 2023
06797fa
revert: vite-cors-plugin
akshaykalia Oct 10, 2023
b85495e
chore: add cors flag to server
akshaykalia Oct 10, 2023
0287092
fix: disable cors differently
akshaykalia Oct 10, 2023
4a947df
chore: disable cors on react app
akshaykalia Oct 10, 2023
8ac9d23
make run less often
nbeck415 Oct 10, 2023
5f510ad
refactor workflow into jobs
nbeck415 Oct 10, 2023
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
6 changes: 3 additions & 3 deletions .github/workflows/add_issue_to_triage_board.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
issues:
types:
- opened
pull_request_target:
types:
- opened
#pull_request_target:
# types:
# - opened
jobs:
add-to-triage-project-board:
uses: cypress-io/cypress/.github/workflows/triage_add_to_project.yml@develop
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Cypress Tests

on:
push:
branches-ignore:
- "renovate/**"
on: [pull_request]

jobs:
install:
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/shipyard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run E2E Tests

on: [push]

jobs:
init-cypress:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cypress install
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Save build folder
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
path: dist

- run: yarn cypress info
- run: node --version
- run: node -p 'os.cpus()'
- run: yarn types
init-app:
steps:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '18.16.1'
- name: Install dependencies
run: yarn install
init-environment:
steps:
- name: Integrate Shipyard
uses: shipyard/github-action/[email protected]
with:
api-token: ${{ secrets.SHIPYARD_API_TOKEN }}
timeout-minutes: "10"
app-name: "cypress-realworld-app"
- name: Print Env Data
run: |
echo "CYPRESS_BASE_URL=${SHIPYARD_ENVIRONMENT_URL}" >> $GITHUB_ENV
echo "CYPRESS_BYPASS_TOKEN=${SHIPYARD_BYPASS_TOKEN}" >> $GITHUB_ENV
env | grep -e SHIPYARD -e CYPRESS
shell: bash
- name: Run E2E tests against the ephemeral environment
run: |
echo $SHIPYARD_ENVIRONMENT_URL
yarn cypress:run --spec "cypress/tests/shipyard/manage-user.spec.ts"
shell: bash
env:
CYPRESS_BASE_URL: ${{ env.CYPRESS_BASE_URL }}
CYPRESS_BYPASS_TOKEN: ${{ env.CYPRESS_BYPASS_TOKEN }}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "es5",
"printWidth": 100,
"printWidth": 160,
"endOfLine": "auto"
}
2 changes: 1 addition & 1 deletion .yarn/releases/yarn-1.22.19.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -96321,7 +96321,7 @@ let main = exports.main = (() => {
return new Promise(function (resolve, reject) {
const connectionOptions = {
port: +mutexPort || (_constants || _load_constants()).SINGLE_INSTANCE_PORT,
host: 'localhost'
host: '0.0.0.0'
};

function startServer() {
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:18.16.1-alpine AS build
WORKDIR /app

COPY package.json yarn.lock .yarnrc vite.config.ts ./

RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true yarn install

COPY . .

# start app
CMD ["yarn", "dev"]
2 changes: 1 addition & 1 deletion backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { frontendPort, getBackendPort } from "../src/utils/portUtils";
require("dotenv").config();

const corsOption = {
origin: `http://localhost:${frontendPort}`,
origin: process.env.SHIPYARD_DOMAIN_FRONTEND ? `https://${process.env.SHIPYARD_DOMAIN_FRONTEND}` : `http://localhost:${frontendPort}`,
credentials: true,
};

Expand Down
2 changes: 1 addition & 1 deletion backend/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const COMMENT_TABLE = "comments";
const NOTIFICATION_TABLE = "notifications";
const BANK_TRANSFER_TABLE = "banktransfers";

const databaseFile = path.join(__dirname, "../data/database.json");
const databaseFile = path.join(__dirname, "../data/database/database.json");
const adapter = new FileSync<DbSchema>(databaseFile);

const db = low(adapter);
Expand Down
20 changes: 12 additions & 8 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ import { defineConfig } from "cypress";
dotenv.config({ path: ".env.local" });
dotenv.config();

const awsConfig = require(path.join(__dirname, "./aws-exports-es5.js"));
//const awsConfig = require(path.join(__dirname, "./aws-exports-es5.js"));

module.exports = defineConfig({
projectId: "7s5okt",
video: true,
retries: {
runMode: 2,
},
env: {
apiUrl: "http://localhost:3001",
apiUrl: `${process.env.SHIPYARD_DOMAIN_BACKEND}`,
url: `${process.env.SHIPYARD_DOMAIN_BACKEND}`,
//apiUrl: "http://backend:3001",
//url: "http://backend:3001",
mobileViewportWidthBreakpoint: 414,
coverage: false,
codeCoverage: {
url: "http://localhost:3001/__coverage__",
url: `${process.env.SHIPYARD_DOMAIN_BACKEND}/__coverage__`,
exclude: "cypress/**/*.*",
},
defaultPassword: process.env.SEED_DEFAULT_USER_PASSWORD,
Expand All @@ -41,11 +45,11 @@ module.exports = defineConfig({
okta_programmatic_login: process.env.OKTA_PROGRAMMATIC_LOGIN || false,

// Amazon Cognito
cognito_username: process.env.AWS_COGNITO_USERNAME,
cognito_password: process.env.AWS_COGNITO_PASSWORD,
cognito_domain: process.env.AWS_COGNITO_DOMAIN,
cognito_username: process.env._COGNITO_USERNAME,
cognito_password: process.env._COGNITO_PASSWORD,
cognito_domain: process.env._COGNITO_DOMAIN,
cognito_programmatic_login: false,
awsConfig: awsConfig.default,
//awsConfig: awsConfig.default,

// Google
googleRefreshToken: process.env.GOOGLE_REFRESH_TOKEN,
Expand All @@ -65,7 +69,7 @@ module.exports = defineConfig({
},
},
e2e: {
baseUrl: "http://localhost:3000",
baseUrl: `https://${process.env.SHIPYARD_DOMAIN_FRONTEND}`,
specPattern: "cypress/tests/**/*.spec.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.ts",
viewportHeight: 1000,
Expand Down
101 changes: 101 additions & 0 deletions cypress/tests/shipyard/manage-user.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { User } from "models";

describe("Create new user", function () {
beforeEach(function () {
//console.log(process.env.SHIPYARD_DOMAIN_FRONTEND)
const urlToVisit = "/signup";
cy.visit(urlToVisit);
cy.url().then((url) => {
cy.log(`Current URL: ${url}`);
});
//cy.task("db:seed");
});
// go to sign up page and register
it("should create a new user", function () {
//cy.visit('/signup')
// tracking using a random ID
const userId = Cypress._.random(1000, 9999);
const username = `user${userId}`;
const firstName = `Name${userId}`
const lastName = `T${userId}`
cy.get("input[name='username']").type(username);
cy.get("input[name='firstName']").type(firstName);
cy.get("input[name='lastName']").type(lastName);
// only field that really matters is username because uses ID
// maybe we track user by the auto assigned ID instead of username?
cy.get("input[name='password']").type("testingPwd");
cy.get("input[name='confirmPassword']").type("testingPwd");

// add user to db
cy.get("button[type='submit']").click();

// want to change this to check for most recent entry, but stuck
// adds the user to the middle of the db
// maybe we sort db by date-created field
/*cy.database("find", "users", { username: username }).then((user: User) => {
expect(user.username).to.equal(username);
});*/
});
});
//want to pretend you have rolled back to prev snap
// create a user and go to snap where user no longer exists
//click trash = all data will be deleted
//next run = the database will be pop with basic contents
//itll be as if youve rolled back

/*
describe("Edit existing user", function () {
const testEmail = "[email protected]"
beforeEach(function () {
const urlToVisit = "/";
cy.visit(urlToVisit);
//cy.task("db:seed");

cy.intercept("PATCH", "/users/*").as("updateUser");
cy.intercept("GET", "/notifications*").as("getNotifications");

cy.database("find", "users", { email: testEmail }).then((user) => {
if (user) {
cy.loginByXstate(user.username);
}
});

cy.getBySel("sidenav-user-settings").click();

});
it("should edit an existing user", function () {
cy.visit('/user/settings')
// tracking using a random ID
const userId = Cypress._.random(1000, 9999);
const newName = `Name${userId}`
const newLast = `T${userId}`
const newEmail = `${newName}@gmail.com`
const newNumber = "415-555-8992"
// clear fields
cy.get("input[name='firstName']").clear();
cy.get("input[name='lastName']").clear();
cy.get("input[name='email']").clear();
cy.get("input[name='phoneNumber']").clear();
// type inputs
cy.get("input[name='firstName']").type(newName);
cy.get("input[name='lastName']").type(newLast);
cy.get("input[name='email']").type(newEmail);
cy.get("input[name='phoneNumber']").type(newNumber);
// edit user in db
cy.get("button[type='submit']").click();

cy.database("find", "users", { email: newEmail })
.then((user: User) => {
if (user) {
cy.log(`Found user with email: ${user.email}`);
expect(user.email).to.equal(newEmail);
expect(user.firstName).to.equal(newName);
expect(user.lastName).to.equal(newLast);
expect(user.phoneNumber).to.equal(newNumber);
} else {
cy.log(`User with email "${testEmail}" not found in the database.`);
}
})
});
});
*/
File renamed without changes.
1 change: 1 addition & 0 deletions dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3'

services:
frontend:
build:
context: '.'
labels:
shipyard.route: '/'
shipyard.primary-route: 'true'
environment:
SHIPYARD_DOMAIN_BACKEND: ${SHIPYARD_DOMAIN_BACKEND-}
ports:
- '3000:3000'
env_file:
- .env

backend:
build:
context: '.'
labels:
shipyard.route: '/api'
environment:
SHIPYARD_DOMAIN_FRONTEND: ${SHIPYARD_DOMAIN_FRONTEND-}
ports:
- '3001:3001'
volumes:
- 'dbdata:/app/data/database'
env_file:
- .env

volumes:
dbdata:
Loading