Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update brew install and add simple tests #16

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
47e692c
fix: replace exists? with exist?
Aaron-Ritter Nov 8, 2024
e6b4299
fix: replace plist with service
Aaron-Ritter Nov 8, 2024
5bc506e
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
93a6966
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
ecf2c13
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
5211b71
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
fca8ae1
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
db4ba3d
ci(e2e-test): add simple fusionauth test
Aaron-Ritter Nov 8, 2024
c72572f
ci(e2e-test): extend test to silent install and use of kickstart
Aaron-Ritter Nov 15, 2024
285f1fe
ci(e2e-test): add dynamic brew prefixes
Aaron-Ritter Nov 15, 2024
efe728a
ci(e2e-test): split tests, add more relative prefixes
Aaron-Ritter Nov 15, 2024
63df60a
ci(e2e-test): add longer wait time for elasticsearch startup
Aaron-Ritter Nov 15, 2024
22f7980
ci(e2e-test): check OK status instead of random sleep
Aaron-Ritter Nov 15, 2024
22111cf
ci(e2e-test): check OK status case insensitive
Aaron-Ritter Nov 15, 2024
a211972
ci(e2e-test): use full path for kickstart
Aaron-Ritter Nov 15, 2024
8f05d9b
ci(e2e-test): check for kickstart completion
Aaron-Ritter Nov 15, 2024
b926473
ci(e2e-test): check for kickstart completion first grep without quiet
Aaron-Ritter Nov 15, 2024
9159404
ci(e2e-test): brew services list and exit 1 for failing status checks
Aaron-Ritter Nov 15, 2024
06caf44
ci(e2e-test): print log if start is failing
Aaron-Ritter Nov 16, 2024
ee50903
feat(fusionauth-app): add debug due to inconsistent ci behaviors
Aaron-Ritter Nov 17, 2024
dfb26d4
refactor(fusionauth-app): fix format
Aaron-Ritter Nov 17, 2024
5b227c0
refactor(fusionauth-app): add shell debug to start
Aaron-Ritter Nov 19, 2024
793960c
Merge branch 'FusionAuth:main' into main
Aaron-Ritter Nov 26, 2024
56ea820
ci(e2e-test): remove fusionauth-search
Aaron-Ritter Dec 11, 2024
18d3b06
Merge branch 'FusionAuth:main' into main
Aaron-Ritter Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# This workflow performs a full End 2 End test of the App
# It runs the test on the last 5 iOS releases.

name: E2E Test with latest FusionAuth

on:
# Triggers the workflow on pull request events but only for default and protected branches
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "e2e-test"
e2e-test:
name: End 2 End Test

permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read

# The type of runner that the job will run on
# https://xcodereleases.com/
# https://developer.apple.com/support/xcode/
# https://developer.apple.com/documentation/xcode-release-notes
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "macos-14", "macos-13" ]
postgresql-version: [ "14", "15", "16" ]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checkout the repository.
- name: Checkout repository
uses: actions/checkout@v4.2.2

# Install FusionAuth with brew.
- name: Install PostgreSQL
run: brew install postgresql@${{ matrix.postgresql-version }} -v

# Start PostgreSQL with brew.
- name: Start PostgreSQL
run: brew services start postgresql@${{ matrix.postgresql-version }} -v

# Add PostgreSQL to the PATH.
- name: Add PostgreSQL to the PATH
run: echo "$(brew --prefix postgresql@${{matrix.postgresql-version }})/bin" >> $GITHUB_PATH

# Add PostgreSQL fusionauth user with default password.
- name: Add PostgreSQL fusionauth user
run: psql --command="CREATE USER fusionauth PASSWORD 'fusionauth'" --command="\du" postgres

# Add PostgreSQL fusionauth database.
- name: Add PostgreSQL fusionauth database
run: createdb --owner=fusionauth fusionauth

# Install FusionAuth App with brew.
- name: Install FusionAuth App
run: brew install --formula ./Formula/fusionauth-app.rb -v

# Configure FusionAuth App with silent mode.
- name: Configure FusionAuth App
run: |
echo "" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties
echo "fusionauth-app.kickstart.file=$(echo $GITHUB_WORKSPACE)/kickstart/kickstart.json" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties
echo "fusionauth-app.silent-mode=true" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties
cat $(brew --prefix)/etc/fusionauth/fusionauth.properties

# Start FusionAuth App.
- name: Start FusionAuth App
run: brew services start fusionauth-app -v

# Check Brew services status.
- name: Check Brew services status
run: brew services list

# Check FusionAuth status 10 times with increasing wait times
# Continue if FusionAuth status is OK or fail at the end.
- name: Check FusionAuth status
run: |
for i in {1..10}; do
if curl -s http://localhost:9011/api/status | grep -qi "ok"; then
echo "FusionAuth is up and running."
exit 0
else
echo "FusionAuth is not up and running. Waiting for $(expr 10 \* $i) seconds."
sleep $(expr 10 \* $i)
fi
done
cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log
exit 1

# Check KickstartRunner execution 10 times with increasing wait times
# Continue if KickstartRunner execution is OK or fail at the end.
# TODO - use webhook instead https://fusionauth.io/docs/extend/events-and-webhooks/events/kickstart-success
- name: Check KickstartRunner execution
run: |
for i in {1..10}; do
if cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log | grep "KickstartRunner" | grep -q "Summary"; then
echo "KickstartRunner execution is OK."
exit 0
else
echo "KickstartRunner execution is not OK. Waiting for $(expr 10 \* $i) seconds."
sleep $(expr 10 \* $i)
fi
done
cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log
exit 1

# Read FusionAuth App logs.
- name: Read FusionAuth App logs
run: cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log

# Connect to FusionAuth App.
- name: Connect to FusionAuth App
run: curl http://localhost:9011/api/status

# Perform E2E test.
# tbd

# Stop FusionAuth App.
- name: Stop FusionAuth App
run: brew services stop fusionauth-app -v

# Stop PostgreSQL.
- name: Stop PostgreSQL
run: brew services stop postgresql@${{ matrix.postgresql-version }} -v
39 changes: 9 additions & 30 deletions Formula/fusionauth-app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class FusionauthApp < Formula

def install
prefix.install "fusionauth-app"
etc.install "config" => "fusionauth" unless File.exists? etc / "fusionauth"
etc.install "config" => "fusionauth" unless File.exist? etc / "fusionauth"
prefix.install_symlink etc / "fusionauth" => "config"
(var / "fusionauth/java").mkpath unless File.exists? var / "fusionauth/java"
(var / "fusionauth/java").mkpath unless File.exist? var / "fusionauth/java"
prefix.install_symlink var / "fusionauth/java"
(var / "log/fusionauth").mkpath unless File.exists? var / "log/fusionauth"
(var / "log/fusionauth").mkpath unless File.exist? var / "log/fusionauth"
prefix.install_symlink var / "log/fusionauth" => "logs"
end

Expand All @@ -25,32 +25,11 @@ def caveats
EOS
end

# http://www.manpagez.com/man/5/launchd.plist/
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>start.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{prefix}/fusionauth-app/bin</string>
<key>StandardOutPath</key>
<string>#{var}/log/fusionauth/fusionauth-app.log</string>
<key>StandardErrorPath</key>
<string>#{var}/log/fusionauth/fusionauth-app.log</string>
</dict>
</plist>
EOS
service do
run ["sh", "-x", "start.sh", "--debug"]
keep_alive true
working_dir opt_prefix/"fusionauth-app/bin"
log_path var/"log/fusionauth/fusionauth-app.log"
error_log_path var/"log/fusionauth/fusionauth-app.log"
end
end
40 changes: 10 additions & 30 deletions Formula/fusionauth-search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class FusionauthSearch < Formula

def install
prefix.install "fusionauth-search"
etc.install "config" => "fusionauth" unless File.exists? etc/"fusionauth"
etc.install "config" => "fusionauth" unless File.exist? etc/"fusionauth"
prefix.install_symlink etc/"fusionauth" => "config"
(var/"log/fusionauth").mkpath unless File.exists? var/"log/fusionauth"
(var/"log/fusionauth").mkpath unless File.exist? var/"log/fusionauth"
prefix.install_symlink var/"log/fusionauth" => "logs"
(var/"fusionauth/java").mkpath unless File.exists? var/"fusionauth/java"
(var/"fusionauth/java").mkpath unless File.exist? var/"fusionauth/java"
prefix.install_symlink var/"fusionauth/java"
(var/"fusionauth/data").mkpath unless File.exists? var/"fusionauth/data"
(var/"fusionauth/data").mkpath unless File.exist? var/"fusionauth/data"
prefix.install_symlink var/"fusionauth/data"

# Hide all the dylibs from brew
Expand All @@ -32,31 +32,11 @@ def caveats; <<~EOS
EOS
end

# http://www.manpagez.com/man/5/launchd.plist/
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>./elasticsearch</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{prefix}/fusionauth-search/elasticsearch/bin</string>
<key>StandardOutPath</key>
<string>#{var}/log/fusionauth/fusionauth-search.log</string>
<key>StandardErrorPath</key>
<string>#{var}/log/fusionauth/fusionauth-search.log</string>
</dict>
</plist>
EOS
service do
run ["sh", "./elasticsearch"]
keep_alive true
working_dir opt_prefix/"fusionauth-search/elasticsearch/bin"
log_path var/"log/fusionauth/fusionauth-search.log"
error_log_path var/"log/fusionauth/fusionauth-search.log"
end
end
Loading