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

Upload container #36

Merged
merged 14 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 23 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
#- run: npm --prefix webapp run test:e2e
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -59,6 +59,25 @@ jobs:
registry: ghcr.io
workdir: webapp
buildargs: API_URI

docker-push-qgservice:
name: Push question generator service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_en2a/questiongenerator
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
registry: ghcr.io
workdir: game/qgservice

docker-push-authservice:
name: Push auth service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -76,6 +95,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/authservice

docker-push-userservice:
name: Push user service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -93,6 +113,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice

docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -113,7 +134,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp, docker-push-qgservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:

questiongeneratorservice:
container_name: qgservice-${teamname:-defaultASW}
image: pelazas1/questiongenerator:latest
image: ghcr.io/arquisoft/wiq_en2a/questiongenerator:latest
profiles: ["dev", "prod"]
build: ./game/qgservice
depends_on:
Expand All @@ -52,8 +52,6 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
volumes:
- ./game/qgservice:/usr/src/questiongeneratorservice

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
Expand All @@ -64,14 +62,15 @@ services:
- mongodb
- userservice
- authservice
- questiongeneratorservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QG_SERVICE_URL: http://qgservice:8003
GQ_SERVICE_URL: http://questiongeneratorservice:8003

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
5 changes: 1 addition & 4 deletions game/qgservice/qg-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ app.use(express.json());
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb';
mongoose.connect(mongoUri);
// const openai = new OpenAI();
/*const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});*/
//const openai = new OpenAIApi(configuration);
//

async function executeSparqlQuery(query) {
try {
Expand Down
9 changes: 4 additions & 5 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ app.get('/health', (_req, res) => {
app.post('/login', async (req, res) => {
try {
// Forward the login request to the authentication service
console.log(authServiceUrl)
const authResponse = await axios.post(authServiceUrl+'/login', req.body);
res.json(authResponse.data);
} catch (error) {
Expand All @@ -44,12 +45,10 @@ app.post('/adduser', async (req, res) => {

app.get('/questionsGame', async (req, res) => {
try {
const response = await axios.get(qgServiceUrl+'/game');
const questions = response.data;
res.json(questions);

const response = await axios.get( qgServiceUrl+"/game");
res.json(response.data);
} catch (error) {

console.error(error);
res.status(500).json({ error: 'Internal server error' });
}
});
Expand Down
16 changes: 10 additions & 6 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@ defineFeature(feature, test => {
given('An unregistered user', async () => {
username = "pablo"
password = "pabloasw"
await expect(page).toClick("button", { text: "Don't have an account? Register here." });
await page.waitFor('button')
await page.click("button", {id: "registerButton"});
});

when('I fill the data in the form and press submit', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Add User' })
await page.type('input[name="username"]', username);
await page.type('input[name="password"]', password);
await page.click('button', { text: 'Add User' })
});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("div", { text: "User added successfully" });
then('A confirmation message should be shown in the screen', async () => {
const confirmationMessage = await page.waitForSelector('div',"#successUserAdd");

const messageText = await page.evaluate(confirmationMessage => confirmationMessage.innerText, confirmationMessage);
expect(messageText).toContain('User added successfully');
});
})

Expand Down
3 changes: 2 additions & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"prod": "serve -s build",
"test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!axios)/'",
"test:e2e": "start-server-and-test 'node e2e/test-environment-setup.js' http://localhost:8000/health prod 3000 \"cd e2e && jest\"",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"test-only:e2e":"cd e2e && jest"
},
"eslintConfig": {
"extends": [
Expand Down
38 changes: 0 additions & 38 deletions webapp/src/App.js

This file was deleted.

2 changes: 1 addition & 1 deletion webapp/src/components/AddUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AddUser = (props:ActionProps) => {
<button color="primary" onClick={props.goBack}>
{t('go_back')}
</button>
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" />
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" id='successUserAdd'/>
{error && (
<Snackbar open={!!error} autoHideDuration={6000} onClose={() => setError('')} message={`Error: ${error}`} />
)}
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/Init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const Init = (props:ActionProps) =>{
const { t } = useTranslation()
return (
<div>
<button className={'app-button'}
<button className={'app-button'} id='registerButton'
onClick={() => props.changeView(false)}>
{t('register')}
</button>
<button className={'app-button'}
<button className={'app-button'} id='loginButton'
onClick={() => props.changeView(true)}>
{t('login')}
</button>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import App from './App'
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
Expand Down
2 changes: 1 addition & 1 deletion webapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["./**/*.tsx"],
"include": ["./**/*.tsx", "src/index.tsx"],
"exclude": [
"node_modules/**/*"
]
Expand Down