-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (119 loc) · 4.38 KB
/
ci.yml
File metadata and controls
145 lines (119 loc) · 4.38 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2
extensions: imap, intl, mbstring
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Lint PHP sources
run: |
find . -path ./vendor -prune -o -path ./dist -prune -o \
-name '*.php' -print0 \
| xargs -0 -n1 php -l > /dev/null
- name: Run unit tests
run: composer test:unit -- --colors=never
static-analysis:
name: Static analysis (Psalm)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2
extensions: imap, intl, mbstring
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Fetch Roundcube source for type resolution
run: composer dist:fetch
- name: Run Psalm
run: composer analyse
integration-tests:
name: Integration tests (Dovecot via Docker)
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2
extensions: imap, intl, mbstring
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Verify Docker is available
run: docker info
- name: Pre-pull Dovecot image
# Pulling outside the test timing avoids spurious wait-strategy timeouts
# if the registry is slow.
run: docker pull dovecot/dovecot:latest-root
- name: Run integration tests
run: composer test:integration
docs-freshness:
name: Documentation freshness checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Config keys are consistent across docs and dist file
run: |
DOCS=$(git grep --untracked -hoE '\bimapsync_[a-z_]+' -- README.md AGENTS.md | sort -u)
DIST=$(git grep --untracked -hoE '\bimapsync_[a-z_]+' -- config.inc.php.dist | sort -u)
if ! diff <(echo "$DOCS") <(echo "$DIST") > /tmp/keys.diff; then
echo "::error::Config-key mismatch between docs and config.inc.php.dist"
echo "Diff (< docs, > dist):"
cat /tmp/keys.diff
exit 1
fi
- name: Locale keys exist in both en_US and de_DE, and the two locales mirror each other
run: |
set -euo pipefail
tmp=$(mktemp -d)
git grep --untracked -hoE 'gettext\([^,)]+' -- '*.php' '*.js' \
| sed -E "s/gettext\(['\"]([a-z0-9_]+)['\"].*/\1/" \
| grep -E '^[a-z0-9_]+$' | sort -u > "$tmp/used"
grep -hoE "labels\['[a-z0-9_]+'\]" localization/en_US.inc \
| sed -E "s/.*\['([^']+)'\]/\1/" | sort -u > "$tmp/en"
grep -hoE "labels\['[a-z0-9_]+'\]" localization/de_DE.inc \
| sed -E "s/.*\['([^']+)'\]/\1/" | sort -u > "$tmp/de"
failed=0
report() {
local label="$1"; shift
local file="$1"
if [ -s "$file" ]; then
echo "::error::$label"
sed 's/^/ /' "$file"
failed=1
fi
}
comm -23 "$tmp/used" "$tmp/en" > "$tmp/used_not_en"
comm -23 "$tmp/used" "$tmp/de" > "$tmp/used_not_de"
comm -23 "$tmp/en" "$tmp/de" > "$tmp/en_not_de"
comm -13 "$tmp/en" "$tmp/de" > "$tmp/de_not_en"
report "Locale keys used in code but missing from en_US.inc" "$tmp/used_not_en"
report "Locale keys used in code but missing from de_DE.inc" "$tmp/used_not_de"
report "Locale keys defined in en_US.inc but missing from de_DE.inc" "$tmp/en_not_de"
report "Locale keys defined in de_DE.inc but missing from en_US.inc" "$tmp/de_not_en"
exit "$failed"