Setting up test scripts in CI/CD #22
This file contains hidden or 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: VisionIndex CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| lint-secrets-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout the repository | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| # 2. Setup Node.js | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| # 3. Install dependencies | |
| - name: Install Dependencies | |
| run: npm install | |
| working-directory: ./app | |
| # 4. Run ESLint | |
| - name: Run Linter | |
| run: npm run lint | |
| working-directory: ./app | |
| # 5. Secret scan (Gitleaks) | |
| - name: Run Secret Scan (Gitleaks) | |
| run: | | |
| curl -sL https://github.com/zricethezav/gitleaks/releases/download/v8.16.1/gitleaks_8.16.1_linux_x64.tar.gz | tar xz | |
| ./gitleaks detect --redact --exit-code=1 | |
| # 6. Run tests (with env vars from GitHub secrets) | |
| - name: Run Tests | |
| env: | |
| MONGO_URI: ${{ secrets.MONGO_URI }} | |
| JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| NODE_ENV: test | |
| run: npm test | |
| working-directory: ./app |