
- I suggested this for the contents of [Linuxbrew/docker](https://github.com/Linuxbrew/docker) in https://github.com/Linuxbrew/docker/issues/75. People agreed, and Shaun asked me to do the same here. - This adds a step to CI to lint the Dockerfile, via [hadolint](https://github.com/hadolint/hadolint), on Ubuntu. - The linting errors it surfaced on this Dockerfile were: ``` Dockerfile:4 DL3008 Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>` Dockerfile:30 DL3020 Use COPY instead of ADD for files and folders Dockerfile:32 DL3003 Use WORKDIR to switch to a directory ``` - [DL3008](https://github.com/hadolint/hadolint/wiki/DL3008) - pinning versions in `apt-get install` - is at odds with what we recommend in the normal Homebrew on Linux dependency install instructions. We don't want the dependency management of having to check each of these Dockerfiles periodically for the latest version numbers of packages and have to update them. So I've disabled this lint. - [DL3003](https://github.com/hadolint/hadolint/wiki/DL3003) - use WORKDIR to `cd` - is disabled in this case due to [review comments](https://github.com/Homebrew/brew/pull/7433/files#r415098255).
199 lines
6.2 KiB
YAML
199 lines
6.2 KiB
YAML
name: GitHub Actions CI
|
|
on:
|
|
push:
|
|
branches: master
|
|
pull_request: []
|
|
release:
|
|
types:
|
|
- published
|
|
jobs:
|
|
tests:
|
|
if: github.repository == 'Homebrew/brew'
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macOS-latest]
|
|
steps:
|
|
- name: Set up Homebrew PATH
|
|
run: |
|
|
if [ "$RUNNER_OS" = "Linux" ]; then
|
|
echo "::add-path::/home/linuxbrew/.linuxbrew/bin"
|
|
else
|
|
echo "::add-path::/usr/local/bin"
|
|
fi
|
|
|
|
- name: Set up Homebrew
|
|
run: |
|
|
if which brew &>/dev/null; then
|
|
HOMEBREW_REPOSITORY="$(brew --repo)"
|
|
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
|
|
|
|
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 -
|
|
|
|
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
|
|
# Allow Xcode to be outdated
|
|
export HOMEBREW_GITHUB_ACTIONS=1
|
|
|
|
# Link old gettext (otherwise `brew doctor` is sad)
|
|
brew link gettext
|
|
fi
|
|
brew doctor
|
|
|
|
- name: Install Bundler RubyGems
|
|
run: |
|
|
brew install-bundler-gems
|
|
|
|
# Check for uncommitted gems
|
|
git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
|
|
|
|
if [ "$RUNNER_OS" = "Linux" ]; then
|
|
# Fix permissions for 'brew tests'
|
|
sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt
|
|
fi
|
|
|
|
- name: Install taps
|
|
run: |
|
|
# Install taps needed for 'brew tests' and 'brew man'
|
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
|
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
|
|
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_GITHUB_ACTIONS: 1
|
|
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 "homebrew-test-bot@lists.sfconservancy.org"
|
|
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
|
|
if: matrix.os == 'macOS-latest'
|
|
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 pull homebrew/brew
|
|
docker-compose -f Dockerfile.yml build sut
|
|
|
|
- name: Run brew test-bot
|
|
run: |
|
|
if [ "$RUNNER_OS" = "Linux" ]; then
|
|
docker-compose -f Dockerfile.yml run --rm -v $GITHUB_WORKSPACE:/tmp/test-bot sut
|
|
docker tag homebrew_sut brew
|
|
else
|
|
brew test-bot
|
|
fi
|
|
|
|
- name: Deploy the latest Docker image
|
|
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/brew
|
|
docker push docker.pkg.github.com/homebrew/brew/brew
|
|
|
|
- name: Deploy the tagged Docker image
|
|
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
docker login docker.pkg.github.com -u BrewTestBot -p ${{secrets.GITHUB_TOKEN}}
|
|
v=${GITHUB_REF:10}
|
|
docker tag brew "docker.pkg.github.com/homebrew/brew/brew:$v"
|
|
docker push "docker.pkg.github.com/homebrew/brew/brew:$v"
|