Skip to content

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 93 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
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 Mar 10, 2025
b63f4bc
Update sdfProccess.js
Z2VvZ2Vv Mar 11, 2025
1bfb64d
written test for API endpoints + adding package-lock and sdf_file to …
Mar 11, 2025
7c7d62d
v0.2.0 - Continue/almost finished backend
Z2VvZ2Vv Mar 11, 2025
af2b4c3
fixing a test name to fit with existing test cases
Mar 11, 2025
efc2f19
Merge branch 'dev' into tests
MistzSoftware Mar 11, 2025
651f8fb
fixed old tests for v0.2.0
Mar 12, 2025
34ca055
v0.2.1 - Issue fixed
Z2VvZ2Vv Mar 12, 2025
7a6f064
renaming test files to fit with the file architecture designed by the TL
Mar 12, 2025
27a0f15
updating gitignore to not push the content of v_files on github
Mar 12, 2025
33f4b4f
Merge pull request #26 from algosup/tests
Z2VvZ2Vv Mar 12, 2025
d570a79
Merge branch 'dev' into tests
Mar 12, 2025
b1df762
fixed the error message that blocked tests for passing
Mar 12, 2025
25c1bdf
v0.3.0 - Continue backend
Z2VvZ2Vv Mar 14, 2025
b4d71a4
Merge branch 'dev' into tests and adding the host attribute to the pr…
Mar 14, 2025
378305f
readding the html
Mar 14, 2025
b47d606
Revert "Merge branch 'dev' into tests and adding the host attribute t…
Mar 14, 2025
d1ed7c6
fixing the build with react
Mar 14, 2025
8f4fd8b
fixing the preview host in vite.config to be able to do tests using r…
Mar 14, 2025
4194316
implemente e2e testing on render.com webpage
Mar 14, 2025
aa2d21b
Create CI.yml
MistzSoftware Mar 14, 2025
68bbaff
Merge branch 'ci-cd' into tests
Mar 14, 2025
758e472
Merge pull request #40 from algosup/MistzSoftware-patch-1
MistzSoftware Mar 14, 2025
fd87728
fixed branch and commands for the ci/cd
Mar 14, 2025
0a9e1ca
adding a lorem ipsum for testing CI
Mar 14, 2025
5eab8c9
Revert "adding a lorem ipsum for testing CI"
Mar 14, 2025
678d607
fixing dependencies installation
Mar 14, 2025
c994f45
fixing the build firectory + fixing the backend run test command
Mar 14, 2025
49d6e27
trying to fix the missing jest depence issue
Mar 14, 2025
0773c9c
try to fix jest running
Mar 14, 2025
a631cc5
adding a lorem ipsum to test CI
Mar 14, 2025
22939ce
Revert "adding a lorem ipsum to test CI"
Mar 14, 2025
c9aed43
fixing mocha running
Mar 14, 2025
16fce6e
try to fix frontend testing
Mar 14, 2025
33198a4
fixing the workflow syntax issue
Mar 14, 2025
2ed0ef2
removing chrome installation
Mar 14, 2025
021f973
v0.4.0 - finished JSON parsing functions
Z2VvZ2Vv Mar 16, 2025
00eda24
trying to fix the test e2e execution
Mar 17, 2025
5bbe5e2
try to fix the runner issue
Mar 17, 2025
4959a34
try to fix the runner
Mar 17, 2025
47f1f19
try to fix the issue again
Mar 17, 2025
abb9c5c
trying again
Mar 17, 2025
c9111aa
trying ti fix the runner again
Mar 17, 2025
a4b2528
removing broken lines from the runner
Mar 17, 2025
d792921
try to fix it again
Mar 17, 2025
8821042
trying again
Mar 17, 2025
b4585df
trying something
Mar 17, 2025
9cc8008
try something
Mar 17, 2025
d507352
removing ts-node/register
Mar 17, 2025
cd5b0fa
trying something else
Mar 17, 2025
8d07075
test something
Mar 17, 2025
fe8a930
removing the this that didn't worked
Mar 17, 2025
8e0ae9a
update dependencies
Mar 17, 2025
3178530
test something
Mar 17, 2025
042ce1d
test somethign elsse
Mar 17, 2025
44d572f
maybe fixed the sitty issue
Mar 17, 2025
7f46a7a
trying to fix the issue
Mar 17, 2025
bb69fb5
removing unused dependencies + increasing the deployement time to 3mi…
Mar 17, 2025
80a60e5
Merge branch 'dev' into tests
Mar 17, 2025
fc37f41
fixed server export for backend tests
Mar 17, 2025
1564309
trying to fix github actions
Mar 17, 2025
3344a9b
fix the shitty code generate by chatgpt
Mar 17, 2025
7251d84
reducing the delay
Mar 18, 2025
7721cca
testing only on the dev branch pushes and all pullrequest on main con…
Mar 18, 2025
5b28a26
Squashed commit of the following:
Mar 18, 2025
177f67c
Merge branch 'dev' into tests
Mar 18, 2025
3744078
removing files that shouldn't be pushed and added the folder to the g…
Mar 18, 2025
543a81a
v0.5.0 - Frontend + end of backend
Z2VvZ2Vv Mar 25, 2025
5d04343
v0.5.1 - Responsive issue
Z2VvZ2Vv Mar 26, 2025
7e4a51a
v0.5.2 - Backend enhanced
Z2VvZ2Vv Mar 26, 2025
e88d95f
fixing packages and scripts command
Mar 26, 2025
d98431a
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Mar 26, 2025
65abbb7
fixing dependencies and deleted file
Mar 26, 2025
9f611fb
fixing the tests naming and add the open port commnand for test using…
Mar 26, 2025
688acab
fixing q removed link
Mar 26, 2025
a73f955
v1.0.0 - Fixes + optimizing
Z2VvZ2Vv Mar 31, 2025
8f11ab3
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv Mar 31, 2025
e8d14a6
v1.0.1 - Enhanced way to use the app
Z2VvZ2Vv Mar 31, 2025
db6c2d6
v1.0.1 - Stable repo
Z2VvZ2Vv Mar 31, 2025
aab00d6
Merge branch 'main' into dev
Z2VvZ2Vv Mar 31, 2025
5e925b1
fixing backend test
Mar 31, 2025
2d17134
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Mar 31, 2025
2001539
v1.0.2 - Fix issue in /api/list
Z2VvZ2Vv Mar 31, 2025
a7602ca
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv Mar 31, 2025
349af6d
fixing the typo in the page name in tests
Mar 31, 2025
f805a29
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Mar 31, 2025
639f2af
v1.1.0 - Feature + Resolve PR issues
Z2VvZ2Vv Mar 31, 2025
b753afc
v1.2.0 - enhanced and more reliable animations
Z2VvZ2Vv Mar 31, 2025
72fb75b
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Apr 1, 2025
ca1b3d3
v1.2.1 - Resolving PR issues
Z2VvZ2Vv Apr 1, 2025
50eaec0
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
Z2VvZ2Vv Apr 1, 2025
8bc9880
v1.2.2 - Resolving PR issues
Z2VvZ2Vv Apr 1, 2025
68cf59d
fixing test for delete fitting with the API Documentation
Apr 1, 2025
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
105 changes: 105 additions & 0 deletions .github/workflows/CI.yml
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!
32 changes: 31 additions & 1 deletion .gitignore
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
247 changes: 247 additions & 0 deletions backend/index.js
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
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
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
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);

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');
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);
res.status(500).send('Error saving parsed JSON files.');
}
}

} catch (error) {
console.log('Error saving parsed JSON files:', error);
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);
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);
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);
res.status(500).send('Error listing files.');
}
});

// Part of production code
// 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}`);
});
Loading
Loading