docs + harness polish: Phase 1.1 README restructure, Phase 2.5 demo r… #4
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: build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [chrome, firefox, edge, brave, opera, safari] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Validate JSON files | |
| run: | | |
| set -euo pipefail | |
| for f in extension/manifest.json extension/lib/ad-patterns.json extension/rules/ad-sdks.json; do | |
| echo "Checking $f" | |
| jq empty "$f" | |
| done | |
| - name: JS syntax check | |
| run: | | |
| set -euo pipefail | |
| for f in extension/background.js extension/lib/*.js extension/content/*.js extension/popup/*.js; do | |
| echo "Checking $f" | |
| node --check "$f" | |
| done | |
| - name: Assert BUNDLED_VERSION matches ad-patterns.json | |
| run: | | |
| JS_VER=$(grep -E "const BUNDLED_VERSION" extension/lib/ad-patterns.js | head -1 | sed -E "s/.*'([^']+)'.*/\1/") | |
| JSON_VER=$(jq -r '.version' extension/lib/ad-patterns.json) | |
| if [ "$JS_VER" != "$JSON_VER" ]; then | |
| echo "::error::BUNDLED_VERSION ($JS_VER) != ad-patterns.json version ($JSON_VER)" | |
| exit 1 | |
| fi | |
| - name: Build ${{ matrix.target }} | |
| run: ./build.sh ${{ matrix.target }} | |
| - name: Validate built artifact | |
| run: | | |
| set -euo pipefail | |
| unzip -p "armorly-${{ matrix.target }}.zip" manifest.json | jq -e '.manifest_version == 3' | |
| if [ "${{ matrix.target }}" = "firefox" ]; then | |
| unzip -p armorly-firefox.zip manifest.json | jq -e '.browser_specific_settings.gecko.id' | |
| unzip -p armorly-firefox.zip manifest.json | jq -e '.background.scripts | length > 0' | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: armorly-${{ matrix.target }} | |
| path: armorly-${{ matrix.target }}.zip | |
| if-no-files-found: error | |
| test: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: pw-${{ runner.os }}-${{ hashFiles('package.json') }} | |
| - run: npm install | |
| - run: npx playwright install --with-deps chromium | |
| # MV3 extension loading needs a display server. The pretest hook | |
| # rebuilds the extension before tests run. | |
| - name: Run Playwright tests (under xvfb) | |
| run: xvfb-run -a npm test | |
| env: | |
| CI: "1" | |
| - name: Upload Playwright report on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: | | |
| playwright-report/ | |
| test-results/ |