ci/macos: include short sleep to make sure server is up #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | macOS | |
on: | |
push: | |
paths-ignore: | |
- '*.md' | |
- 'doc/**' | |
- 'windows/**' | |
pull_request: | |
paths-ignore: | |
- '*.md' | |
- 'doc/**' | |
- 'windows/**' | |
jobs: | |
ci: | |
name: CI | macOS with homebrew | |
runs-on: macos-13 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: # For tools/get-version: | |
fetch-depth: 0 | |
- name: Install dependencies | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_CLEANUP: 1 | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 | |
run: | | |
brew update | |
brew install \ | |
erlang \ | |
openssl \ | |
libyaml \ | |
rebar3 | |
- name: Cache Rebar data | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/rebar3 | |
key: ${{ runner.os }}-${{ hashFiles('rebar.config') }} | |
- name: Download dependencies | |
run: rebar3 get-deps | |
- name: Compile code | |
env: | |
LDFLAGS: -L/usr/local/opt/openssl/lib -L/usr/local/lib | |
CFLAGS: -I/usr/local/opt/openssl/include/ -I/usr/local/include | |
CPPFLAGS: -I/usr/local/opt/openssl/include/ -I/usr/local/include | |
run: rebar3 compile | |
- name: Build release | |
run: rebar3 release | |
- name: Start release | |
run: _build/default/rel/eturnal/bin/eturnal daemon | |
- name: Ping release | |
run: _build/default/rel/eturnal/bin/eturnal ping | |
- name: Stop release | |
run: _build/default/rel/eturnal/bin/eturnal stop | |
- name: Analyze cross references | |
run: rebar3 xref | |
- name: Perform static code analysis | |
run: rebar3 dialyzer | |
- name: Run black-box tests (CT) | |
run: rebar3 ct || rebar3 ct | |
shell: bash | |
- name: Run white-box tests (EUnit) | |
run: rebar3 eunit | |
- name: Check test coverage | |
run: rebar3 cover | |
formula: | |
name: On ${{ matrix.os }} | install & test ${{ matrix.vsn }} Formula | |
runs-on: ${{ matrix.os }}-latest | |
strategy: | |
matrix: | |
os: [macos, ubuntu] | |
vsn: [head, stable] | |
fail-fast: false | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- 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: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | |
restore-keys: ${{ runner.os }}-rubygems- | |
- name: Install Homebrew Bundler RubyGems | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: brew install-bundler-gems | |
- name: Install eturnal with homebrew formula | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_CLEANUP: 1 | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 | |
run: | | |
if [ ${{ matrix.vsn }} = 'head' ]; then export vsn='--head'; fi | |
# Download eturnal.rb instead of `brew tap` to avoid failures when | |
# running on branches or pull requests -> requires actions/checkout | |
curl -O https://raw.githubusercontent.com/${{ github.repository }}/$(git rev-parse HEAD)/Formula/eturnal.rb | |
brew install --build-from-source ${vsn:-} --verbose ./eturnal.rb | |
- name: Homebrew autoremove unused packages | |
if: matrix.os != 'ubuntu' | |
run: | | |
brew uninstall erlang rebar3 | |
brew autoremove | |
- name: Run eturnal Formula test | |
run: brew test --verbose eturnal | |
- name: Start eturnal service | |
run: brew services start eturnal | |
- name: Check if eturnal is up & running ... | |
run: | | |
max_iterations=60 | |
iterations=0 | |
while true | |
do | |
iterations="$(expr $iterations + 1)" | |
echo ">> Attempt $iterations from $max_iterations" | |
sleep 1 | |
if [ "$(eturnalctl ping)" = 'pong' ]; then | |
echo '>> eturnal is running! ...' | |
sleep 5 | |
break | |
fi | |
if [ "$iterations" -ge "$max_iterations" ]; then | |
echo '>> Loop Timeout!' | |
exit 1 | |
fi | |
done | |
- name: Print eturnal info | |
run: eturnalctl info | |
- name: Create test credentials | |
run: $(brew --prefix)/opt/eturnal/bin/eturnalctl credentials | |
- name: Stop eturnal service | |
run: brew services stop eturnal | |
- name: Lint formula | |
## we know, it fails due to non-executables in the /bin directory, but | |
## we want to see if anything else needs further investigation | |
continue-on-error: true | |
run: brew audit --strict eturnal | |