-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (165 loc) · 6.27 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: GitHub Actions CI
on:
push:
branches: master
pull_request: []
env:
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
jobs:
tests:
if: github.repository == 'Homebrew/brew'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- name: Set up Homebrew
id: set-up-homebrew
run: |
if which brew &>/dev/null; then
HOMEBREW_PREFIX="$(brew --prefix)"
HOMEBREW_REPOSITORY="$HOMEBREW_PREFIX/Homebrew"
else
HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
HOMEBREW_REPOSITORY="$HOMEBREW_PREFIX/Homebrew"
sudo mkdir -p "$HOMEBREW_REPOSITORY/Library/Taps"
git -C "$HOMEBREW_REPOSITORY" init
git -C "$HOMEBREW_REPOSITORY" remote add origin "https://github.com/$GITHUB_REPOSITORY"
cd "$HOMEBREW_PREFIX"
sudo mkdir -p bin etc include lib opt sbin share var/homebrew/linked Cellar
sudo ln -sf ../Homebrew/bin/brew "$HOMEBREW_PREFIX/bin/"
cd -
fi
export PATH="$HOMEBREW_PREFIX/bin:$PATH"
echo "::add-path::$HOMEBREW_PREFIX/bin"
cd "$HOMEBREW_REPOSITORY"
rm -rf "$GITHUB_WORKSPACE"
ln -s "$HOMEBREW_REPOSITORY" "$GITHUB_WORKSPACE"
git fetch --tags origin "${{github.sha}}"
git checkout --force -B master FETCH_HEAD
brew update-reset Library/Taps/homebrew/homebrew-core
cd -
GEMS_HASH=$(shasum -a 256 "$HOMEBREW_REPOSITORY/Library/Homebrew/Gemfile.lock" | cut -f1 -d' ')
echo "::set-output name=gems-hash::$GEMS_HASH"
if [ "$RUNNER_OS" = "Linux" ]; then
sudo chown -R "$USER" "$HOMEBREW_PREFIX"
fi
- name: Set up Ruby
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-ruby@master
with:
ruby-version: '2.6'
- name: Run brew config
run: brew config
- name: Run brew doctor
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
# Cleanup some Linux `brew doctor` failures
sudo rm -rf /usr/local/include/node/
else
# Link old gettext (otherwise `brew doctor` is sad)
brew link gettext
# remove deleted formula
brew uninstall --force python@2
fi
brew doctor
- name: Cache Bundler RubyGems
id: cache
uses: actions/cache@v1
with:
path: Library/Homebrew/vendor/bundle/ruby/
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: |
${{ runner.os }}-rubygems-
- name: Install Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems
- name: Check for uncommitted RubyGems
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
- name: Install taps
run: |
# Install taps needed for 'brew tests' and 'brew man'
cd "$(brew --repo)"
brew tap homebrew/bundle
brew update-reset Library/Taps/homebrew/homebrew-bundle
brew tap homebrew/services
brew update-reset Library/Taps/homebrew/homebrew-services
brew tap homebrew/test-bot
brew update-reset Library/Taps/homebrew/homebrew-test-bot
if [ "$RUNNER_OS" = "macOS" ]; then
brew tap homebrew/cask
brew update-reset Library/Taps/homebrew/homebrew-cask
else
# Fix permissions for 'brew tests'
sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt
fi
- name: Run brew style
run: brew style --display-cop-names
- name: Run brew man
run: brew man --fail-if-changed
- name: Run brew tests
run: |
# brew tests doesn't like world writable directories
umask 022
# set variables for coverage reporting
export HOMEBREW_CI_BUILD_NUMBER="$GITHUB_REF"
export HOMEBREW_CI_BRANCH="$HEAD_GITHUB_REF"
export HOMEBREW_GITHUB_REPOSITORY="$GITHUB_REPOSITORY"
# don't bother running all tests on both platforms (for speed)
if [ "$RUNNER_OS" = "Linux" ]; then
brew tests --no-compat --online
brew tests --generic --online
brew tests --online
else
brew tests --online --coverage
fi
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# set variables for coverage reporting
HOMEBREW_CI_NAME: github-actions
HOMEBREW_COVERALLS_REPO_TOKEN: 3F6U6ZqctoNJwKyREremsqMgpU3qYgxFk
# These cannot be queried at the macOS level on GitHub Actions.
HOMEBREW_LANGUAGES: en-GB
- name: Run brew update-tests
run: |
git config --global user.name "BrewTestBot"
git config --global user.email "[email protected]"
brew update-test
brew update-test --to-tag
brew update-test --commit=HEAD
if: github.event_name == 'pull_request'
- name: Run brew readall on all taps
run: brew readall --aliases
- name: Run brew style on homebrew-core
run: brew style --display-cop-names homebrew/core
- name: Run brew style on official taps
run: brew style --display-cop-names homebrew/bundle homebrew/services homebrew/test-bot
- name: Run vale for docs linting
run: |
brew install vale
vale docs/
- name: Lint Dockerfile
if: matrix.os == 'ubuntu-latest'
run: |
brew install hadolint
hadolint Dockerfile
- name: Build Docker image
if: matrix.os == 'ubuntu-latest'
run: docker build -t brew --build-arg=version=16.04 .
- name: Run brew test-bot
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
docker run --rm brew brew test-bot
else
brew test-bot
fi
- name: Deploy the Docker image to GitHub and Docker Hub
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master'
run: |
docker login docker.pkg.github.com -u BrewTestBot -p ${{secrets.GITHUB_TOKEN}}
docker tag brew "docker.pkg.github.com/homebrew/brew/ubuntu16.04:master"
docker push "docker.pkg.github.com/homebrew/brew/ubuntu16.04:master"
docker login -u brewtestbot -p ${{secrets.DOCKER_TOKEN}}
docker tag brew "homebrew/ubuntu16.04:master"
docker push "homebrew/ubuntu16.04:master"