Skip to content
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
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report
about: Create a report to help us improve
title: '[BUG] '
labels: 'bug'
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
- Node.js version [e.g. 20.x]

**Additional context**
Add any other context about the problem here.

**Test Status**
- [ ] Tests are passing locally
- [ ] New tests added for bug fix
42 changes: 42 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Pull Request
about: Describe the changes in your pull request
title: ''
labels: ''
assignees: ''

---

## 📋 Description
Brief description of the changes

## 🔄 Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring

## 🧪 Testing
- [ ] Tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have checked that the CI pipeline passes

## 📝 Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published in downstream modules

## 🔗 Related Issues
Fixes #(issue number)

## 📸 Screenshots (if appropriate)
Add screenshots to help explain your changes

## 🔍 Additional Notes
Add any other notes about the pull request here.
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
push:
branches: [ main, develop, feature/github-pipeline ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint (non-blocking)
run: npm run lint || echo "⚠️ Linting issues found but continuing with build..."
continue-on-error: true

- name: Run type checking
run: npx tsc --noEmit

- name: Run tests
run: npx vitest run --reporter=verbose

- name: Build project
run: npm run build

- name: Test Preview
run: |
npm run preview &
sleep 5
curl -f http://localhost:4173 || echo "Preview server test failed"
pkill -f "vite preview" || true

security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run security audit
run: npm audit --audit-level=moderate || echo "⚠️ Security vulnerabilities found"
continue-on-error: true

build-and-deploy:
runs-on: ubuntu-latest
needs: [test, security]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build for production
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-files-${{ github.sha }}
path: dist/
retention-days: 30

- name: Deploy Preview
run: echo "🚀 Ready for deployment to production!"
100 changes: 100 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Pull Request

on:
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting
id: lint
run: npm run lint
continue-on-error: true

- name: Run tests
id: test
run: |
npx vitest run --reporter=verbose > test-results.txt 2>&1
echo "exit_code=$?" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Run build
id: build
run: npm run build
continue-on-error: true

- name: Read test results
id: test-results
if: always()
run: |
if [ -f test-results.txt ]; then
echo "test_output<<EOF" >> $GITHUB_OUTPUT
cat test-results.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi

- name: Comment PR with results
uses: thollander/actions-comment-pull-request@v2
if: always()
with:
message: |
## 📊 Pull Request Check Results

| Check | Status | Details |
|-------|--------|---------|
| Linting | ${{ steps.lint.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.lint.outcome == 'success' && 'No linting errors' || 'Linting errors found' }} |
| Tests | ${{ steps.test.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.test.outcome == 'success' && 'All tests passed' || 'Some tests failed' }} |
| Build | ${{ steps.build.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.build.outcome == 'success' && 'Build successful' || 'Build failed' }} |

${{ steps.test.outcome == 'failure' && format('
<details>
<summary>🔍 Test Output (Click to expand)</summary>

```
{0}
```
</details>', steps.test-results.outputs.test_output) || '' }}

${{ (steps.lint.outcome == 'failure' || steps.test.outcome == 'failure' || steps.build.outcome == 'failure') && '
### ❌ Some checks failed

Please fix the issues above before merging. You can run the following commands locally:
- `npm run lint` - Check for linting errors
- `npm test` - Run tests
- `npm run build` - Test the build
' || '
### ✅ All checks passed!

Great work! This PR is ready for review. 🚀
' }}

---
<sub>🤖 Automated check by GitHub Actions</sub>
comment_tag: pr-check

- name: Fail workflow if any check failed
if: steps.lint.outcome == 'failure' || steps.test.outcome == 'failure' || steps.build.outcome == 'failure'
run: |
echo "❌ One or more checks failed"
echo "Lint: ${{ steps.lint.outcome }}"
echo "Test: ${{ steps.test.outcome }}"
echo "Build: ${{ steps.build.outcome }}"
exit 1
108 changes: 108 additions & 0 deletions .github/workflows/test-with-comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Test with Detailed Comments

on:
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
checks: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting with output capture
id: lint
run: |
echo "lint_output<<EOF" >> $GITHUB_OUTPUT
npm run lint 2>&1 || echo "LINT_FAILED=true" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Run tests with output capture
id: test
run: |
echo "test_output<<EOF" >> $GITHUB_OUTPUT
npx vitest run --reporter=verbose 2>&1 | tee test_output.txt
if [ ${PIPESTATUS[0]} -ne 0 ]; then
echo "TEST_FAILED=true" >> $GITHUB_OUTPUT
echo "$(cat test_output.txt)" >> $GITHUB_OUTPUT
else
echo "TEST_PASSED=true" >> $GITHUB_OUTPUT
echo "$(cat test_output.txt | tail -10)" >> $GITHUB_OUTPUT
fi
echo "EOF" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Run build with output capture
id: build
run: |
echo "build_output<<EOF" >> $GITHUB_OUTPUT
npm run build 2>&1 || echo "BUILD_FAILED=true" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Comment PR with detailed results
uses: thollander/actions-comment-pull-request@v2
with:
message: |
## 🔍 Pull Request Detailed Check Results

### Linting Results
${{ env.LINT_FAILED == 'true' && '❌ **Linting Failed**' || '✅ **Linting Passed**' }}

${{ env.LINT_FAILED == 'true' && format('```
{0}
```', steps.lint.outputs.lint_output) || '_No linting issues found._' }}

### Test Results
${{ env.TEST_FAILED == 'true' && '❌ **Tests Failed**' || '✅ **Tests Passed**' }}

<details>
<summary>Click to see test output</summary>

```
${{ steps.test.outputs.test_output }}
```
</details>

### Build Results
${{ env.BUILD_FAILED == 'true' && '❌ **Build Failed**' || '✅ **Build Passed**' }}

${{ env.BUILD_FAILED == 'true' && format('```
{0}
```', steps.build.outputs.build_output) || '_Build completed successfully._' }}

---

${{ (env.LINT_FAILED == 'true' || env.TEST_FAILED == 'true' || env.BUILD_FAILED == 'true') && '### ⚠️ Action Required
Please address the failing checks above before merging this PR.' || '### 🎉 All Checks Passed!
This PR is ready to be reviewed and merged.' }}

comment_tag: detailed-pr-check

- name: Set environment variables for next steps
run: |
echo "LINT_FAILED=${{ steps.lint.outputs.LINT_FAILED }}" >> $GITHUB_ENV
echo "TEST_FAILED=${{ steps.test.outputs.TEST_FAILED }}" >> $GITHUB_ENV
echo "BUILD_FAILED=${{ steps.build.outputs.BUILD_FAILED }}" >> $GITHUB_ENV

- name: Fail workflow if any step failed
if: env.LINT_FAILED == 'true' || env.TEST_FAILED == 'true' || env.BUILD_FAILED == 'true'
run: |
echo "One or more checks failed. See PR comment for details."
exit 1
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SecCodeSmith Frontend Portfolio

[![CI](https://github.com/SecCodeSmith/SecCodeSmith-frontend/actions/workflows/ci.yml/badge.svg)](https://github.com/SecCodeSmith/SecCodeSmith-frontend/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Version](https://img.shields.io/badge/Version-0.2.0-blue.svg)](https://github.com/SecCodeSmith/SecCodeSmith-frontend/releases)
[![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/)
Expand Down
Loading