dev: hiding buttons #2
  
    
      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: Test | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [16, 18, 20] | |
| 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: | | |
| if [ -f package.json ]; then | |
| npm ci | |
| fi | |
| - name: Run unit tests | |
| run: | | |
| if [ -f package.json ] && npm run test 2>/dev/null; then | |
| npm test | |
| else | |
| echo "No unit tests configured" | |
| fi | |
| - name: Run integration tests | |
| run: | | |
| if [ -f package.json ] && npm run test:integration 2>/dev/null; then | |
| npm run test:integration | |
| else | |
| echo "No integration tests configured" | |
| fi | |
| - name: Run end-to-end tests | |
| run: | | |
| if [ -f package.json ] && npm run test:e2e 2>/dev/null; then | |
| npm run test:e2e | |
| else | |
| echo "No end-to-end tests configured" | |
| fi | |
| - name: Run linting | |
| run: | | |
| if [ -f package.json ] && npm run lint 2>/dev/null; then | |
| npm run lint | |
| else | |
| echo "No linting configured" | |
| fi | |
| - name: Run type checking | |
| run: | | |
| if [ -f package.json ] && npm run type-check 2>/dev/null; then | |
| npm run type-check | |
| else | |
| echo "No type checking configured" | |
| fi | |
| - name: Check code coverage | |
| run: | | |
| if [ -f package.json ] && npm run test:coverage 2>/dev/null; then | |
| npm run test:coverage | |
| else | |
| echo "No coverage reporting configured" | |
| fi | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v3 | |
| if: always() | |
| with: | |
| file: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| browser-test: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| browser: [chrome, firefox] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| if [ -f package.json ]; then | |
| npm ci | |
| fi | |
| - name: Run browser tests | |
| run: | | |
| if [ -f package.json ] && npm run test:browser 2>/dev/null; then | |
| npm run test:browser -- --browser ${{ matrix.browser }} | |
| else | |
| echo "No browser tests configured" | |
| fi | |
| extension-test: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| if [ -f package.json ]; then | |
| npm ci | |
| fi | |
| - name: Build extension | |
| run: | | |
| if [ -f build.sh ]; then | |
| chmod +x build.sh | |
| ./build.sh | |
| fi | |
| - name: Test extension functionality | |
| run: | | |
| echo "Testing extension functionality..." | |
| # Check if required files exist | |
| required_files=("manifest.json" "content.js" "popup.html" "popup.js") | |
| for file in "${required_files[@]}"; do | |
| if [ -f "$file" ]; then | |
| echo "✅ $file exists" | |
| else | |
| echo "❌ $file is missing" | |
| exit 1 | |
| fi | |
| done | |
| # Validate manifest | |
| if node -e "JSON.parse(require('fs').readFileSync('./manifest.json', 'utf8'))"; then | |
| echo "✅ manifest.json is valid JSON" | |
| else | |
| echo "❌ manifest.json is invalid JSON" | |
| exit 1 | |
| fi | |
| # Check for basic functionality | |
| if grep -q "chrome.runtime\|browser.runtime" *.js; then | |
| echo "✅ Extension API usage found" | |
| else | |
| echo "⚠️ Warning: No extension API usage found" | |
| fi | |
| - name: Run extension tests | |
| run: | | |
| if [ -f package.json ] && npm run test:extension 2>/dev/null; then | |
| npm run test:extension | |
| else | |
| echo "No extension-specific tests configured" | |
| fi |