name: Lint & Type Check on: push: branches: [ 'main' ] pull_request: branches: [ '*' ] workflow_dispatch: jobs: lint: name: Lint ${{ matrix.name }} runs-on: ubuntu-latest permissions: pull-requests: write contents: read strategy: fail-fast: false matrix: include: - name: api-rate-limiter type: python path: PROJECTS/advanced/api-rate-limiter - name: dns-lookup type: python path: PROJECTS/beginner/dns-lookup - name: keylogger type: python path: PROJECTS/beginner/keylogger - name: docker-security-audit type: go path: PROJECTS/beginner/docker-security-audit - name: bug-bounty-platform-frontend type: biome path: PROJECTS/advanced/bug-bounty-platform/frontend - name: c2-beacon-frontend type: biome path: PROJECTS/beginner/c2-beacon/frontend - name: api-security-scanner-frontend type: biome path: PROJECTS/intermediate/api-security-scanner/frontend - name: siem-dashboard-frontend type: biome path: PROJECTS/intermediate/siem-dashboard/frontend - name: encrypted-p2p-chat-frontend type: biome path: PROJECTS/advanced/encrypted-p2p-chat/frontend - name: fullstack-template-frontend type: biome path: TEMPLATES/fullstack-template/frontend defaults: run: working-directory: ${{ matrix.path }} steps: - name: Checkout code uses: actions/checkout@v4 # Python Setup - name: Set up Python if: matrix.type == 'python' uses: actions/setup-python@v5 with: python-version: '3.12' - name: Cache pip dependencies if: matrix.type == 'python' uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.name }}-${{ hashFiles(format('{0}/pyproject.toml', matrix.path)) }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.name }}- ${{ runner.os }}-pip- - name: Install Python dependencies if: matrix.type == 'python' run: | python -m pip install --upgrade pip pip install -e ".[dev]" # Biome Setup - name: Setup Node.js if: matrix.type == 'biome' uses: actions/setup-node@v4 with: node-version: '20' - name: Setup pnpm if: matrix.type == 'biome' uses: pnpm/action-setup@v4 with: version: latest - name: Cache pnpm store if: matrix.type == 'biome' uses: actions/cache@v4 with: path: ~/.local/share/pnpm/store/v10 key: ${{ runner.os }}-pnpm-${{ matrix.name }}-${{ hashFiles(format('{0}/pnpm-lock.yaml', matrix.path)) }} restore-keys: | ${{ runner.os }}-pnpm-${{ matrix.name }}- ${{ runner.os }}-pnpm- - name: Install frontend dependencies if: matrix.type == 'biome' run: pnpm install --frozen-lockfile # Go Setup - name: Setup Go if: matrix.type == 'go' uses: actions/setup-go@v5 with: go-version: '1.21' cache-dependency-path: ${{ matrix.path }}/go.sum # Python Linting - name: Run pylint if: matrix.type == 'python' id: pylint run: | echo "Running pylint..." if pylint . > pylint-output.txt 2>&1; then echo "PYLINT_PASSED=true" >> $GITHUB_ENV echo "No pylint errors found!" else echo "PYLINT_PASSED=false" >> $GITHUB_ENV echo "Pylint found issues!" fi cat pylint-output.txt continue-on-error: true - name: Run ruff if: matrix.type == 'python' id: ruff run: | echo "Running ruff check..." if ruff check . > ruff-output.txt 2>&1; then echo "RUFF_PASSED=true" >> $GITHUB_ENV echo "No ruff errors found!" else echo "RUFF_PASSED=false" >> $GITHUB_ENV echo "Ruff found issues" fi cat ruff-output.txt continue-on-error: true - name: Run mypy if: matrix.type == 'python' id: mypy run: | echo "Running mypy..." if mypy . > mypy-output.txt 2>&1; then echo "MYPY_PASSED=true" >> $GITHUB_ENV echo "No mypy errors found" else echo "MYPY_PASSED=false" >> $GITHUB_ENV echo "Mypy found issues" fi cat mypy-output.txt continue-on-error: true # Biome Linting - name: Run Biome if: matrix.type == 'biome' id: biome run: | echo "Running Biome check..." if npx @biomejs/biome check . > biome-output.txt 2>&1; then echo "BIOME_PASSED=true" >> $GITHUB_ENV echo "No Biome errors found!" else echo "BIOME_PASSED=false" >> $GITHUB_ENV echo "Biome found issues!" fi cat biome-output.txt continue-on-error: true # Go Linting - name: Run golangci-lint if: matrix.type == 'go' id: golangci run: | echo "Running golangci-lint..." if golangci-lint run --out-format=colored-line-number > golangci-output.txt 2>&1; then echo "GOLANGCI_PASSED=true" >> $GITHUB_ENV echo "No golangci-lint errors found!" else echo "GOLANGCI_PASSED=false" >> $GITHUB_ENV echo "golangci-lint found issues!" fi cat golangci-output.txt continue-on-error: true # Create Summary for Python - name: Create Python Lint Summary if: matrix.type == 'python' && github.event_name == 'pull_request' run: | { echo "## Lint Results: ${{ matrix.name }}" echo '' # Pylint Status if [[ "${{ env.PYLINT_PASSED }}" == "true" ]]; then echo '### Pylint: **Passed**' echo 'No pylint issues found.' else echo '### Pylint: **Issues Found**' echo '
View pylint output' echo '' echo '```' head -100 pylint-output.txt echo '```' echo '
' fi echo '' # Ruff Status if [[ "${{ env.RUFF_PASSED }}" == "true" ]]; then echo '### Ruff: **Passed**' echo 'No ruff issues found.' else echo '### Ruff: **Issues Found**' echo '
View ruff output' echo '' echo '```' head -100 ruff-output.txt echo '```' echo '
' fi echo '' # Mypy Status if [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then echo '### Mypy: **Passed**' echo 'No mypy issues found.' else echo '### Mypy: **Issues Found**' echo '
View mypy output' echo '' echo '```' head -100 mypy-output.txt echo '```' echo '
' fi echo '' # Overall Summary if [[ "${{ env.PYLINT_PASSED }}" == "true" ]] && [[ "${{ env.RUFF_PASSED }}" == "true" ]] && [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then echo '---' echo '### All checks passed!' else echo '---' echo '### Review the issues above' fi echo '' echo "" } > lint-report.md # Create Summary for Biome - name: Create Biome Lint Summary if: matrix.type == 'biome' && github.event_name == 'pull_request' run: | { echo "## Lint Results: ${{ matrix.name }}" echo '' # Biome Status if [[ "${{ env.BIOME_PASSED }}" == "true" ]]; then echo '### Biome: **Passed**' echo 'No Biome issues found.' else echo '### Biome: **Issues Found**' echo '
View Biome output' echo '' echo '```' head -100 biome-output.txt echo '```' echo '
' fi echo '' # Overall Summary if [[ "${{ env.BIOME_PASSED }}" == "true" ]]; then echo '---' echo '### All checks passed!' else echo '---' echo '### Review the issues above' fi echo '' echo "" } > lint-report.md # Create Summary for Go - name: Create Go Lint Summary if: matrix.type == 'go' && github.event_name == 'pull_request' run: | { echo "## Lint Results: ${{ matrix.name }}" echo '' # golangci-lint Status if [[ "${{ env.GOLANGCI_PASSED }}" == "true" ]]; then echo '### golangci-lint: **Passed**' echo 'No golangci-lint issues found.' else echo '### golangci-lint: **Issues Found**' echo '
View golangci-lint output' echo '' echo '```' head -100 golangci-output.txt echo '```' echo '
' fi echo '' # Overall Summary if [[ "${{ env.GOLANGCI_PASSED }}" == "true" ]]; then echo '---' echo '### All checks passed!' else echo '---' echo '### Review the issues above' fi echo '' echo "" } > lint-report.md # Post PR Comment - name: Post PR Comment if: github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ github.event.pull_request.number }} body-path: ${{ matrix.path }}/lint-report.md edit-mode: replace comment-tag: lint-check-${{ matrix.name }} # Exit with proper status - name: Check lint status run: | if [[ "${{ matrix.type }}" == "python" ]]; then if [[ "${{ env.PYLINT_PASSED }}" == "false" ]] || [[ "${{ env.RUFF_PASSED }}" == "false" ]] || [[ "${{ env.MYPY_PASSED }}" == "false" ]]; then echo "Python lint checks failed" exit 1 fi elif [[ "${{ matrix.type }}" == "biome" ]]; then if [[ "${{ env.BIOME_PASSED }}" == "false" ]]; then echo "Biome lint checks failed" exit 1 fi elif [[ "${{ matrix.type }}" == "go" ]]; then if [[ "${{ env.GOLANGCI_PASSED }}" == "false" ]]; then echo "Go lint checks failed" exit 1 fi fi echo "All lint checks passed"