Skip to content

Commit

Permalink
feat: add support for Differential Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and Johannes-Andersen committed Jul 23, 2024
1 parent 27e293e commit d5c3411
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 84 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/cleanup-workflow-runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Delete old workflow runs
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
delete:
name: Delete workflow runs 🗑️
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: write
contents: read

steps:
- name: Start cleanup
uses: Mattraks/delete-workflow-runs@4c9f24749b7996562658e3d6e10662489e22caca # v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 8
2 changes: 1 addition & 1 deletion .github/workflows/dead-domains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
cleanup:
name: Cleanup dead domains 🧹
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 10
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: corepack enable
Expand Down
108 changes: 108 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Deploy

on:
workflow_call:
inputs:
previous_sha:
required: true
type: string
description: 'Previous commit SHA'
current_sha:
required: true
type: string
description: 'Current commit SHA'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
find-changes:
name: Find changed lists 🕵️
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 5

- name: Find changed lists
id: find-changes
run: |
changed_lists=$(git diff --name-only "${{ inputs.previous_sha }}" "${{ inputs.current_sha }}" | grep '^filters/' | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n") | map(select(. != ""))')
if [[ -z "$changed_lists" || "$changed_lists" == "[]" ]]; then
echo "No changes detected."
echo "changed_lists=[]" >> $GITHUB_ENV
else
echo "changed_lists=$changed_lists" >> $GITHUB_ENV
fi
echo "::set-output name=changed_lists::$changed_lists"
outputs:
changed_lists: ${{ steps.find-changes.outputs.changed_lists }}

deploy:
name: Deploy 🚀
runs-on: ubuntu-latest
timeout-minutes: 15
needs: find-changes
if: ${{ needs.find-changes.outputs.changed_lists != '[]' }}
strategy:
max-parallel: 1
matrix:
list: ${{ fromJson(needs.find-changes.outputs.changed_lists) }}
permissions:
contents: write

steps:
- name: Checkout main branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 2
ref: main

- run: corepack enable
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Build filters
run: pnpm run build -l ${{ matrix.list }}

- name: Checkout deploy branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 2
ref: deploy
path: deploy-branch

- name: Backup old list
run: mkdir -p old && cp deploy-branch/${{ matrix.list }}.txt old/${{ matrix.list }}.txt

- name: Move over new list
run: cp out/${{ matrix.list }}.txt deploy-branch/${{ matrix.list }}.txt

- name: Use diff-builder
run: |
patch_name=$(echo ${{ matrix.list }} | tr '[:upper:]' '[:lower:]')_$(echo ${{ inputs.current_sha }} | cut -c1-8)
mkdir -p deploy-branch/patches/${{ matrix.list }}
pnpm exec diff-builder build -c -v -n "$patch_name" -t 24 old/${{ matrix.list }}.txt deploy-branch/${{ matrix.list }}.txt deploy-branch/patches/${{ matrix.list }}
- name: Commit and push changes
run: |
cd deploy-branch
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add patches/
git add ads.txt annoyances.txt tracking.txt
git commit -m "Deployment of ${{ matrix.list }}"
git push origin deploy
76 changes: 0 additions & 76 deletions .github/workflows/test-and-deploy.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
test:
name: Test 🧪
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: corepack enable
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: ".nvmrc"
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Setup Biome
uses: biomejs/setup-biome@1cbe33ead22c7a2fded3b52fa2893611c815c9b5 # v2

- name: Run filters lint
run: pnpm run lint:filters

- name: Run Biome
run: biome ci . --reporter=github

- name: Validate codeowners
run: pnpm run codeowners:check

- name: Build filters
run: pnpm run build

attempt_deploy:
name: Attempt deploy 🔭
needs: test
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
previous_sha: ${{ github.event.before }}
current_sha: ${{ github.sha }}
3 changes: 2 additions & 1 deletion filters/ads/header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
! Title: Partall Filter List - Ads
! Description: uBlock Origin filter list for blocking ads, to be used in conjunction with other general purpose filter lists.
! Last modified: {{last_modified}}
! Last updated: {{last_modified}}
! Version: {{version}}
! Expires: 1 day
! Expires: 5 days
! License: https://github.com/johannes-Andersen/partall/blob/main/LICENSE
! Homepage: https://github.com/johannes-Andersen/partall
3 changes: 2 additions & 1 deletion filters/annoyances/header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
! Title: Partall Filter List - Annoyances
! Description: uBlock Origin filter list for annoyances, like cookie warnings, newsletter popups, etc.
! Last modified: {{last_modified}}
! Last updated: {{last_modified}}
! Version: {{version}}
! Expires: 1 day
! Expires: 5 days
! License: https://github.com/johannes-Andersen/partall/blob/main/LICENSE
! Homepage: https://github.com/johannes-Andersen/partall
1 change: 0 additions & 1 deletion filters/tracking/filters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
||shopgun.com^$third-party
||raygun.io$third-party
||piano.io^$third-party

3 changes: 2 additions & 1 deletion filters/tracking/header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
! Title: Partall Filter List - Tracking
! Description: uBlock Origin filter list for blocking tracking, to be used in conjunction with other general purpose filter lists.
! Last modified: {{last_modified}}
! Last updated: {{last_modified}}
! Version: {{version}}
! Expires: 1 day
! Expires: 5 days
! License: https://github.com/johannes-Andersen/partall/blob/main/LICENSE
! Homepage: https://github.com/johannes-Andersen/partall
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
"dead-domains": "dead-domains-linter -s -i **/filters.txt",
"dead-domains:fix": "dead-domains-linter -a -i **/filters.txt"
},
"packageManager": "pnpm@9",
"packageManager": "pnpm@9.6.0",
"engines": {
"node": "22.5.1",
"pnpm": "9.6.0"
},
"dependencies": {
"@adguard/aglint": "2.0.9",
"@adguard/dead-domains-linter": "1.0.19",
"@adguard/diff-builder": "1.0.18",
"@biomejs/biome": "1.8.3",
"codeowners-generator": "2.4.1"
},
Expand Down
25 changes: 25 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5c3411

Please sign in to comment.