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 all 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 …
MistzSoftware 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
MistzSoftware Mar 11, 2025
efc2f19
Merge branch 'dev' into tests
MistzSoftware Mar 11, 2025
651f8fb
fixed old tests for v0.2.0
MistzSoftware 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
MistzSoftware Mar 12, 2025
27a0f15
updating gitignore to not push the content of v_files on github
MistzSoftware Mar 12, 2025
33f4b4f
Merge pull request #26 from algosup/tests
Z2VvZ2Vv Mar 12, 2025
d570a79
Merge branch 'dev' into tests
MistzSoftware Mar 12, 2025
b1df762
fixed the error message that blocked tests for passing
MistzSoftware 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…
MistzSoftware Mar 14, 2025
378305f
readding the html
MistzSoftware Mar 14, 2025
b47d606
Revert "Merge branch 'dev' into tests and adding the host attribute t…
MistzSoftware Mar 14, 2025
d1ed7c6
fixing the build with react
MistzSoftware Mar 14, 2025
8f4fd8b
fixing the preview host in vite.config to be able to do tests using r…
MistzSoftware Mar 14, 2025
4194316
implemente e2e testing on render.com webpage
MistzSoftware Mar 14, 2025
aa2d21b
Create CI.yml
MistzSoftware Mar 14, 2025
68bbaff
Merge branch 'ci-cd' into tests
MistzSoftware 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
MistzSoftware Mar 14, 2025
0a9e1ca
adding a lorem ipsum for testing CI
MistzSoftware Mar 14, 2025
5eab8c9
Revert "adding a lorem ipsum for testing CI"
MistzSoftware Mar 14, 2025
678d607
fixing dependencies installation
MistzSoftware Mar 14, 2025
c994f45
fixing the build firectory + fixing the backend run test command
MistzSoftware Mar 14, 2025
49d6e27
trying to fix the missing jest depence issue
MistzSoftware Mar 14, 2025
0773c9c
try to fix jest running
MistzSoftware Mar 14, 2025
a631cc5
adding a lorem ipsum to test CI
MistzSoftware Mar 14, 2025
22939ce
Revert "adding a lorem ipsum to test CI"
MistzSoftware Mar 14, 2025
c9aed43
fixing mocha running
MistzSoftware Mar 14, 2025
16fce6e
try to fix frontend testing
MistzSoftware Mar 14, 2025
33198a4
fixing the workflow syntax issue
MistzSoftware Mar 14, 2025
2ed0ef2
removing chrome installation
MistzSoftware Mar 14, 2025
021f973
v0.4.0 - finished JSON parsing functions
Z2VvZ2Vv Mar 16, 2025
00eda24
trying to fix the test e2e execution
MistzSoftware Mar 17, 2025
5bbe5e2
try to fix the runner issue
MistzSoftware Mar 17, 2025
4959a34
try to fix the runner
MistzSoftware Mar 17, 2025
47f1f19
try to fix the issue again
MistzSoftware Mar 17, 2025
abb9c5c
trying again
MistzSoftware Mar 17, 2025
c9111aa
trying ti fix the runner again
MistzSoftware Mar 17, 2025
a4b2528
removing broken lines from the runner
MistzSoftware Mar 17, 2025
d792921
try to fix it again
MistzSoftware Mar 17, 2025
8821042
trying again
MistzSoftware Mar 17, 2025
b4585df
trying something
MistzSoftware Mar 17, 2025
9cc8008
try something
MistzSoftware Mar 17, 2025
d507352
removing ts-node/register
MistzSoftware Mar 17, 2025
cd5b0fa
trying something else
MistzSoftware Mar 17, 2025
8d07075
test something
MistzSoftware Mar 17, 2025
fe8a930
removing the this that didn't worked
MistzSoftware Mar 17, 2025
8e0ae9a
update dependencies
MistzSoftware Mar 17, 2025
3178530
test something
MistzSoftware Mar 17, 2025
042ce1d
test somethign elsse
MistzSoftware Mar 17, 2025
44d572f
maybe fixed the sitty issue
MistzSoftware Mar 17, 2025
7f46a7a
trying to fix the issue
MistzSoftware Mar 17, 2025
bb69fb5
removing unused dependencies + increasing the deployement time to 3mi…
MistzSoftware Mar 17, 2025
80a60e5
Merge branch 'dev' into tests
MistzSoftware Mar 17, 2025
fc37f41
fixed server export for backend tests
MistzSoftware Mar 17, 2025
1564309
trying to fix github actions
MistzSoftware Mar 17, 2025
3344a9b
fix the shitty code generate by chatgpt
MistzSoftware Mar 17, 2025
7251d84
reducing the delay
MistzSoftware Mar 18, 2025
7721cca
testing only on the dev branch pushes and all pullrequest on main con…
MistzSoftware Mar 18, 2025
5b28a26
Squashed commit of the following:
MistzSoftware Mar 18, 2025
177f67c
Merge branch 'dev' into tests
MistzSoftware Mar 18, 2025
3744078
removing files that shouldn't be pushed and added the folder to the g…
MistzSoftware 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
MistzSoftware Mar 26, 2025
d98431a
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
MistzSoftware Mar 26, 2025
65abbb7
fixing dependencies and deleted file
MistzSoftware Mar 26, 2025
9f611fb
fixing the tests naming and add the open port commnand for test using…
MistzSoftware Mar 26, 2025
688acab
fixing q removed link
MistzSoftware 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
MistzSoftware Mar 31, 2025
2d17134
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
MistzSoftware 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
MistzSoftware Mar 31, 2025
f805a29
Merge branch 'dev' of https://github.com/algosup/2024-2025-project-4-…
MistzSoftware 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-…
MistzSoftware 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
MistzSoftware 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!
31 changes: 30 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
.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
240 changes: 240 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
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 { 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) => {
const fieldExtensionMap = {
sdfFile: ['.sdf'],
verilogFile: ['.v']
};

// Check if the file field name is in the map
const fileExtension = extname(file.originalname).toLowerCase();
const allowedExtensions = fieldExtensionMap[file.fieldname];

if (allowedExtensions && allowedExtensions.includes(fileExtension)) {
cb(null, true);
} else {
req.fileValidationError = `Invalid file(s) format.`;
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 {
// verify if files are uploaded
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) {
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);
return res.status(400).send('The project already exists.');

} catch (error) {
try {
await fs.writeFile(join(projectJSON_Path), JSON.stringify(commonInstances, null, 2));
res.status(200).send('Files uploaded successfully.');

} catch (error) {
res.status(500).send('Error saving parsed JSON files.');
}
}

} catch (error) {
res.status(500).send('Error saving parsed JSON files.');
}

} catch (error) {
res.status(500).send('Unexpected server error.');
}
});

// Endpoint to show a error message if no project name is provided
app.get('/api/map', (req, res) => {
return res.status(400).send('Project name is required.');
});

// 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(400).send('Project not found.');
}
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('Project does not exist.');
}

// Delete file
await fs.unlink(projectPath);
res.send('File deleted successfully.');

} catch (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');

// Check if the directory exists
try {
await fs.access(directoryPath);
} catch (error) {
// Create the directory if it doesn't exist
await fs.mkdir(directoryPath, { recursive: true });
}

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

export const server = app.listen(PORT, () => {});
Loading
Loading