Skip to content

Commit 1be60da

Browse files
committed
revert to chrome whoops
1 parent 77f62db commit 1be60da

File tree

2 files changed

+155
-57
lines changed

2 files changed

+155
-57
lines changed

.github/workflows/test.yml

Lines changed: 143 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- name: Checkout repository
2121
uses: actions/checkout@v2
22-
22+
2323
- name: Set up .env
2424
env:
2525
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
@@ -30,7 +30,7 @@ jobs:
3030
echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
3131
echo "JWT_SECRET=$JWT_SECRET" >> .env
3232
echo "EXECUTION_SERVICE_URL=$EXECUTION_SERVICE_URL" >> .env
33-
33+
3434
- name: Set up credentials
3535
env:
3636
QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
@@ -41,8 +41,8 @@ jobs:
4141
4242
- name: Setup Go
4343
uses: actions/setup-go@v5
44-
with:
45-
go-version: "1.23.x"
44+
with:
45+
go-version: '1.23.x'
4646

4747
- name: Install Go dependencies
4848
run: |
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Install firebase tools
5353
run: curl -sL firebase.tools | bash
54-
54+
5555
- name: Run Go tests with Firebase emulator
5656
run: firebase emulators:exec --only firestore 'cd ./apps/question-service; go test -v ./tests'
5757

@@ -66,11 +66,11 @@ jobs:
6666
run: |
6767
cd ./apps/frontend
6868
cp .env.example .env
69-
69+
7070
- name: Set up Node.js
7171
uses: actions/setup-node@v2
7272
with:
73-
node-version: "22"
73+
node-version: '22'
7474

7575
- name: Install pnpm
7676
run: npm i -g pnpm
@@ -85,38 +85,160 @@ jobs:
8585
cd ./apps/frontend
8686
pnpm unit-test
8787
88-
test-webdriver-working:
88+
test-docker-compose:
8989
runs-on: ubuntu-latest
9090

9191
steps:
9292
- name: Checkout code
9393
uses: actions/checkout@v4
9494

95+
- name: Set up Docker Compose
96+
run: |
97+
sudo apt-get update
98+
sudo apt-get install -y docker-compose
99+
100+
- name: Create Environment Files
101+
env:
102+
QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }}
103+
USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }}
104+
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
105+
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
106+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
107+
EXECUTION_SERVICE_URL: ${{ vars.EXECUTION_SERVICE_URL }}
108+
JWT_SECRET: ${{ secrets.JWT_SECRET }}
109+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
110+
HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }}
111+
EXECUTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.EXECUTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
112+
DB_CLOUD_URI: ${{ secrets.USER_SERVICE_DB_CLOUD_URI }}
113+
USER_SERVICE_PORT: ${{ vars.USER_SERVICE_PORT }}
114+
MATCHING_SERVICE_PORT: ${{ vars.MATCHING_SERVICE_PORT }}
115+
HISTORY_SERVICE_PORT: ${{ vars.HISTORY_SERVICE_PORT }}
116+
SIGNALLING_SERVICE_PORT: ${{ vars.SIGNALLING_SERVICE_PORT }}
117+
EXECUTION_SERVICE_PORT: ${{ vars.EXECUTION_SERVICE_PORT }}
118+
MATCHING_SERVICE_TIMEOUT: ${{ vars.MATCHING_SERVICE_TIMEOUT }}
119+
REDIS_URL: ${{ vars.REDIS_URL }}
120+
QUESTION_SERVICE_GRPC_URL: ${{ vars.QUESTION_SERVICE_GPRC_URL }}
121+
run: |
122+
cd ./apps/frontend
123+
echo "NEXT_PUBLIC_QUESTION_SERVICE_URL=$QUESTION_SERVICE_URL" >> .env
124+
echo "NEXT_PUBLIC_USER_SERVICE_URL=$USER_SERVICE_URL" >> .env
125+
echo "NEXT_PUBLIC_MATCHING_SERVICE_URL=$MATCHING_SERVICE_URL" >> .env
126+
echo "NEXT_PUBLIC_HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env
127+
echo "NEXT_PUBLIC_SIGNALLING_SERVICE_URL=$SIGNALLING_SERVICE_URL" >> .env
128+
echo "NEXT_PUBLIC_EXECUTION_SERVICE_URL=EXECUTION_SERVICE_URL" >> .env
129+
130+
cd ../question-service
131+
echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
132+
echo "JWT_SECRET=$JWT_SECRET" >> .env
133+
echo "EXECUTION_SERVICE_URL=$EXECUTION_SERVICE_URL" >> .env
134+
135+
cd ../user-service
136+
echo "DB_CLOUD_URI=$DB_CLOUD_URI" >> .env
137+
echo "PORT=$USER_SERVICE_PORT" >> .env
138+
echo "JWT_SECRET=$JWT_SECRET" >> .env
139+
140+
cd ../matching-service
141+
echo "PORT=$MATCHING_SERVICE_PORT" >> .env
142+
echo "MATCH_TIMEOUT=$MATCHING_SERVICE_TIMEOUT" >> .env
143+
echo "JWT_SECRET=$JWT_SECRET" >> .env
144+
echo "REDIS_URL=$REDIS_URL" >> .env
145+
echo "QUESTION_SERVICE_GRPC_URL=$QUESTION_SERVICE_GRPC_URL" >> .env
146+
147+
cd ../history-service
148+
echo "FIREBASE_CREDENTIAL_PATH=$HISTORY_FIREBASE_CREDENTIAL_PATH" >> .env
149+
echo "PORT=$HISTORY_SERVICE_PORT" >> .env
150+
151+
cd ../execution-service
152+
echo "FIREBASE_CREDENTIAL_PATH=$EXECUTION_FIREBASE_CREDENTIAL_PATH" >> .env
153+
echo "PORT=$EXECUTION_SERVICE_PORT" >> .env
154+
echo "HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env
155+
156+
cd ../signalling-service
157+
echo "PORT=$SIGNALLING_SERVICE_PORT" >> .env
158+
159+
- name: Create Database Credential Files
160+
env:
161+
QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
162+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
163+
HISTORY_FIREBASE_JSON: ${{ secrets.HISTORY_SERVICE_FIREBASE_CREDENTIAL }}
164+
HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }}
165+
EXECUTION_FIREBASE_JSON: ${{ secrets.EXECUTION_SERVICE_FIREBASE_CREDENTIAL }}
166+
EXECUTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.EXECUTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
167+
run: |
168+
cd ./apps/question-service
169+
echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH"
170+
171+
cd ../history-service
172+
echo "$HISTORY_FIREBASE_JSON" > "./$HISTORY_FIREBASE_CREDENTIAL_PATH"
173+
174+
cd ../execution-service
175+
echo "$EXECUTION_FIREBASE_JSON" > "./$EXECUTION_FIREBASE_CREDENTIAL_PATH"
176+
177+
- name: Build and Run Services
178+
run: |
179+
cd ./apps
180+
docker-compose up --build -d
181+
182+
- name: Wait for services to be ready
183+
run: sleep 30
184+
185+
- name: Install websocat
186+
run: |
187+
sudo wget -qO /usr/local/bin/websocat https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl
188+
sudo chmod a+x /usr/local/bin/websocat
189+
websocat --version
190+
191+
- name: Run Tests
192+
env:
193+
FRONTEND_URL: ${{ vars.FRONTEND_URL }}
194+
USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }}
195+
QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }}
196+
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
197+
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
198+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
199+
EXECUTION_SERVICE_URL: ${{ vars.EXECUTION_SERVICE_URL }}
200+
run: |
201+
echo "Testing Question Service..."
202+
curl -sSL -o /dev/null $QUESTION_SERVICE_URL && echo "Question Service is up"
203+
echo "Testing User Service..."
204+
curl -fsSL -o /dev/null $USER_SERVICE_URL && echo "User Service is up"
205+
echo "Testing Frontend..."
206+
curl -fsSL -o /dev/null $FRONTEND_URL && echo "Frontend is up"
207+
echo "Testing History Service..."
208+
curl -fsSL -o /dev/null $HISTORY_SERVICE_URL && echo "History Service is up"
209+
echo "Testing Execution Service..."
210+
curl -fsSL -o /dev/null $EXECUTION_SERVICE_URL && echo "Execution Service is up"
211+
echo "Testing Matching Service..."
212+
if ! (echo "Hello" | websocat $MATCHING_SERVICE_URL); then
213+
echo "WebSocket for Matching Service is not live"
214+
else
215+
echo "WebSocket for Matching Service is live"
216+
fi
217+
# Add in test for matching service in the future
218+
echo "Testing Signalling Service..."
219+
if ! (echo "Hello" | websocat $SIGNALLING_SERVICE_URL); then
220+
echo "WebSocket for Signalling Service is not live"
221+
else
222+
echo "WebSocket for Signalling Service is live"
223+
fi
224+
# We can add more tests here
225+
95226
- name: Install pnpm
96227
uses: pnpm/action-setup@v4
97228
with:
98229
version: 9.1.4
99-
230+
100231
- name: Install dependencies
101232
run: |
102233
cd ./apps/frontend
103234
pnpm i
104-
235+
105236
- name: Install Chrome WebDriver
106237
uses: nanasess/setup-chromedriver@v2
107238
with:
108239
chromedriver-version: '130.0.6723.116'
109-
110-
- name: Install Edge
111-
uses: browser-actions/setup-edge@v1
112-
with:
113-
edge-version: stable
114-
115-
- name: Install Geckodriver
116-
uses: browser-actions/setup-geckodriver@latest
117-
240+
118241
- name: Run Browser Test
119242
run: |
120243
cd ./apps/frontend
121-
pnpm browser-test -t "webdriver installed correctly"
122-
244+
pnpm browser-test
Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,37 @@
1-
import { Actions, Browser, Builder, By, Capabilities, Key, until, WebDriver } from "selenium-webdriver"
2-
3-
import {Options as ChromeOptions} from "selenium-webdriver/chrome"
4-
import {Options as EdgeOptions} from "selenium-webdriver/edge"
5-
import {Options as FirefoxOptions} from "selenium-webdriver/firefox"
1+
import { Actions, Browser, Builder, By, Key, until, WebDriver } from "selenium-webdriver"
62

3+
import Chrome from "selenium-webdriver/chrome"
74
const URL = 'http://localhost:3000/';
85
const ETERNAL_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjk5OTk5OTk5OTk5fQ.Z4_FVGQ5lIcouP3m4YLMr6pGMF17IJFfo2yOTiN58DY"
96

10-
const CHROME_OPTIONS = new ChromeOptions()
11-
.addArguments("--headless=new") as ChromeOptions; // uncomment locally to see the steps in action
12-
const EDGE_OPTIONS = new EdgeOptions()
13-
.setBinaryPath("/opt/hostedtoolcache/msedge/stable/x64/msedge") // need to point to the correct path
14-
.addArguments("--headless=new") as EdgeOptions;
15-
16-
const FIREFOX_OPTIONS = new FirefoxOptions()
17-
.addArguments("--headless") as FirefoxOptions;
18-
19-
const builder = new Builder()
20-
.setChromeOptions(CHROME_OPTIONS)
21-
.setEdgeOptions(EDGE_OPTIONS)
22-
.setFirefoxOptions(FIREFOX_OPTIONS)
23-
24-
describe.each([Browser.CHROME, Browser.EDGE, Browser.FIREFOX])("%s driver test", (browser) => {
7+
describe("chrome browser", () => {
8+
const options = new Chrome.Options()
9+
.addArguments("--headless=new") as Chrome.Options; // uncomment locally to see the steps in action
10+
const builder = new Builder().forBrowser(Browser.CHROME).setChromeOptions(options);
2511
let driver: WebDriver;
26-
beforeAll(() => {
27-
const cap = new Capabilities().setBrowserName(browser)
28-
builder.withCapabilities(cap);
29-
})
3012

3113
beforeEach(async () => {
32-
console.log(browser + ": building...");
3314
driver = await builder.build();
34-
console.log(browser + ": built");
35-
}, 10000)
15+
})
3616

3717
afterEach(async () => {
38-
if (driver) {
39-
await driver.quit();
40-
}
18+
await driver.quit();
4119
})
4220

43-
describe("webdriver installed correctly", () => {
21+
describe("chrome webdriver installed correctly", () => {
4422
it("does google search", async () => {
4523
await driver.get('http://www.google.com');
4624
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
4725
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
4826
}, 10000);
49-
50-
it.skip("does another google search", async () => {
27+
it("does another google search", async () => {
5128
await driver.get('http://www.google.com');
5229
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
5330
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
5431
}, 10000);
5532
});
5633

57-
describe.skip("browser-test", () => {
34+
describe("browser-test", () => {
5835
it("accesses and login to peerprep", async () => {
5936
await driver.get(URL);
6037
await driver.wait(until.urlIs(`${URL}login`));
@@ -75,8 +52,7 @@ describe.each([Browser.CHROME, Browser.EDGE, Browser.FIREFOX])("%s driver test",
7552
expect(slogan2).toBe("peers");
7653
}, 10000);
7754
})
78-
}, 20000)
79-
55+
})
8056

8157

8258

0 commit comments

Comments
 (0)