-
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (126 loc) · 4.94 KB
/
tests.yml
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
name: brew test-bot
on:
push:
branches:
- main
pull_request:
jobs:
test-bot:
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-13, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Cache Homebrew Bundler RubyGems
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ matrix.os }}-${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ matrix.os }}-${{ runner.os }}-rubygems-
- name: Install Homebrew Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems
- name: Set BREWFILE_PATH env var
run: |
echo "BREWFILE_PATH=${GITHUB_WORKSPACE}/Brewfile.ci" >> "$GITHUB_ENV"
- name: Create brewed-bottles dir
run: |
mkdir "${RUNNER_TEMP}/brewed-bottles"
pwd
ls -lA "${RUNNER_TEMP}/brewed-bottles"
- name: HACK - Bottle go + Force link conflicting go binaries
env:
HOMEBREW_COLOR: 1
HOMEBREW_DEVELOPER: 1
run: |
if [ -e "/usr/local/opt/[email protected]" ]; then
brew install --build-bottle go || true
brew link --overwrite go
brew bottle go
# find "${GITHUB_WORKSPACE}" -iname '*.bottle.*' -exec mv '{}' "${RUNNER_TEMP}/brewed-bottles/" \;
ls -l "${RUNNER_TEMP}/brewed-bottles/"
fi
:
- name: Install Brewfile.ci dependencies
env:
HOMEBREW_COLOR: 1
HOMEBREW_DEVELOPER: 1
run: |
brew bundle install --file="${BREWFILE_PATH}"
- run: brew test-bot --only-cleanup-before
- run: brew test-bot --only-setup
# Allow our own tap style overrides
- run: |
sed -i'' -e '/Style\/DisableCopsWithinSourceCodeDirective:/{n;s/.*Enabled: true/ Enabled: false/;}' "$(brew --repository)"/Library/.rubocop.yml
- run: brew test-bot --only-tap-syntax
- run: |
brew test-bot --only-formulae --only-json-tab --skip-recursive-dependents --root-url="https://ghcr.io/v2/LyraPhase/right2repair"
if: github.event_name == 'pull_request'
- name: Move bottle files
run: |
find "${GITHUB_WORKSPACE}" -iname '*.bottle.*' -exec mv '{}' "${RUNNER_TEMP}/brewed-bottles/" \;
ls -lA "${RUNNER_TEMP}/brewed-bottles/"
if: github.event_name == 'pull_request'
- name: Upload bottles as artifact
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@main
with:
name: bottles_${{ matrix.os }}-${{ runner.arch }}
path: '${{ runner.temp }}/brewed-bottles/*.bottle.*'
autoreview-check:
needs: test-bot
runs-on: ubuntu-latest
steps:
- name: Check triggering user permissions
id: check_user_permissions
uses: actions-cool/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
username: ${{ github.triggering_actor }}
require: admin
outputs:
authorized: ${{ steps.check_user_permissions.outputs.require-result }}
autoreview:
if: format('{0}', needs.autoreview-check.outputs.authorized) == 'true' && github.event_name == 'pull_request' && github.event.pull_request.merged != true
needs: [test-bot, autoreview-check]
runs-on: ubuntu-latest
env:
PR: ${{ github.event.pull_request.number }}
steps:
- name: Auto-approve review for admins
env:
GH_TOKEN: ${{ secrets.LYRAPHASE_RUNNER_PACKAGES_TOKEN }}
run: |
pr_data="$(
gh api \
--header 'Accept: application/vnd.github+json' \
--header 'X-GitHub-Api-Version: 2022-11-28' \
"repos/$GITHUB_REPOSITORY/pulls/$PR"
)"
state="$(jq --raw-output .state <<< "$pr_data")"
merged="$(jq --raw-output .merged <<< "$pr_data")"
automerge_enabled="$(jq --raw-output '.auto_merge != null' <<< "$pr_data")"
if [[ -z "$state" ]] ||
[[ -z "$merged" ]] ||
[[ -z "$automerge_enabled" ]]
then
echo "::error ::Failed to get PR data!"
exit 1
fi
if [[ "$state" == "closed" ]]; then
echo "::error ::PR #$PR is closed!"
exit 1
fi
requires_merge=true
if [[ "$merged" == "true" || "$automerge_enabled" == "true" ]]; then
echo '::notice ::Pull request is either already merged or queued to merge.'
requires_merge=false
fi
if [[ "$requires_merge" == "true" ]]; then
gh pr comment "$PR" --body "Auto-approving repo owner PR" --repo "$GITHUB_REPOSITORY"
gh pr review --approve "$PR" --repo "$GITHUB_REPOSITORY"
fi