diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e3cdbee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +env: + NODE_VERSION: '18' + +jobs: + test-and-build: + name: Test & Build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install Scarb + uses: actions-rs/install@v0.1 + with: + crate: scarb + use-tool-cache: true + + - name: Install Starknet Foundry + uses: actions-rs/install@v0.1 + with: + crate: snforge + use-tool-cache: true + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Check formatting + run: yarn format:check + + - name: Lint frontend + run: yarn next:lint + working-directory: packages/nextjs + + - name: Check TypeScript types + run: yarn next:check-types + working-directory: packages/nextjs + + - name: Run frontend tests + run: yarn test:nextjs + working-directory: packages/nextjs + + - name: Compile contracts + run: yarn compile + working-directory: packages/snfoundry + + - name: Run contract tests + run: yarn test + working-directory: packages/snfoundry + + - name: Build frontend + run: yarn build + working-directory: packages/nextjs diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..94247c2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,41 @@ +name: Deploy + +on: + push: + branches: [ main ] + +env: + NODE_VERSION: '18' + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build frontend + run: yarn build + working-directory: packages/nextjs + + # Descomenta para deploy automático a Vercel + # - name: Deploy to Vercel + # uses: amondnet/vercel-action@v25 + # with: + # vercel-token: ${{ secrets.VERCEL_TOKEN }} + # vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} + # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + # working-directory: ./packages/nextjs diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..e30714d --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,110 @@ +name: Security & Code Quality + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + schedule: + # Ejecutar análisis de seguridad semanalmente + - cron: '0 2 * * 1' + +env: + NODE_VERSION: '18' + +jobs: + security-audit: + name: Security Audit + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run npm audit + run: yarn audit + continue-on-error: true + + - name: Run Snyk security scan + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --severity-threshold=high + continue-on-error: true + + code-quality: + name: Code Quality Analysis + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install Scarb + uses: actions-rs/install@v0.1 + with: + crate: scarb + use-tool-cache: true + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Check code formatting + run: yarn format:check + + - name: Lint frontend code + run: yarn next:lint + working-directory: packages/nextjs + + - name: Check TypeScript types + run: yarn next:check-types + working-directory: packages/nextjs + + - name: Run SonarCloud analysis + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.projectKey=your-project-key + -Dsonar.organization=your-organization + continue-on-error: true + + dependency-review: + name: Dependency Review + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Dependency Review + uses: actions/dependency-review-action@v4 + with: + fail-on-severity: moderate diff --git a/packages/nextjs/vitest.config.ts b/packages/nextjs/vitest.config.ts index 0744653..70f0716 100644 --- a/packages/nextjs/vitest.config.ts +++ b/packages/nextjs/vitest.config.ts @@ -1,9 +1,9 @@ +/// import { defineConfig } from "vitest/config"; -import path from "path"; import react from "@vitejs/plugin-react"; +import path from "path"; export default defineConfig({ - // @ts-ignore plugins: [react()], test: { environment: "jsdom", diff --git a/packages/snfoundry/contracts/Scarb.toml b/packages/snfoundry/contracts/Scarb.toml index 7b8bc68..798bd0b 100644 --- a/packages/snfoundry/contracts/Scarb.toml +++ b/packages/snfoundry/contracts/Scarb.toml @@ -13,7 +13,7 @@ openzeppelin_token = "2.0.0" [dev-dependencies] openzeppelin_utils = "2.0.0" openzeppelin_testing = "4.3.0" -snforge_std = "0.42.0" +snforge_std = "0.46.0" assert_macros = "2.11.4" [[target.starknet-contract]]