Skip to content

Commit

Permalink
Merge pull request #72 from superglue-ai/feature/playwright
Browse files Browse the repository at this point in the history
Feature/playwright
  • Loading branch information
stefanfaistenauer authored Mar 4, 2025
2 parents 90dfeae + f2e3931 commit 202ffc5
Show file tree
Hide file tree
Showing 10 changed files with 633 additions and 443 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
run: |
rm -rf node_modules package-lock.json
npm install
- name: Install Playwright browsers
run: npx playwright install

- name: Run tests
run: npm run test
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ RUN npm install && \
# Copy source code
COPY . .

# After copying files but before building
# Build the application
RUN npm run build


# Production stage
FROM node:22-slim
Expand All @@ -43,9 +42,10 @@ COPY packages/core/package*.json ./packages/core/
COPY packages/web/package*.json ./packages/web/
COPY packages/shared/package*.json ./packages/shared/

# Install production dependencies only
# Install production dependencies and Playwright
RUN npm ci --omit=dev && \
npm install -g next turbo cross-env
npm install -g next turbo cross-env && \
npx playwright install --with-deps

# Copy built files from builder stage
COPY --from=builder /usr/src/app/packages/core/dist ./packages/core/dist
Expand Down
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"clean": "turbo run clean"
},
"dependencies": {
"@playwright/test": "^1.50.1",
"@superglue/client": "^2.3.11",
"dotenv": "^16.4.7",
"dotenv-cli": "^8.0.0"
Expand Down
14 changes: 14 additions & 0 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,22 @@ function getAuthErrorHTML(token: string | undefined) {
`;
}

function validateEnvironment() {
const requiredEnvVars = [
'OPENAI_MODEL',
'GRAPHQL_PORT',
'OPENAI_API_KEY'
];
requiredEnvVars.forEach((envVar) => {
if (!process.env[envVar]) {
throw new Error(`Environment variable ${envVar} is not set.`);
}
});
}

// Server Setup
async function startServer() {
validateEnvironment();
// Initialize Apollo Server
const server = new ApolloServer(apolloConfig);
await server.start();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export async function callEndpoint(endpoint: ApiConfig, payload: Record<string,
);

const body = endpoint.body ?
JSON.parse(replaceVariables(endpoint.body, requestVars)) :
{};
replaceVariables(endpoint.body, requestVars) :
"";

const url = replaceVariables(composeUrl(endpoint.urlHost, endpoint.urlPath), requestVars);
const axiosConfig: AxiosRequestConfig = {
Expand Down
Loading

0 comments on commit 202ffc5

Please sign in to comment.