-
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (134 loc) · 6.01 KB
/
Copy pathupdate-flag-database.yml
File metadata and controls
165 lines (134 loc) · 6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# SPDX-License-Identifier: PMPL-1.0-or-later
name: Update Flag Database
# Runs weekly to detect Mozilla flag changes
on:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
workflow_dispatch: # Manual trigger
pull_request:
paths:
- 'extension/data/flags-database.json'
permissions: read-all
jobs:
detect-mozilla-changes:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Setup Deno
uses: denoland/setup-deno@e95548e56dfa95d4e1a28d6f422fafe75c4c26fb # v2
with:
deno-version: v2.x
- name: Fetch Firefox source preferences
run: |
# Download Firefox source to check for new/changed prefs
wget https://hg.mozilla.org/mozilla-central/raw-file/tip/modules/libpref/init/all.js \
-O /tmp/firefox-prefs.js
wget https://hg.mozilla.org/mozilla-central/raw-file/tip/modules/libpref/init/StaticPrefList.yaml \
-O /tmp/firefox-static-prefs.yaml
- name: Compare with current database
id: compare
run: |
# Extract flag keys from current database
jq -r '.flags[].key' extension/data/flags-database.json > /tmp/current-flags.txt
# Parse Firefox prefs and find new ones
# (This is a simplified check - full implementation would parse YAML/JS properly)
grep -oP '(?<=pref\(")[\w\.]+"(?=,)' /tmp/firefox-prefs.js | tr -d '"' > /tmp/firefox-flags.txt || true
# Find new flags (in Firefox but not in our database)
comm -13 <(sort /tmp/current-flags.txt) <(sort /tmp/firefox-flags.txt) > /tmp/new-flags.txt
# Find removed flags (in our database but not in Firefox)
comm -23 <(sort /tmp/current-flags.txt) <(sort /tmp/firefox-flags.txt) > /tmp/removed-flags.txt
NEW_COUNT=$(wc -l < /tmp/new-flags.txt)
REMOVED_COUNT=$(wc -l < /tmp/removed-flags.txt)
echo "new_flags=$NEW_COUNT" >> $GITHUB_OUTPUT
echo "removed_flags=$REMOVED_COUNT" >> $GITHUB_OUTPUT
if [ $NEW_COUNT -gt 0 ] || [ $REMOVED_COUNT -gt 0 ]; then
echo "changes_detected=true" >> $GITHUB_OUTPUT
else
echo "changes_detected=false" >> $GITHUB_OUTPUT
fi
- name: Create issue for new flags
if: steps.compare.outputs.changes_detected == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
with:
script: |
const newFlags = ${{ steps.compare.outputs.new_flags }};
const removedFlags = ${{ steps.compare.outputs.removed_flags }};
const body = `## Firefox Flag Database Update Needed
**New flags detected:** ${newFlags}
**Removed/deprecated flags:** ${removedFlags}
### New Flags
\`\`\`
${require('fs').readFileSync('/tmp/new-flags.txt', 'utf8')}
\`\`\`
### Removed Flags
\`\`\`
${require('fs').readFileSync('/tmp/removed-flags.txt', 'utf8')}
\`\`\`
### Action Required
- [ ] Research each new flag
- [ ] Classify safety level (safe/experimental/dangerous)
- [ ] Document effects (positive/negative/interesting)
- [ ] Add to extension/data/flags-database.json
- [ ] Mark removed flags with geckoMaxVersion
- [ ] Update documentation
### References
- Firefox source: https://hg.mozilla.org/mozilla-central/file/tip/modules/libpref/init/
- Bugzilla: https://bugzilla.mozilla.org
- MDN: https://developer.mozilla.org
`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `[Auto] Firefox flags changed: +${newFlags} -${removedFlags}`,
body: body,
labels: ['flag-database', 'automated', 'needs-review']
});
- name: Validate current database schema
run: |
# Validate JSON schema
npx ajv-cli validate \
-s extension/data/flags-schema.json \
-d extension/data/flags-database.json
- name: Check for community contributions
run: |
# Check if this is a PR adding/modifying flags
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "Reviewing community flag contribution..."
# Validate the PR changes the database correctly
git diff origin/main extension/data/flags-database.json
# TODO: Add automated validation:
# - Schema compliance
# - Safety level justification
# - Documentation links present
# - No duplicate keys
fi
version-compatibility-check:
runs-on: ubuntu-latest
strategy:
matrix:
firefox-version: ['109', '115', '120', '125', 'nightly']
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Test Firefox ${{ matrix.firefox-version }}
run: |
# Check which flags are valid for this Firefox version
jq --arg ver "${{ matrix.firefox-version }}.0" '
.flags[] |
select(
(.geckoMinVersion // "0.0") <= $ver and
((.geckoMaxVersion // "999.0") >= $ver or .geckoMaxVersion == null)
) |
.key
' extension/data/flags-database.json > flags-for-${{ matrix.firefox-version }}.txt
COUNT=$(wc -l < flags-for-${{ matrix.firefox-version }}.txt)
echo "Firefox ${{ matrix.firefox-version }}: $COUNT compatible flags"
- name: Upload compatibility report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4
with:
name: compatibility-firefox-${{ matrix.firefox-version }}
path: flags-for-${{ matrix.firefox-version }}.txt