This repository has been archived by the owner on Apr 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
118 lines (99 loc) · 3.36 KB
/
ci.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
---
name: CI
on:
push:
paths:
- "Formula/*.rb"
branches:
- master
pull_request:
paths:
- "Formula/*.rb"
branches:
- master
workflow_dispatch:
jobs:
test:
name: Test Formulae
runs-on: macos-11
steps:
# https://github.com/Homebrew/actions/tree/master/setup-homebrew
#
# this action handles checkout of the repo
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
test-bot: true
- name: Setup Tap
run: |
mkdir -p $(brew --repo)/Library/Taps/kong
ln -s $PWD $(brew --repo)/Library/Taps/kong/homebrew-kong
- name: Cache Homebrew Bundler RubyGems & Downloads
id: cache
uses: actions/cache@v1
with:
path: |
${{ steps.set-up-homebrew.outputs.gems-path }}
/usr/local/Homebrew/Library/Caches/Homebrew/downloads
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-
- name: Install Homebrew Bundler RubyGems & Downloads
if: steps.cache.outputs.cache-hit != 'true'
run: |
brew install-bundler-gems
# use brew tap-info to prime cache of formulae deps
brew tap-info -v -d kong/kong --json \
| jq -r '.[].formula_names[]' \
| xargs brew fetch --deps
- id: files
uses: jitterbit/get-changed-files@v1
- name: Get Changed Formulae
id: changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "::set-output name=formulae::$(
# extract formula name from file for changed files
echo -n '${{ steps.files.outputs.added_modified }}' \
| tr ' ' '\n' \
| sort -ru \
| sed -ne 's^Formula/\(.*\)\.rb^\1^gp' \
| tr '\n' ','
)"
- name: Brew Style (Kong)
if: contains(steps.changes.outputs.formulae, 'kong') == true
run: |
echo "::add-matcher::.github/matcher.json"
brew style \
--except-cops FormulaAudit/DependencyOrder \
{${{ steps.changes.outputs.formulae }}}
- name: Brew Style (Non-Kong)
if: contains(steps.changes.outputs.formulae, 'kong') == false
run: |
echo "::add-matcher::.github/matcher.json"
brew style \
{${{ steps.changes.outputs.formulae }}}
- name: Brew Audit
if: contains(steps.changes.outputs.formulae, 'kong') == true
run: |
echo "::add-matcher::.github/matcher.json"
brew audit \
--online \
--except-cops FormulaAudit/DependencyOrder \
{${{ steps.changes.outputs.formulae }}}
- name: Brew Audit (Non-Kong)
if: contains(steps.changes.outputs.formulae, 'kong') == false
run: |
echo "::add-matcher::.github/matcher.json"
brew audit \
--online \
{${{ steps.changes.outputs.formulae }}}
- name: Installation of Kong should fail
run: |
set -x
# already installed on these runners
brew uninstall --force nginx
# skip cleanup since this is an ephemeral build
export HOMEBREW_NO_INSTALL_CLEANUP=1
! brew install kong