@@ -18,8 +18,14 @@ concurrency:
18
18
group : scheduled
19
19
cancel-in-progress : true
20
20
21
- permissions :
22
- issues : write
21
+ permissions : {}
22
+
23
+ env :
24
+ GH_NO_UPDATE_NOTIFIER : 1
25
+ GH_PROMPT_DISABLED : 1
26
+ GH_REPO : ${{ github.repository }}
27
+ REPORTING_ISSUE : 139929
28
+ RUN_URL : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
23
29
24
30
jobs :
25
31
create_matrix :
31
37
json : ${{ steps.matrix.outputs.json }}
32
38
env :
33
39
TEST_COUNT : 50
34
- TAP : homebrew/core
35
40
steps :
36
41
- name : Set up Homebrew
37
42
id : set-up-homebrew
@@ -43,33 +48,68 @@ jobs:
43
48
44
49
- name : Generate matrix
45
50
id : matrix
51
+ working-directory : ${{ steps.set-up-homebrew.outputs.repository-path }}
46
52
run : |
47
- formula="$(find "$(brew --repo "${TAP}")/Formula" -type f | shuf -n "${TEST_COUNT}" | xargs -I{} basename {} .rb)"
48
- # shellcheck disable=SC2086
53
+ # Index all formulae so that we test (n ranges from 0 to TEST_COUNT - 1):
54
+ # - formulae 0, 365, 630,..., 0 + 365 * n,... on the first day of the year
55
+ # - formulae 1, 366, 631,..., 1 + 365 * n,... on the second day of the year
56
+ # - formulae 2, 367, 632,..., 2 + 365 * n,... on the third day of the year
57
+ # - ...
58
+ # This works fine as long as we have fewer than 365 * TEST_COUNT formulae.
59
+ mapfile -t formulae < <(find Formula -type f -execdir basename -s '.rb' {} + | sort)
60
+ formulae_count="${#formulae[@]}"
61
+
62
+ DAYS_PER_YEAR=365
63
+ if (( formulae_count > DAYS_PER_YEAR * TEST_COUNT )); then
64
+ echo "::error ::Too many formulae (${formulae_count})! Adjust TEST_COUNT to a number greater than ${TEST_COUNT}."
65
+ exit 1
66
+ fi
67
+
68
+ day="$(date +%j)"
69
+ testing_formulae=()
70
+ for (( i=0; i < TEST_COUNT; i++ )); do
71
+ index="$(( (day + i * DAYS_PER_YEAR - 1) % formulae_count ))"
72
+ testing_formulae+=("${formulae[${index}]}")
73
+ done
74
+
49
75
json="$(
50
- brew info --json=v2 $formula |
51
- jq --compact-output '[.formulae[] | select(.deprecated == false and .disabled == false ) | .name]'
76
+ brew info --json=v2 "${testing_formulae[@]}" |
77
+ jq --compact-output '[.formulae[] | select(.deprecated or .disabled | not ) | .name]'
52
78
)"
53
79
echo "json=${json}" >> "$GITHUB_OUTPUT"
54
80
81
+ comment_on_failure :
82
+ needs : create_matrix
83
+ if : needs.create_matrix.result == 'failure'
84
+ runs-on : ubuntu-latest
85
+ permissions :
86
+ issues : write
87
+ env :
88
+ GH_TOKEN : ${{ github.token }}
89
+ steps :
90
+ - name : Post comment on failure
91
+ run : |
92
+ gh issue comment "$REPORTING_ISSUE" \
93
+ --body "\`create_matrix\` job failed. Check $RUN_URL" \
94
+ --repo "$GITHUB_REPOSITORY"
95
+
55
96
audit_online :
56
97
if : startsWith( github.repository, 'Homebrew/' )
57
- runs-on : ${{ matrix.os }}
98
+ runs-on : ubuntu-latest
58
99
container :
59
100
image : ghcr.io/homebrew/ubuntu22.04:master
101
+ permissions :
102
+ issues : write
60
103
needs : create_matrix
61
- name : " Online check (${{ matrix.os }}) : ${{ matrix.formula }}"
104
+ name : " Online check: ${{ matrix.formula }}"
62
105
env :
63
106
HOMEBREW_GITHUB_API_TOKEN : " ${{ github.token }}"
64
107
GH_TOKEN : " ${{ github.token }}"
65
- REPORTING_ISSUE : 139929
66
- RUN_URL : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
67
108
FORMULA : ${{ matrix.formula }}
68
109
strategy :
69
110
fail-fast : false
70
111
matrix :
71
112
formula : ${{ fromJson(needs.create_matrix.outputs.json) }}
72
- os : [ubuntu-22.04]
73
113
steps :
74
114
- name : Set up Homebrew
75
115
id : set-up-homebrew
@@ -81,35 +121,33 @@ jobs:
81
121
82
122
- name : Check formula source is not archived.
83
123
id : archived
84
- if : matrix.os != 'macos-latest'
85
124
run : brew audit --online --skip-style --only github_repository_archived,gitlab_repository_archived "$FORMULA"
86
125
87
126
- name : Report online issues
88
- if : ${{ failure() && steps.archived.conclusion == 'failure' }}
127
+ if : failure() && steps.archived.conclusion == 'failure'
89
128
run : |
90
129
gh issue comment "$REPORTING_ISSUE" \
91
130
--body "$FORMULA should be archived. Check $RUN_URL" \
92
131
--repo "$GITHUB_REPOSITORY"
93
132
94
133
- name : Check formula for unavailable homepage.
95
134
id : homepage
96
- if : matrix.os != 'macos-latest'
97
135
run : brew audit --online --skip-style --only homepage "$FORMULA"
98
136
99
137
- name : Report homepage issues
100
- if : ${{ failure() && steps.homepage.conclusion == 'failure' }}
138
+ if : failure() && steps.homepage.conclusion == 'failure'
101
139
run : |
102
140
gh issue comment "$REPORTING_ISSUE" \
103
141
--body "$FORMULA has homepage issues. Check $RUN_URL" \
104
142
--repo "$GITHUB_REPOSITORY"
105
143
106
144
- name : Check formula for missing sources.
107
145
id : fetch
108
- if : matrix.os != 'macos-latest '
109
- run : brew fetch -s "$FORMULA"
146
+ if : always() && steps.archived.conclusion != 'failure '
147
+ run : brew fetch --build-from-source "$FORMULA"
110
148
111
149
- name : Report fetch issues
112
- if : ${{ failure() && steps.fetch.conclusion == 'failure' }}
150
+ if : failure() && steps.fetch.conclusion == 'failure'
113
151
run : |
114
152
gh issue comment "$REPORTING_ISSUE" \
115
153
--body "$FORMULA source has problems. Check $RUN_URL" \
0 commit comments