Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GitHub CI to check sorting HttpsExclusions #596

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint HttpsExclusions

on:
push:
branches:
- master
paths:
- "**/*.txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both "**/*.txt" can be replaced by a relative path of banks.txt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, But, it can be extended in the future.

pull_request:
branches:
- master
paths:
- "**/*.txt"

jobs:
bank:
name: Check that bank.txt is sorted
runs-on: ubuntu-latest
steps:
- name: Set up Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Check out to repository
uses: actions/checkout@v4
- name: Run lint:banks
run: npm run lint:banks
shell: bash
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
.DS_Store
.DS_Store
node_modules
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
"main": "index.js",
"repository": "[email protected]:AdguardTeam/HttpsExclusions.git",
"author": "AdGuard",
"license": "MIT"
"license": "MIT",
"scripts": {
"lint:banks": "tsx tools/banks.mts"
},
"devDependencies": {
"@types/node": "^20.14.2",
"tsx": "^4.15.4",
"typescript": "^5.4.5"
}
}
12 changes: 12 additions & 0 deletions tools/banks.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Fs from 'node:fs'

const Banks = Fs.readFileSync('exclusions/banks.txt').toString().split('\n')
const Sorted = Banks.toSorted((A, B) => {
if (A.startsWith('//')) {
return 0
}
// Sort by alphabetical order
return A.localeCompare(B)
})

process.exit(JSON.stringify(Banks) === JSON.stringify(Sorted) ? 0 : 1)
14 changes: 14 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "NodeNext",
"lib": ["ES2023", "ES2023.Array", "ES2023.Collection"],
"target": "ES2022",
"moduleResolution": "NodeNext",
"removeComments": false,
"alwaysStrict": true,
"skipLibCheck": true
},
"include": [
"tools/**/*.mts"
]
}