-
Notifications
You must be signed in to change notification settings - Fork 2
Merge dev to main #51
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
Merged
Changes from 78 commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
014395b
v0.1.0 - Created backend & created frontend base
Z2VvZ2Vv b63f4bc
Update sdfProccess.js
Z2VvZ2Vv 1bfb64d
written test for API endpoints + adding package-lock and sdf_file to …
7c7d62d
v0.2.0 - Continue/almost finished backend
Z2VvZ2Vv af2b4c3
fixing a test name to fit with existing test cases
efc2f19
Merge branch 'dev' into tests
MistzSoftware 651f8fb
fixed old tests for v0.2.0
34ca055
v0.2.1 - Issue fixed
Z2VvZ2Vv 7a6f064
renaming test files to fit with the file architecture designed by the TL
27a0f15
updating gitignore to not push the content of v_files on github
33f4b4f
Merge pull request #26 from algosup/tests
Z2VvZ2Vv d570a79
Merge branch 'dev' into tests
b1df762
fixed the error message that blocked tests for passing
25c1bdf
v0.3.0 - Continue backend
Z2VvZ2Vv b4d71a4
Merge branch 'dev' into tests and adding the host attribute to the pr…
378305f
readding the html
b47d606
Revert "Merge branch 'dev' into tests and adding the host attribute t…
d1ed7c6
fixing the build with react
8f4fd8b
fixing the preview host in vite.config to be able to do tests using r…
4194316
implemente e2e testing on render.com webpage
aa2d21b
Create CI.yml
MistzSoftware 68bbaff
Merge branch 'ci-cd' into tests
758e472
Merge pull request #40 from algosup/MistzSoftware-patch-1
MistzSoftware fd87728
fixed branch and commands for the ci/cd
0a9e1ca
adding a lorem ipsum for testing CI
5eab8c9
Revert "adding a lorem ipsum for testing CI"
678d607
fixing dependencies installation
c994f45
fixing the build firectory + fixing the backend run test command
49d6e27
trying to fix the missing jest depence issue
0773c9c
try to fix jest running
a631cc5
adding a lorem ipsum to test CI
22939ce
Revert "adding a lorem ipsum to test CI"
c9aed43
fixing mocha running
16fce6e
try to fix frontend testing
33198a4
fixing the workflow syntax issue
2ed0ef2
removing chrome installation
021f973
v0.4.0 - finished JSON parsing functions
Z2VvZ2Vv 00eda24
trying to fix the test e2e execution
5bbe5e2
try to fix the runner issue
4959a34
try to fix the runner
47f1f19
try to fix the issue again
abb9c5c
trying again
c9111aa
trying ti fix the runner again
a4b2528
removing broken lines from the runner
d792921
try to fix it again
8821042
trying again
b4585df
trying something
9cc8008
try something
d507352
removing ts-node/register
cd5b0fa
trying something else
8d07075
test something
fe8a930
removing the this that didn't worked
8e0ae9a
update dependencies
3178530
test something
042ce1d
test somethign elsse
44d572f
maybe fixed the sitty issue
7f46a7a
trying to fix the issue
bb69fb5
removing unused dependencies + increasing the deployement time to 3mi…
80a60e5
Merge branch 'dev' into tests
fc37f41
fixed server export for backend tests
1564309
trying to fix github actions
3344a9b
fix the shitty code generate by chatgpt
7251d84
reducing the delay
7721cca
testing only on the dev branch pushes and all pullrequest on main con…
5b28a26
Squashed commit of the following:
177f67c
Merge branch 'dev' into tests
3744078
removing files that shouldn't be pushed and added the folder to the g…
543a81a
v0.5.0 - Frontend + end of backend
Z2VvZ2Vv 5d04343
v0.5.1 - Responsive issue
Z2VvZ2Vv 7e4a51a
v0.5.2 - Backend enhanced
Z2VvZ2Vv e88d95f
fixing packages and scripts command
d98431a
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
65abbb7
fixing dependencies and deleted file
9f611fb
fixing the tests naming and add the open port commnand for test using…
688acab
fixing q removed link
a73f955
v1.0.0 - Fixes + optimizing
Z2VvZ2Vv 8f11ab3
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv e8d14a6
v1.0.1 - Enhanced way to use the app
Z2VvZ2Vv db6c2d6
v1.0.1 - Stable repo
Z2VvZ2Vv aab00d6
Merge branch 'main' into dev
Z2VvZ2Vv 5e925b1
fixing backend test
2d17134
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
2001539
v1.0.2 - Fix issue in /api/list
Z2VvZ2Vv a7602ca
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv 349af6d
fixing the typo in the page name in tests
f805a29
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
639f2af
v1.1.0 - Feature + Resolve PR issues
Z2VvZ2Vv b753afc
v1.2.0 - enhanced and more reliable animations
Z2VvZ2Vv 72fb75b
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
ca1b3d3
v1.2.1 - Resolving PR issues
Z2VvZ2Vv 50eaec0
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv 8bc9880
v1.2.2 - Resolving PR issues
Z2VvZ2Vv 68cf59d
fixing test for delete fitting with the API Documentation
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: [ "dev" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
paths: | ||
- 'frontend/**' | ||
- 'backend/**' | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
|
||
# Set up Node.js environment | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '23.6.0' # You can specify the Node.js version you need | ||
|
||
# Runs a single command using the runners shell | ||
- name: CI starting | ||
run: | | ||
echo ⏳ CI testing begin... | ||
|
||
- name: Install Dependencies | ||
run: | | ||
echo ⏳ install frontend dependencies... | ||
cd ./frontend/ | ||
npm install | ||
echo ✅ frontend dependencies installed! | ||
echo ⏳ install backend dependencies... | ||
cd ../backend/ | ||
npm install | ||
echo ✅ backend dependencies installed! | ||
|
||
- name: Building | ||
run: | | ||
echo ⏳ Building... | ||
cd ./frontend/ | ||
npm run build | ||
echo ✅ Built! | ||
|
||
frontend-testing: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
# Deploy Render app | ||
- name: Deploy Application | ||
env: | ||
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} | ||
run: | | ||
echo ⏳ Frontend testing is setting up... | ||
if [[ -z "$deploy_url" ]]; then | ||
echo "❌ Error: deploy_url is not set!" | ||
exit 1 | ||
fi | ||
echo "⏳ Triggering deployment..." | ||
curl -v "$deploy_url" | ||
sleep 60 | ||
echo ✅ Application deployed! | ||
|
||
- name: Run e2e testing | ||
run: | | ||
echo ⏳ frontend e2e testing begin... | ||
cd ./frontend/ | ||
npm i | ||
npm run test:e2e | ||
echo ✅ frontend e2e testing ended! | ||
|
||
backend-testing: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Run API e2e testing | ||
run: | | ||
echo ⏳ API testing begin... | ||
cd ./backend/ | ||
npm i | ||
npm run test:e2e | ||
echo ✅ backend e2e testing ended! |
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,2 +1,32 @@ | ||
.DS_Store | ||
.vscode/ | ||
.vscode/ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
temp_user_data | ||
package-lock.json | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# API files | ||
parsed_files | ||
.env |
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,247 @@ | ||
import express from 'express'; | ||
import multer from 'multer'; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname, join, extname } from 'path'; | ||
import { promises as fs } from 'fs'; | ||
import cors from 'cors'; | ||
// import { resolve } from 'path'; | ||
|
||
import { parseSDF } from './src/sdfProcess.js'; | ||
import { parseVerilog } from './src/vProcess.js'; | ||
import { mergeJsonForD3 } from './src/mergeVerilogSdf.js'; | ||
|
||
export const app = express(); | ||
const port = 3001; | ||
|
||
// Get absolute path | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
// Authorize CORS | ||
app.use(cors()); | ||
app.use(express.json()); | ||
|
||
// Configure multer for handling SDF file upload | ||
// Store file in memory, not on disk | ||
const storage = multer.memoryStorage(); | ||
|
||
// Filter to verify file type | ||
const upload = multer({ | ||
storage: storage, | ||
fileFilter: (req, file, cb) => { | ||
// Définition des extensions autorisées PAR CHAMP | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const fieldExtensionMap = { | ||
sdfFile: ['.sdf'], | ||
verilogFile: ['.v'] | ||
}; | ||
|
||
const fileExtension = extname(file.originalname).toLowerCase(); | ||
const allowedExtensions = fieldExtensionMap[file.fieldname]; | ||
|
||
// Vérifier si l'extension correspond au bon champ | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (allowedExtensions && allowedExtensions.includes(fileExtension)) { | ||
cb(null, true); | ||
} else { | ||
req.fileValidationError = `Invalid file type for ${file.fieldname}, only ${allowedExtensions?.join(', ')} files are allowed!`; | ||
cb(null, false); | ||
} | ||
}, | ||
}); | ||
|
||
|
||
// Endpoint for uploading and parsing SDF & Verilog file | ||
app.post('/api/upload', upload.fields([{ name: 'sdfFile' }, { name: 'verilogFile' }]), async (req, res) => { | ||
try { | ||
// Vérification des erreurs de validation de fichier | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (req.fileValidationError) { | ||
return res.status(400).send(req.fileValidationError); | ||
} | ||
|
||
const sdfFile = req.files?.['sdfFile']?.[0]; | ||
const verilogFile = req.files?.['verilogFile']?.[0]; | ||
|
||
// Check if files are uploaded | ||
if (!sdfFile || !verilogFile) { | ||
return res.status(400).send('Both SDF and Verilog files must be uploaded.'); | ||
} | ||
|
||
const sdfContent = sdfFile.buffer.toString('utf-8').trim(); | ||
const verilogContent = verilogFile.buffer.toString('utf-8').trim(); | ||
|
||
if (!sdfContent || !verilogContent) { | ||
return res.status(400).send('One or both uploaded files are empty.'); | ||
} | ||
|
||
// Parse SDF and Verilog files | ||
let sdfData, verilogData, commonInstances; | ||
try { | ||
sdfData = parseSDF(sdfContent); | ||
} catch (error) { | ||
return res.status(500).send('Error parsing SDF file.'); | ||
} | ||
|
||
try { | ||
verilogData = parseVerilog(verilogContent); | ||
} catch (error) { | ||
return res.status(500).send('Error parsing Verilog file.'); | ||
} | ||
|
||
try { | ||
commonInstances = mergeJsonForD3(verilogData, sdfData); | ||
} catch (error) { | ||
console.log('Error merging files:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return res.status(500).send('Error merging files.'); | ||
} | ||
|
||
// Save parsed SDF and Verilog files | ||
try { | ||
const projectName = req.body.projectName; | ||
if (!projectName) { | ||
return res.status(400).send('Project name is required.'); | ||
} | ||
|
||
//try if folder 'parsed_files' exists | ||
try { | ||
await fs.access(join(__dirname, 'parsed_files')); | ||
} catch (error) { | ||
try { | ||
await fs.mkdir(join(__dirname, 'parsed_files')); | ||
} catch (error) { | ||
return res.status(500).send('Error creating directory.'); | ||
} | ||
} | ||
|
||
const projectJSON_Path = join(__dirname, 'parsed_files', `${projectName}.json`); | ||
|
||
//check if files exists | ||
try { | ||
// check if file exists | ||
await fs.access(projectJSON_Path); | ||
console.error('Project already exists'); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return res.status(400).send('Project already exists'); | ||
|
||
} catch (error) { | ||
try { | ||
await fs.writeFile(join(projectJSON_Path), JSON.stringify(commonInstances, null, 2)); | ||
res.send('SDF and Verilog files successfully parsed and merged.'); | ||
|
||
} catch (error) { | ||
console.error('Error saving parsed JSON files:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.status(500).send('Error saving parsed JSON files.'); | ||
} | ||
} | ||
|
||
} catch (error) { | ||
console.log('Error saving parsed JSON files:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.status(500).send('Error saving parsed JSON files.'); | ||
} | ||
|
||
} catch (error) { | ||
res.status(500).send('Unexpected server error.'); | ||
} | ||
}); | ||
|
||
|
||
// Endpoint API for sending parsed SDF file | ||
app.get('/api/map/:projectName', async (req, res) => { | ||
try { | ||
const projectName = req.params.projectName; | ||
if (!projectName) { | ||
return res.status(400).send('Project name is required.'); | ||
} | ||
|
||
// Construct the file path using string concatenation | ||
const jsonFilePath = join(__dirname, 'parsed_files', `${projectName}.json`); | ||
|
||
// Check if the file exists | ||
await fs.access(jsonFilePath); | ||
|
||
// Read the file content | ||
const jsonData = await fs.readFile(jsonFilePath, 'utf-8'); | ||
res.json(JSON.parse(jsonData)); | ||
|
||
} catch (error) { | ||
if (error.code === 'ENOENT') { | ||
// File does not exist | ||
return res.status(404).send('File not found.'); | ||
} | ||
console.error('Error reading parsed SDF JSON file:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.status(500).send('Error reading parsed SDF JSON file.'); | ||
} | ||
}); | ||
|
||
// Endpoint to delete a parsed SDF JSON file | ||
app.delete('/api/delete-project/:projectName', async (req, res) => { | ||
try { | ||
const projectName = req.params.projectName; | ||
|
||
// Validate projectName | ||
if (!projectName || typeof projectName !== 'string') { | ||
return res.status(400).send('Invalid project name.'); | ||
} | ||
|
||
const projectPath = join(__dirname, 'parsed_files', `${projectName}.json`); | ||
|
||
try { | ||
// verify if file exists | ||
await fs.access(projectPath); | ||
} catch (err) { | ||
// file does not exist | ||
return res.status(404).send('File does not exist.'); | ||
} | ||
|
||
// Delete file | ||
await fs.unlink(projectPath); | ||
res.send('File deleted successfully.'); | ||
|
||
} catch (error) { | ||
console.error('Error deleting file:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.status(500).send('Error deleting file, please try again later.'); | ||
} | ||
}); | ||
|
||
|
||
// Endpoint to list all SDF files | ||
app.get('/api/list', async (req, res) => { | ||
try { | ||
const directoryPath = join(__dirname, 'parsed_files'); | ||
const entries = await fs.readdir(directoryPath, { withFileTypes: true }); | ||
|
||
// Prepare an array to hold file information | ||
const filesInfo = []; | ||
|
||
// Iterate over entries to get file names and creation dates | ||
for (const entry of entries) { | ||
if (entry.isFile() && entry.name.endsWith('.json')) { | ||
const filePath = join(directoryPath, entry.name); | ||
const stats = await fs.stat(filePath); | ||
|
||
// Format the date to only include the date part (YYYY-MM-DD) | ||
const createdDate = stats.birthtime.toISOString().split('T')[0]; | ||
|
||
filesInfo.push({ | ||
name: entry.name.replace('.json', ''), | ||
createdDate | ||
}); | ||
} | ||
} | ||
|
||
res.json(filesInfo); | ||
} catch (error) { | ||
console.error('Error listing files:', error); | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.status(500).send('Error listing files.'); | ||
} | ||
}); | ||
|
||
// Part of production code | ||
MaximeTAlgosup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// app.use(express.static(join(__dirname, '../frontend/'))); | ||
|
||
// app.get('*', (req, res) => { | ||
// res.sendFile(resolve(__dirname, '../frontend/', 'index.html')); | ||
// }); | ||
// | ||
|
||
export const server = app.listen(port, () => { | ||
console.log(`Backend launched on http://localhost:${port}`); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
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.