Update CI/CD workflow to restore pnpm cache #40
This file contains 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
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
static-code-analysis: | |
name: Static Code Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
id: cache-pnpm | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm- | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run ESLint | |
run: pnpm run lint | |
test-automation: | |
name: Test Automation | |
runs-on: ubuntu-latest | |
needs: static-code-analysis | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build application | |
run: pnpm run build | |
- name: Start server | |
run: pnpm run start & | |
- name: Wait for server to start | |
run: npx wait-on http://localhost:3000 | |
- name: Run Cypress tests | |
run: npx cypress run --e2e | |
performance-testing: | |
name: Performance Testing | |
runs-on: ubuntu-latest | |
needs: test-automation | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build application | |
run: pnpm run build | |
- name: Start server | |
run: pnpm run start & | |
- name: Wait for server to start | |
run: npx wait-on http://localhost:3000 | |
- name: Run k6 local test | |
uses: grafana/k6-action@v0.3.1 | |
with: | |
filename: __tests__/performance/test.js | |
flags: --vus 50 --duration 10s | |
security-testing: | |
name: Security Testing | |
runs-on: ubuntu-latest | |
needs: performance-testing | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- name: Install OWASP ZAP | |
uses: zaproxy/action-full-scan@v0.5.0 | |
with: | |
target: 'http://localhost:3000' | |
reporting: | |
name: Reporting | |
runs-on: ubuntu-latest | |
needs: [test-automation, performance-testing, security-testing] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Generate Cypress testing report | |
run: npx mochawesome-merge "cypress/reports/*.json" > report.json && npx marge report.json --reportFilename "testing_report" --reportTitle "Cypress Report" --reportPageTitle "Cypress Report" | |
- name: Upload Cypress test reports | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress-reports | |
path: mochawesome-report | |
- name: Upload k6 performance reports | |
uses: actions/upload-artifact@v3 | |
with: | |
name: k6-reports | |
path: path/to/k6-reports | |
- name: Generate consolidated report | |
run: | | |
# Assuming you have a script or tool to merge different test reports | |
pnpm run generate-consolidated-report | |
- name: Upload consolidated report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: consolidated-report | |
path: path/to/consolidated-report | |
test-management: | |
name: Test Management | |
runs-on: ubuntu-latest | |
needs: reporting | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Upload test results to Test Management Tool | |
run: | | |
# Replace with actual commands to upload to your test management tool | |
curl -X POST -H "Content-Type: application/json" -d @path/to/consolidated-report.json http://test-management-tool/api/upload | |
deployment: | |
name: Deployment | |
runs-on: ubuntu-latest | |
needs: test-management | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Restore pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm | |
key: ${{ needs.static-code-analysis.outputs.cache-pnpm }} | |
- name: Deploy to production | |
run: pnpm run deploy |